This is my Code.
Dt = BlObj.BlDynamic_Table("[USP_DynamicGridView]", 2);
DtOperation = BlObj.BlDynamic_Table("[USP_DynamicGridView]", 1);
for (int i = 0; i < DtOperation.Rows.Count; i++)
{
Dt.Columns.Add(DtOperation.Rows[i][0].ToString());
}
dgrDynamic.DataSource = Dt;
dgrDynamic.DataBind();
dgrDynamic.Columns.Count is resulting 0 even though there are columns surly.
Related
When am creating excel from datatatble in asp.net date time format is wrong. I just convert date time to 'dd-MM-yyyy', if the date is greater than 12 , it would write correctly , otherwise it would be mm-dd-yyyy format. Actuall am writing '01-11-2016' ie November 1st, but it shows '11-01-2016' in excel. My code is like this. Give me a solution.
int rowsTotal = 0, colsTotal = 0;
int i, j, k;
rowsTotal = dt.Rows.Count;
colsTotal = dt.Columns.Count;
for (i = 0; i <= rowsTotal - 1; i++)
{
k = 0;
for (j = 0; j <= colsTotal - 1; j++)
{
if (gv. Columns[j].Visible)
{
if (dt.Columns[j].DataType.Name == "DateTime")
{
DateTime dtDate = new DateTime();
excelWorksheet.Cells[i + 4, k + 1] = string.Format("{0:dd-MM-yyyy}", dt.Rows[i][j] != DBNull.Value ? Convert.ToDateTime(dt.Rows[i][j]) : dt.Rows[i][j]);
}
else
{
excelWorksheet.Cells[i + 4, k + 1] = dt.Rows[i][j];
}
k += 1;
}
}
}
I am trying to develop a choco solver to the probelm of the Planning of telephone support center. in 12 hours from 8:00 o clock to 20:00.
variables and constraint :
Number of employees = 9
Minimum ans Maximum buisiness hours for every employee (h and H)
buisiness hours foe all employees : 42 hours <= total hours <= 42+C (C in my case equals 2)
Table of numbers of employee who work in every hour ( size of table =12 )
Contrainst who i cant'make :
I got to know the number of nuisiness hours for each employee but I can not put them in tracking hours :/
the result will be :
Final Result
but until now i got my result untill now
I think it's sort problem... please if you can just save my life and tell me what is the missing constraint in my code.
My code
package projetppc;
import java.util.Arrays;
import javax.swing.SortingFocusTraversalPolicy;
import org.chocosolver.solver.Model;
import org.chocosolver.solver.Solution;
import org.chocosolver.solver.variables.IntVar;
public class ProjetPPC {
public void modelAndSolve() {
int k = 9;
int htpj = 12;
int h = 4;
int H = 6;
int C = 2;
int HT = 42;
Model model = new Model(k + "- CAT");
int[] numOfemp = {1, 2, 4, 5, 5, 4, 5, 5, 3, 4, 2, 2};
IntVar[][] matrix = new IntVar[k][htpj];
for (int i = 0; i < k; i++) {
for (int j = 0; j < htpj; j++) {
matrix[i][j] = model.intVar("(" + i + "," + j + ")", 0, 1);
}
}
model.arithm(matrix[0][0], "=", 1).post();
int[] coeffs1 = new int[htpj];
Arrays.fill(coeffs1, 1);
// constraint 1 et 2
for (int i = 0; i < k; i++) {
model.scalar(matrix[i], coeffs1, "<=", H).post();
model.scalar(matrix[i], coeffs1, ">=", h).post();
}
int[] coeffs2 = new int[k];
Arrays.fill(coeffs2, 1);
IntVar[][] inversematrix = new IntVar[htpj][k];
for (int i = 0; i < k; i++) {
for (int j = 0; j < htpj; j++) {
inversematrix[j][i] = matrix[i][j];
}
}
// constraint
for (int i = 0; i < htpj; i++) {
model.scalar(inversematrix[i], coeffs2, "=", numOfemp[i]).post();
}
// constraint
IntVar[] alltable = new IntVar[k * htpj];
for (int i = 0; i < k; i++) {
for (int j = 0; j < htpj; j++) {
alltable[(htpj * i) + j] = matrix[i][j];
}
}
int[] coeffs3 = new int[k * htpj];
Arrays.fill(coeffs3, 1);
model.scalar(alltable, coeffs3, ">=", HT).post();
model.scalar(alltable, coeffs3, "<=", HT + C).post();
// solution
Solution solution = model.getSolver().findSolution();
if (solution != null) {
for (int i = 0; i < k; i++) {
System.out.println("employé " + i + " " + Arrays.toString(matrix[i]));
}
} else {
System.out.println("Pas de solution.");
}
}
public static void main(String[] args) {
new ProjetPPC().modelAndSolve();
}
}
I have tried following code but it writes in vertical way.How can i add 2d array into my listbox
for (int i = 0; i < test.GetLength(0); i++)
{
for (int j = 0; j < test.GetLength(1); j++)
{
ListBox3.Items.Add("-" + test[i, j].ToString());
}
ListBox3.Items.Add("\n");
}
}
This may help you from what I understand from your query;
string listboxstr = "";
for (int i = 0; i < test.GetLength(0); i++)
{
listboxstr = "" + test[i, 0].ToString();
for (int j = 1; j < test.GetLength(1); j++)
{
listboxstr +="-" + test[i, j].ToString();
}
ListBox3.Items.Add(listboxstr);
ListBox3.Items.Add("\n");
}
}
I am having trouble printing my array in a asp:Label. the array is 5 numbers long, but it will only print out one of the numbers when I do the id.Text = arrayname;
Here is the method:
void random4helper()
{
Random rand = new Random();
int min = 1;
int max = 51;
int randomNum;
int i = 0;
int count = 0;
bool loop = true;
while (loop)
{
randomNum = rand.Next(min, max);
if (!meganumbers4.Contains(randomNum))
{
meganumbers4[i] = randomNum;
count += 1;
i += 1;
}
if (count == 5)
{
loop = false;
}
}
for (int j = 0; j < meganumbers4.Length; j++)
{
d.Text = meganumbers4[j] + " ";
}
}
Here is the corresponding Label:
<asp:Label runat="server" id="a" CssClass="print" Text="A"></asp:Label>
You are overwriting the value in each loop. Instead, you need to add the new value to the current value. Change this line:
d.Text = meganumbers4[j] + " ";
To:
d.Text += meganumbers4[j] + " ";
I have a problem with filling a LinkedHashMap with GregorianCalendar-Objects.
I creat a GregorianCalendar starttime. Then I fill it into an ArrayList and add 200 Milliseconds 50 times. After that, I fill these values in a Map together with a double from another ArrayList. When I make a System out of the Map it only gives me the last value of the time list but all values from the double list.
starttime = new GregorianCalendar(2013, 0, 1, 13, 0, 0);
starttime.set(Calendar.MILLISECOND, 0);
GregorianCalendar time = new GregorianCalendar();
time.setTimeInMillis(starttime.getTimeInMillis());
for (int i = 0; i < 50; i++) {
time.add(Calendar.MILLISECOND, 200);
timeList.add(time.getTimeInMillis());
}
for (int i = 0; i < 50; i++) {
time.setTimeInMillis(timeList.get(i));
inputMap.put(time, valueList.get(i));
}
for (Entry<GregorianCalendar, Double> entry : inputMap.entrySet()) {
System.out.println(entry.getKey().getTime().toString()+" "
+entry.getKey().get(Calendar.MILLISECOND)+ " = " + entry.getValue());
}
I found a solution. The Problem is, that time is a reference in the inputMap. So you have to create a new GregorianCalendar in the filling loop.
for (int i = 0; i < 50; i++) {
GregorianCalendar gregCal = new GregorianCalendar();
gregCal.setTimeInMillis(starttime.getTimeInMillis());
inputMap.put(gregCal, valueList.get(i));
starttime.add(Calendar.MILLISECOND, 200);
}