-
Notifications
You must be signed in to change notification settings - Fork 2
/
addremoveworker.aspx.cs
executable file
·82 lines (69 loc) · 3.44 KB
/
addremoveworker.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Web.Configuration;
public partial class addremoveworker : System.Web.UI.Page
{
static SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["automationConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
if (Session["inp"] == null) Response.Redirect("inputLogin.aspx");
if (!Page.IsPostBack)
{
lblmid.Text = Request.QueryString["mid"].ToString();
DataView dvdistinct = (DataView)(sdsdistinctworkerID.Select(DataSourceSelectArguments.Empty));
DataView dvw = (DataView)(sdsworkers.Select(DataSourceSelectArguments.Empty));
dvw.Sort = "workerID";
for (int i = 0; i < dvdistinct.Table.Rows.Count; i++)
{
wid.Value = dvdistinct.Table.Rows[i][0].ToString();
DataView dvfinal = (DataView)(sdsselectfinal.Select(DataSourceSelectArguments.Empty));
if (dvfinal.Table.Rows.Count % 2 == 1)
{
if(dvw.Find(wid.Value)>=0)
ddlremwork.Items.Add(new ListItem(dvw.Table.Rows[dvw.Find(wid.Value)]["workerName"].ToString(),wid.Value));
}
}
for (int i = 0; i < dvw.Table.Rows.Count; i++)
{
wid.Value = dvw.Table.Rows[i][0].ToString();
DataView dvfinal = (DataView)(sdsselectfinal.Select(DataSourceSelectArguments.Empty));
if (dvfinal.Table.Rows.Count % 2 == 0)
ddlworkers.Items.Add(new ListItem(dvw.Table.Rows[dvw.Find(wid.Value)]["workerName"].ToString(), wid.Value));
}
}
}
protected void btnback_Click(object sender, EventArgs e)
{
Response.Redirect(Session["bu"].ToString());
}
protected void addworker_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("insert into [job-worker](job,wid,time,status) values(@j,@w,@t,@s)",con);
cmd.Parameters.AddWithValue("@j",Request.QueryString["jid"].ToString());
cmd.Parameters.AddWithValue("@w",ddlworkers.SelectedValue);
cmd.Parameters.AddWithValue("@t",DateTime.ParseExact(tbadddate.Text, "dd-MM-yyyy",null));
cmd.Parameters.AddWithValue("@s","ADDED");
cmd.ExecuteNonQuery();
con.Close();
Response.Redirect("addremoveworker.aspx?jid="+Request.QueryString["jid"].ToString()+"&mid="+Request.QueryString["mid"].ToString());
}
protected void btremworker_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("insert into [job-worker](job,wid,time,status) values(@j,@w,@t,@s)", con);
cmd.Parameters.AddWithValue("@j", Request.QueryString["jid"].ToString());
cmd.Parameters.AddWithValue("@w", ddlremwork.SelectedValue);
cmd.Parameters.AddWithValue("@t", DateTime.ParseExact(tbremwo.Text, "dd-MM-yyyy", null));
cmd.Parameters.AddWithValue("@s", "REMOVED");
cmd.ExecuteNonQuery();
con.Close();
Response.Redirect("addremoveworker.aspx?jid=" + Request.QueryString["jid"].ToString() + "&mid=" + Request.QueryString["mid"].ToString());
}
}