protected void Button1_Click(object sender, EventArgs e) { string cs = WebConfigurationManager.ConnectionStrings["automationConnectionString"].ConnectionString; SqlConnection conn = new SqlConnection(cs); conn.Open(); string cmd = "INSERT INTO job(machineID,customerID,groupleaderID,worker2ID,startdate) VALUES(@mId,@cId,@gId,@wId,@sdID)"; SqlCommand command = new SqlCommand(cmd, conn); command.Parameters.AddWithValue("@mId", DropDownList1.SelectedValue); command.Parameters.AddWithValue("@cId", DropDownList2.SelectedValue); command.Parameters.AddWithValue("@gId", ddlGroupLeader.SelectedValue); command.Parameters.AddWithValue("@wId", DropDownList4.SelectedValue); command.Parameters.AddWithValue("@sdID", DateTime.ParseExact(TextBoxSD.Text, "dd-MM-yyyy", null)); //command.Parameters.AddWithValue("@cpId", DropDownList5.SelectedValue); command.ExecuteNonQuery(); conn.Close(); GridView1.Sort("machineID", SortDirection.Ascending); SqlDataSourcemachine.Update(); DataView dvj = (DataView)(sdcj.Select(DataSourceSelectArguments.Empty)); DataView dvw = (DataView)(sdcw.Select(DataSourceSelectArguments.Empty)); dvw.Sort = "workerID"; for (int i = 0; i < dvj.Table.Rows.Count; i++) { h.Value = dvj.Table.Rows[i][5].ToString(); sdcw.Update(); h.Value = dvj.Table.Rows[i][6].ToString(); sdcw.Update(); } DataView dvpcurrentjob = (DataView)(selectcurrentjob.Select(DataSourceSelectArguments.Empty)); currjob.Value = dvpcurrentjob.Table.Rows[0][0].ToString(); makeplan(dvpcurrentjob.Table.Rows[0][0].ToString(), Convert.ToDateTime(dvpcurrentjob.Table.Rows[0]["startdate"])); conn.Open(); SqlCommand cm = new SqlCommand("insert into [job-worker](job,wid,time,status) values(@j1,@w1,@t1,@s1)", conn); cm.Parameters.AddWithValue("@j1", currjob.Value); cm.Parameters.AddWithValue("@t1", DateTime.ParseExact(TextBoxSD.Text, "dd-MM-yyyy", null)); cm.Parameters.AddWithValue("@s1", "ADDED"); cm.Parameters.AddWithValue("@w1", ddlGroupLeader.SelectedValue); cm.ExecuteNonQuery(); cm = new SqlCommand("insert into [job-worker](job,wid,time,status) values(@j2,@w2,@t2,@s2)", conn); cm.Parameters.AddWithValue("@j2", currjob.Value); cm.Parameters.AddWithValue("@t2", DateTime.ParseExact(TextBoxSD.Text, "dd-MM-yyyy", null)); cm.Parameters.AddWithValue("@s2", "ADDED"); cm.Parameters.AddWithValue("@w2", DropDownList4.SelectedValue); cm.ExecuteNonQuery(); conn.Close(); Response.Redirect("job.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (Session["inp"] == null) { Response.Redirect("inputLogin.aspx"); } DataView dvm = (DataView)(SqlDataSourcemachine.Select(DataSourceSelectArguments.Empty)); DataView dvl = (DataView)(SqlDataSourcelocation.Select(DataSourceSelectArguments.Empty)); dvl.Sort = "slot"; dvm.Sort = "locationID"; foreach (TableRow tr in ta.Rows) { foreach (TableCell tc in tr.Cells) { string p = tc.ID.ToString(); if (p[0] == 'a') { tc.ID = tc.ID.ToString().TrimStart('a'); int x = dvl.Find(tc.ID); if (x >= 0) { for (int i = 0; i < dvm.Table.Rows.Count; i++) { if (dvm.Table.Rows[i]["locationID"].ToString() == dvl.Table.Rows[x]["Id"].ToString()) { Button b = new Button(); b.Text = dvm.Table.Rows[i]["machineID"].ToString(); b.ID = dvm.Table.Rows[i]["machineID"].ToString(); tc.Controls.Add(b); b.Width = 75; b.Height = 50; if (Convert.ToInt32(dvm.Table.Rows[i]["a_status"].ToString()) == 1) { b.BackColor = System.Drawing.Color.Green; b.PostBackUrl = "inputMap.aspx?mid=" + b.ID; } else { b.BackColor = System.Drawing.Color.Black; } b.ForeColor = System.Drawing.Color.White; } } } } else { string x = tc.ID.ToString().TrimStart('s'); tc.Text = x; tc.BackColor = System.Drawing.Color.Black; tc.ForeColor = System.Drawing.Color.White; } } } foreach (TableRow tr in tb.Rows) { foreach (TableCell tc in tr.Cells) { string p = tc.ID.ToString(); if (p[0] == 'a') { tc.ID = tc.ID.ToString().TrimStart('a'); int x = dvl.Find(tc.ID); if (x >= 0) { for (int i = 0; i < dvm.Table.Rows.Count; i++) { if (dvm.Table.Rows[i]["locationID"].ToString() == dvl.Table.Rows[x]["Id"].ToString()) { Button b = new Button(); b.Text = dvm.Table.Rows[i]["machineID"].ToString(); b.ID = dvm.Table.Rows[i]["machineID"].ToString(); b.Width = 75; b.Height = 50; tc.Controls.Add(b); if (Convert.ToInt32(dvm.Table.Rows[i]["a_status"].ToString()) == 1) { b.BackColor = System.Drawing.Color.Green; b.PostBackUrl = "inputmap.aspx?mid=" + b.ID; } else { b.BackColor = System.Drawing.Color.Black; } b.ForeColor = System.Drawing.Color.White; } } } } else { string x = tc.ID.ToString().TrimStart('s'); tc.Text = x; tc.BackColor = System.Drawing.Color.Black; tc.ForeColor = System.Drawing.Color.White; } } } }