private void CreateTS() { WebForm6 GS = new WebForm6(); var SSS = GS.getsession(); int gogo = 0; //int checkedpass=1; CheckTS(); GetTotalTime(); if (gogo == 1) { SqlConnection con = new SqlConnection(constr); string queryString = "insert into timesheets(project_id,employee_id,status,datework,start_time,end_time,work_hr,desciption)values ('" + DropDownList1.SelectedValue + "','" + SSS + "','pending','" + DateTS.Value + "','" + starttime.Value + "','" + endtime.Value + "','" + span + "','" + Desciption.Value + "')"; con.Open(); SqlCommand cmd = new SqlCommand(queryString, con); cmd.ExecuteNonQuery(); con.Close(); } ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('no success gogo no pass')", true); }
protected void rptLogList_ItemCommand(object source, RepeaterCommandEventArgs e) { WebForm6 GS = new WebForm6(); var SSS = GS.getsession(); if (e.CommandName == ("ApproveCommand")) { TBtest1.Text = e.CommandArgument.ToString(); SqlConnection con = new SqlConnection(constr); con.Open(); string QueryString = "update timesheets set timesheets.status='Approve' where timesheets.id='" + e.CommandArgument.ToString() + "' "; SqlCommand cmd = new SqlCommand(QueryString, con); cmd = new SqlCommand(QueryString, con); cmd.ExecuteNonQuery(); con.Close(); con.Open(); string QueryString3 = "insert into [AppCommit] (TSid,status,WorkerID) values('" + e.CommandArgument.ToString() + "','Aprove', '" + SSS + "' )"; SqlCommand cmd3 = new SqlCommand(QueryString3, con); cmd3 = new SqlCommand(QueryString3, con); cmd3.ExecuteNonQuery(); con.Close(); } if (e.CommandName == ("RejectCommand")) { SqlConnection con = new SqlConnection(constr); con.Open(); string QueryString = "update timesheets set timesheets.status='Reject' where timesheets.id= '" + e.CommandArgument.ToString() + "' "; SqlCommand cmd = new SqlCommand(QueryString, con); cmd = new SqlCommand(QueryString, con); cmd.ExecuteNonQuery(); con.Close(); con.Open(); string QueryString2 = "insert into timesheetdetail (timesheetID,datework,work_start,work_end,desciption,work_hr,status) select timesheets.id ,timesheets.datework,timesheets.start_time,timesheets.end_time,timesheets.desciption,timesheets.work_hr,timesheets.status from timesheets where timesheets.id = '" + e.CommandArgument.ToString() + "' "; SqlCommand cmd2 = new SqlCommand(QueryString2, con); cmd2 = new SqlCommand(QueryString2, con); cmd2.ExecuteNonQuery(); con.Close(); con.Open(); con.Open(); string QueryString4 = "insert into [AppCommit] (TSid,status,WorkerID) values('" + e.CommandArgument.ToString() + "','Reject', '" + SSS + "' )"; SqlCommand cmd4 = new SqlCommand(QueryString4, con); cmd4 = new SqlCommand(QueryString4, con); cmd4.ExecuteNonQuery(); con.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["type"] == null || Session["type"].ToString() != "Manager") { Response.Redirect("Index.aspx"); } if (!Page.IsPostBack) { ReloadData(); } WebForm6 GS = new WebForm6(); var SSS = GS.getsession(); TBtest1.Text = SSS.ToString(); }
public static List <ModelViewTS> getTSCon() { WebForm6 GS = new WebForm6(); var SSS = GS.getsession(); DateTime DateToday = DateTime.Today; List <ModelViewTS> ListAPP = new List <ModelViewTS>(); ModelViewTS ListinTS; //ดึง list log string queryString = @"select timesheets.id as ID ,project.projectname as PJname,[userprofile].firstname+' '+[userprofile].lastname as Name,timesheets.datework as DateW ,work_hr as Hr ,status as ss,start_time as start,end_time as finish ,[timesheets].desciption as descip from timesheets inner join [project]on [project].[id] =[timesheets].[project_id] inner join [userprofile] on [userprofile].id= [timesheets].employee_id union select timesheets.id,[project].projectname,[userprofile].firstname+' '+[userprofile].lastname , timesheetdetail.datework,timesheetdetail.work_hr,timesheetdetail.status ,timesheetdetail.work_start,work_end,timesheetdetail.desciption from timesheetdetail inner join [timesheets] on [timesheets].[id] = [timesheetdetail].timesheetID inner join [project]on [project].[id] =[timesheets].[project_id] inner join [userprofile] on [userprofile].id= [timesheets].employee_id"; con.Open(); /*+เดี่ยวกลับมาแก้ใส่session +*/ SqlCommand command = new SqlCommand(queryString, con); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { ListinTS = new ModelViewTS(); ListinTS.id = (int)reader["ID"]; ListinTS.Projectname = (string)reader["PJname"]; ListinTS.FristnameLastname = (string)reader["Name"]; ListinTS.DateTS = Convert.ToString(reader["DateW"]); ListinTS.Worktime = Convert.ToString(reader["Hr"]); ListinTS.StartTime = Convert.ToString(reader["start"]); ListinTS.EndTime = Convert.ToString(reader["finish"]); ListinTS.Description = Convert.ToString(reader["descip"]); ListinTS.status = Convert.ToString(reader["ss"]); ListAPP.Add(ListinTS); } con.Close(); return(ListAPP); }
public static List <ModelTS> getTSHistory() { WebForm6 GS = new WebForm6(); var SSS = GS.getsession(); DateTime DateToday = DateTime.Today; List <ModelTS> ListAPP = new List <ModelTS>(); ModelTS ListinTS; //ดึง list log string queryString = @"SELECT [timesheets].[id] as ID,[project].projectname, [userprofile].firstname+' '+[userprofile].lastname as Name ,[timesheets].datework as DateWork, [work_hr] as 'WorkHours', [project].end_date as Enddate ,status,[timesheets].desciption FROM [timesheets] Inner Join [project] ON [project].[id] = [timesheets].[project_id] Inner Join [userprofile] ON [userprofile].[id] = [timesheets].[employee_id] where [timesheets].[status]='pending'and [timesheets].project_id IN (select Assign.project_id from Assign where Assign.employee_id = '" + SSS + "')"; con.Open(); /*+เดี่ยวกลับมาแก้ใส่session +*/ SqlCommand command = new SqlCommand(queryString, con); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { ListinTS = new ModelTS(); ListinTS.id = (int)reader["ID"]; ListinTS.Projectname = (string)reader["Projectname"]; ListinTS.FristnameLastname = (string)reader["Name"]; ListinTS.Worktime = Convert.ToString(reader["WorkHours"]); ListinTS.DateTS = Convert.ToString(((DateTime)reader["DateWork"]).ToString("dd/MM/yyyy")); ListinTS.Description = Convert.ToString(reader["Desciption"]); ListinTS.Checkstatus = (DateTime)reader["Enddate"]; ListinTS.status = Convert.ToString(reader["status"]);; ListAPP.Add(ListinTS); } con.Close(); return(ListAPP); }