public static object binDdata(string id) { try { MySQLDB dbc = new MySQLDB(); var objectdata = new List <test>(); JavaScriptSerializer js = new JavaScriptSerializer(); dbc.ConnectToDatabase(); DataTable dt = dbc.GetData("Select religion_id,religion_name,IsMasterData from religion_master where IsDelete=0 order by religion_id"); for (int i = 0; i < dt.Rows.Count; i++) { var model = new test(); model.id = dt.Rows[i]["religion_id"].ToString(); model.name = dt.Rows[i]["religion_name"].ToString(); objectdata.Add(model); } string aa = js.Serialize(objectdata); return(objectdata); } catch (Exception aa) { return(""); } }
private static string List_of_Holiday(string id, MySQLDB dbc, string response) { DataTable dtHolidaydetails = dbc.GetData("SELECT Holiday_Day,Holiday_Month,Holiday_Year,Holiday_Reason,Holiday_For_Id FROM holiday_setup where IsDelete=0 and Holiday_Profile_Id=" + id + " "); for (int i = 0; i < dtHolidaydetails.Rows.Count; i++) { response += dtHolidaydetails.Rows[i]["Holiday_Day"].ToString() + "@" + dtHolidaydetails.Rows[i]["Holiday_Month"].ToString() + "@" + dtHolidaydetails.Rows[i]["Holiday_Year"].ToString() + "@" + dtHolidaydetails.Rows[i]["Holiday_Reason"].ToString() + "@" + dtHolidaydetails.Rows[i]["Holiday_For_Id"].ToString() + "###"; } return(response); }
protected void Page_Load(object sender, EventArgs e) { try { int timegrp = 0; ltrErr.Text = ""; try { if (Request.Cookies.AllKeys.Contains("LoginCookies") && Request.Cookies["LoginCookies"] != null) { int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id); Label header = Master.FindControl("lbl_pageHeader") as Label; int.TryParse(Request.QueryString["TimegrpId"].ToString(), out timegrp); if (timegrp == 0) { header.Text = "Add Time Group Details"; } else { header.Text = "Update Time Group Details"; } } else { Response.Redirect("~/login.aspx", false); } } catch (Exception ex) { Response.Redirect("~/login.aspx", false); } if (!IsPostBack) { txtgroup.Focus(); ViewState["TimegrpId"] = timegrp.ToString(); time_grp.Value = (string)ViewState["TimegrpId"]; DateTime dtt = MySQLDB.GetIndianTime(); string todaydate = (dtt.Day.ToString().Length == 1 ? "0" + dtt.Day.ToString() : dtt.Day.ToString()) + "/" + (dtt.Month.ToString().Length == 1 ? "0" + dtt.Month.ToString() : dtt.Month.ToString()) + "/" + dtt.Year; date.Text = todaydate; getBinddata(timegrp); } } catch (Exception ex) { Logger.WriteCriticalLog("Manage_TimeGroup 75: exception:" + ex.Message + "::::::::" + ex.StackTrace); } }
protected void Page_Load(object sender, EventArgs e) { try { ltrErr.Text = ""; try { if (Request.Cookies.AllKeys.Contains("LoginCookies") && Request.Cookies["LoginCookies"] != null) { int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id); Label header = Master.FindControl("lbl_pageHeader") as Label; header.Text = "Employee Attendance Entry"; } else { Response.Redirect("~/login.aspx", false); } } catch (Exception ex) { Response.Redirect("~/login.aspx", false); } if (!IsPostBack) { DateTime dtt = MySQLDB.GetIndianTime(); string date = (dtt.Day.ToString().Length == 1 ? "0" + dtt.Day.ToString() : dtt.Day.ToString()) + "/" + (dtt.Month.ToString().Length == 1 ? "0" + dtt.Month.ToString() : dtt.Month.ToString()) + "/" + dtt.Year; txtattDate.Text = date; int year = 0; int month = 0; int day = 0; string[] arrdob = date.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); if (arrdob.Length == 3) { int.TryParse(arrdob[2].ToString(), out year); int.TryParse(arrdob[1].ToString(), out month); int.TryParse(arrdob[0].ToString(), out day); bindGvdata(year, month, day); } else { ltrErr.Text = "Attendance Date is not in proper format."; return; } } } catch (Exception ex) { Logger.WriteCriticalLog("Employee_Attendance 73: exception:" + ex.Message + "::::::::" + ex.StackTrace); } }
protected void Page_Load(object sender, EventArgs e) { try { btnsave.Visible = true; //ddlmonthlist.Enabled = false; //ddlyear.Enabled = false; try { if (Request.Cookies.AllKeys.Contains("LoginCookies") && Request.Cookies["LoginCookies"] != null) { int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id); Label header = Master.FindControl("lbl_pageHeader") as Label; header.Text = "Employee Leave Configuration"; } else { Response.Redirect("~/login.aspx", false); } } catch (Exception ex) { Response.Redirect("~/login.aspx", false); } if (!Page.IsPostBack) { BindGrid(-1); bindEmpGroup(); bindMonth(); //bindyear(); for (int i = 2005; i <= 2020; i++) { ddlyear.Items.Add(i.ToString()); } ddlyear.Items.FindByValue(MySQLDB.GetIndianTime().Year.ToString()).Selected = true; mid = int.Parse(ddlmonthlist.SelectedIndex.ToString()); mid = mid + 1; BindEmpLeave(mid, int.Parse(ddlyear.SelectedValue.ToString()), -1); // btnsave.Visible = true; } } //BindGrid(-1); catch (Exception ex) { Logger.WriteCriticalLog("EmpLeaveConfiguration 71: exception:" + ex.Message + "::::::::" + ex.StackTrace); } }
protected void Signout_Click(object sender, EventArgs e) { if (Request.Cookies.AllKeys.Contains("LoginCookies")) { if (Request.Cookies["LoginCookies"] != null) { var user = new HttpCookie("LoginCookies") { Expires = MySQLDB.GetIndianTime().AddDays(-1), Value = null }; Response.Cookies.Add(user); Response.Redirect("~/login.aspx", false); } } }
private void bindMonth() { DataTable dtmonths = new DataTable(); try { DateTime month = Convert.ToDateTime("1/1/2017"); for (int i = 0; i < 12; i++) { DateTime nextMonth = month.AddMonths(i); ListItem list = new ListItem(); list.Text = nextMonth.ToString("MMMM"); list.Value = nextMonth.Month.ToString(); ddlmonthlist.Items.Add(list); } ddlmonthlist.SelectedValue = MySQLDB.GetIndianTime().Month.ToString(); } catch (Exception aa) { Logger.WriteCriticalLog("EmpLeaveConfiguration 123: exception:" + aa.Message + "::::::::" + aa.StackTrace); } }
public static string getHolidayList(string id) { MySQLDB dbc = new MySQLDB(); try { int ids = 0; int.TryParse(id, out ids); dbc.ConnectToDatabase(); DataTable dtholiday = dbc.GetData("SELECT Holiday_day_id FROM employee_management.holiday_profile_master where Holiday_Profile_Id=" + id + " "); string response = ""; if (dtholiday != null && dtholiday.Rows.Count > 0) { response = dtholiday.Rows[0]["Holiday_day_id"].ToString() + "@@@"; } //DataTable dtHolidaydetails = dbc.GetData("SELECT Holiday_Day,Holiday_Month,Holiday_Year,Holiday_Reason,Holiday_For_Id FROM holiday_setup where IsDelete=0 and Holiday_Profile_Id=" + id + " "); //for (int i = 0; i < dtHolidaydetails.Rows.Count; i++) //{ // response += dtHolidaydetails.Rows[i]["Holiday_Day"].ToString() + "@" + dtHolidaydetails.Rows[i]["Holiday_Month"].ToString() + "@" + dtHolidaydetails.Rows[i]["Holiday_Year"].ToString() + "@" + dtHolidaydetails.Rows[i]["Holiday_Reason"].ToString() + "@" + dtHolidaydetails.Rows[i]["Holiday_For_Id"].ToString() + "###"; //} response = List_of_Holiday(id, dbc, response); response = response.TrimEnd('#'); return(response); } catch (Exception ex) { Logger.WriteCriticalLog("Holiday_Setup 249: exception:" + ex.Message + "::::::::" + ex.StackTrace); return(""); } finally { dbc.CloseSQlConnection(); dbc.disposeConnectionObj(); } }
protected void btnsave_Click(object sender, EventArgs e) { objmysqldb.ConnectToDatabase(); try { ltrErr.Text = ""; int grp_id = 0; int.TryParse(time_grp.Value.ToString(), out grp_id); if (txtgroup.Text.Equals("") || SMSintime.Value.ToString().Equals("") || smsout.Value.ToString().Equals("")) { ltrErr.Text = "Please enter all details"; return; } long dateticks = 0; try { string[] arrchangeDate = date.Text.Split('/'); dateticks = new DateTime(int.Parse(arrchangeDate[2]), int.Parse(arrchangeDate[1]), int.Parse(arrchangeDate[0])).Ticks; } catch (Exception aa) { } if (dateticks == 0) { ltrErr.Text = "Please Enter valid Applicable change date"; return; } DataTable dtPreviousTimeConfig = objmysqldb.GetData("select GroupWise_Time_Id,Group_Time_Id,Day_id,In_hour,In_min,out_hour,out_min,Ext_Early_hour,Ext_Early_min,Ext_Late_hour,Ext_Late_min from groupwise_time_config where Group_Time_Id=" + grp_id + " "); DataTable dtPreviousgrpdata = objmysqldb.GetData("select Group_id,Group_Name,Absent_SMS_After,OutPuch_SMS_After,Changes_Applicable_Date from group_master"); if (dtPreviousTimeConfig != null && dtPreviousgrpdata != null) { DataRow[] drgrp = dtPreviousgrpdata.Select("Group_Name ='" + txtgroup.Text.ToString() + "' and Group_id <> " + grp_id + " "); if (drgrp.Length > 0) { ltrErr.Text = "Group name already exists"; return; } DataTable dtdata = new DataTable(); dtdata.Columns.Add("Day_id", typeof(Int32)); dtdata.Columns.Add("In_hour", typeof(Int32)); dtdata.Columns.Add("In_min", typeof(Int32)); dtdata.Columns.Add("out_hour", typeof(Int32)); dtdata.Columns.Add("out_min", typeof(Int32)); dtdata.Columns.Add("Ext_Early_hour", typeof(Int32)); dtdata.Columns.Add("Ext_Early_min", typeof(Int32)); dtdata.Columns.Add("Ext_Late_hour", typeof(Int32)); dtdata.Columns.Add("Ext_Late_min", typeof(Int32)); #region time check foreach (GridViewRow row in grd.Rows) { Label dayid = (Label)row.FindControl("lbldayid"); TextBox txtIn = (TextBox)row.FindControl("txtIntime"); TextBox txtOut = (TextBox)row.FindControl("txtoutTime"); TextBox txtEarly = (TextBox)row.FindControl("txtearly"); TextBox txtLate = (TextBox)row.FindControl("txtlate"); if (txtIn.Text.ToString().Equals("") || txtOut.Text.ToString().Equals("") || txtEarly.Text.ToString().Equals("") || txtLate.Text.ToString().Equals("")) { ltrErr.Text = "Please enter all time slot"; return; } string[] intime = txtIn.Text.ToString().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); string[] outtime = txtOut.Text.ToString().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); string[] Earlytime = txtEarly.Text.ToString().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); string[] latetime = txtLate.Text.ToString().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (intime.Length != 2 || outtime.Length != 2 || Earlytime.Length != 2 || latetime.Length != 2) { ltrErr.Text = "Please enter valid time "; return; } int day = 0; int.TryParse(dayid.Text.ToString(), out day); int In_hour = 0; int In_min = 0; int out_hour = 0; int out_min = 0; int Ext_Early_hour = 0; int Ext_Early_min = 0; int Ext_Late_hour = 0; int Ext_Late_min = 0; int.TryParse(intime[0], out In_hour); int.TryParse(intime[1], out In_min); int.TryParse(outtime[0], out out_hour); int.TryParse(outtime[1], out out_min); int.TryParse(Earlytime[0], out Ext_Early_hour); int.TryParse(Earlytime[1], out Ext_Early_min); int.TryParse(latetime[0], out Ext_Late_hour); int.TryParse(latetime[1], out Ext_Late_min); if (In_hour > 23 || In_min > 59 || out_hour > 23 || out_min > 59 || Ext_Early_hour > 23 || Ext_Early_min > 59 || Ext_Late_hour > 23 || Ext_Late_min > 59) { ltrErr.Text = "Please enter valid time "; return; } dtdata.Rows.Add(day, In_hour, In_min, out_hour, out_min, Ext_Early_hour, Ext_Early_min, Ext_Late_hour, Ext_Late_min); } #endregion objmysqldb.OpenSQlConnection(); objmysqldb.BeginSQLTransaction(); int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id); objmysqldb.AddCommandParameter("Group_Name", txtgroup.Text.ToString()); int absent = 0; int outpunch = 0; int.TryParse(SMSintime.Value.ToString(), out absent); int.TryParse(smsout.Value.ToString(), out outpunch); DateTime currenttime = Logger.getIndiantimeDT(); if (grp_id > 0) { objmysqldb.InsertUpdateDeleteData("update group_master set Group_Name=?Group_Name,Absent_SMS_After=" + absent + ",OutPuch_SMS_After=" + outpunch + ",Changes_Applicable_Date=" + dateticks + ",modify_datetime=" + currenttime.Ticks + ", IsUpdate=1, UserID=" + user_id + " where Group_id = " + grp_id + ""); } else { long mode = currenttime.Ticks; int res = objmysqldb.InsertUpdateDeleteData("insert into group_master (Group_Name,Absent_SMS_After,OutPuch_SMS_After,Changes_Applicable_Date,modify_datetime,DOC,IsUpdate,UserID,IsDelete) values (?Group_Name," + absent + "," + outpunch + "," + dateticks + "," + mode + "," + mode + ",1," + user_id + ",0) "); if (res != 1) { ltrErr.Text = "Please Try Again."; objmysqldb.RollBackSQLTransaction(); Logger.WriteCriticalLog("Manage_TimeGroup 205 Update error."); return; } else { long lastgrpid = objmysqldb.LastNo("group_master", "Group_id", mode); ViewState["TimegrpId"] = lastgrpid.ToString(); time_grp.Value = (string)ViewState["TimegrpId"]; int.TryParse(time_grp.Value.ToString(), out grp_id); //Emp_idHidden.Value = lastEmpid.ToString(); //Response.Redirect("~/ManageEmployee.aspx?Emp=" + Emp_idHidden.Value.ToString() + "", false); } } foreach (DataRow dr in dtdata.Rows) { int retval = objmysqldb.InsertUpdateDeleteData("update groupwise_time_config set In_hour=" + int.Parse(dr["In_hour"].ToString()) + ",In_min=" + int.Parse(dr["In_min"].ToString()) + ",out_hour=" + int.Parse(dr["out_hour"].ToString()) + ",out_min=" + int.Parse(dr["out_min"].ToString()) + ",Ext_Early_hour=" + int.Parse(dr["Ext_Early_hour"].ToString()) + ",Ext_Early_min=" + int.Parse(dr["Ext_Early_min"].ToString()) + ",Ext_Late_hour=" + int.Parse(dr["Ext_Late_hour"].ToString()) + ",Ext_Late_min=" + int.Parse(dr["Ext_Late_min"].ToString()) + ",modify_datetime=" + currenttime.Ticks + ",IsUpdate=1,UserID=" + user_id + " where Group_Time_Id=" + grp_id + " and Day_id=" + int.Parse(dr["Day_id"].ToString()) + " "); if (retval == 0) { retval = objmysqldb.InsertUpdateDeleteData("insert into groupwise_time_config (Group_Time_Id,Day_id,In_hour,In_min,out_hour,out_min,Ext_Early_hour,Ext_Early_min,Ext_Late_hour,Ext_Late_min,modify_datetime,DOC,IsUpdate,UserID) values (" + grp_id + "," + int.Parse(dr["Day_id"].ToString()) + "," + int.Parse(dr["In_hour"].ToString()) + "," + int.Parse(dr["In_min"].ToString()) + "," + int.Parse(dr["out_hour"].ToString()) + "," + int.Parse(dr["out_min"].ToString()) + "," + int.Parse(dr["Ext_Early_hour"].ToString()) + "," + int.Parse(dr["Ext_Early_min"].ToString()) + "," + int.Parse(dr["Ext_Late_hour"].ToString()) + "," + int.Parse(dr["Ext_Late_min"].ToString()) + "," + currenttime.Ticks + "," + currenttime.Ticks + ",1," + user_id + ")"); } } // Applicable Date change string[] arrdob = date.Text.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); DateTime dtcur = MySQLDB.GetIndianTime(); if (arrdob.Length == 3) { DateTime dtchangeDate = new DateTime(int.Parse(arrdob[2]), int.Parse(arrdob[1]), int.Parse(arrdob[0])); DateTime dtcurrent = new DateTime(dtcur.Year, dtcur.Month, dtcur.Day); TimeSpan dtDiff = dtchangeDate - dtcurrent; DateTime dtstartdate = dtcurrent; if (dtDiff.Days < 0) { dtDiff = dtcurrent - dtchangeDate; dtstartdate = dtchangeDate; } #region datewise entry DateTime currenttimes = Logger.getIndiantimeDT(); for (int d = 0; d <= dtDiff.Days; d++) { DateTime dtt = dtstartdate.AddDays(d); //foreach (DataRow dr in dtdata.Rows) int days = (int)dtt.DayOfWeek; if (days == 0) { days = 7; } DataRow[] drdaywise = dtdata.Select("Day_id =" + days + " "); foreach (DataRow dr in drdaywise) { int retval = objmysqldb.InsertUpdateDeleteData("update employee_punchtime_details_datewise set In_hour=" + int.Parse(dr["In_hour"].ToString()) + ",In_min=" + int.Parse(dr["In_min"].ToString()) + ",out_hour=" + int.Parse(dr["out_hour"].ToString()) + ",out_min=" + int.Parse(dr["out_min"].ToString()) + ",Ext_Early_hour=" + int.Parse(dr["Ext_Early_hour"].ToString()) + ",Ext_Early_min=" + int.Parse(dr["Ext_Early_min"].ToString()) + ",Ext_Late_hour=" + int.Parse(dr["Ext_Late_hour"].ToString()) + ",Ext_Late_min=" + int.Parse(dr["Ext_Late_min"].ToString()) + ",modify_datetime=" + currenttimes.Ticks + ",IsUpdate=1,UserID=" + user_id + " where time_grp_id=" + grp_id + " and Day_id=" + int.Parse(dr["Day_id"].ToString()) + " and Dateticks=" + dtt.Ticks + " "); if (retval == 0) { retval = objmysqldb.InsertUpdateDeleteData("insert into employee_punchtime_details_datewise (Dateticks,time_grp_id,Day_id,In_hour,In_min,out_hour,out_min,Ext_Early_hour,Ext_Early_min,Ext_Late_hour,Ext_Late_min,modify_datetime,DOC,IsUpdate,UserID,IsDelete) values (" + dtt.Ticks + "," + grp_id + "," + int.Parse(dr["Day_id"].ToString()) + "," + int.Parse(dr["In_hour"].ToString()) + "," + int.Parse(dr["In_min"].ToString()) + "," + int.Parse(dr["out_hour"].ToString()) + "," + int.Parse(dr["out_min"].ToString()) + "," + int.Parse(dr["Ext_Early_hour"].ToString()) + "," + int.Parse(dr["Ext_Early_min"].ToString()) + "," + int.Parse(dr["Ext_Late_hour"].ToString()) + "," + int.Parse(dr["Ext_Late_min"].ToString()) + "," + currenttimes.Ticks + "," + currenttimes.Ticks + ",1," + user_id + ",0)"); } } } DataTable dtgroupdata = new DataTable(); dtgroupdata = objmysqldb.GetData("select * from employee_management.time_group_assign_emplyee_wise where Group_id=" + grp_id + ""); if (dtgroupdata.Rows.Count > 0 && dtgroupdata != null) { for (int d1 = 0; d1 <= dtDiff.Days; d1++) { DateTime dtt1 = dtstartdate.AddDays(d1); //foreach (DataRow dr in dtdata.Rows) int days1 = (int)dtt1.DayOfWeek; if (days1 == 0) { days1 = 7; } DataRow[] drdaywise1 = dtdata.Select("Day_id =" + days1 + " "); for (int emp = 0; emp < dtgroupdata.Rows.Count; emp++) { foreach (DataRow dr in drdaywise1) { int retval = objmysqldb.InsertUpdateDeleteData("update employeewise_punchtime_details_datewise set In_hour=" + int.Parse(dr["In_hour"].ToString()) + ",In_min=" + int.Parse(dr["In_min"].ToString()) + ",out_hour=" + int.Parse(dr["out_hour"].ToString()) + ",out_min=" + int.Parse(dr["out_min"].ToString()) + ",Ext_Early_hour=" + int.Parse(dr["Ext_Early_hour"].ToString()) + ",Ext_Early_min=" + int.Parse(dr["Ext_Early_min"].ToString()) + ",Ext_Late_hour=" + int.Parse(dr["Ext_Late_hour"].ToString()) + ",Ext_Late_min=" + int.Parse(dr["Ext_Late_min"].ToString()) + ",modify_datetime=" + currenttimes.Ticks + ",IsUpdate=1,UserID=" + user_id + " where emp_id=" + int.Parse(dtgroupdata.Rows[emp]["emp_id"].ToString()) + " and Day_id=" + int.Parse(dr["Day_id"].ToString()) + " and Dateticks=" + dtt1.Ticks + " "); if (retval == 0) { retval = objmysqldb.InsertUpdateDeleteData("insert into employeewise_punchtime_details_datewise (Dateticks,emp_id,Day_id,In_hour,In_min,out_hour,out_min,Ext_Early_hour,Ext_Early_min,Ext_Late_hour,Ext_Late_min,modify_datetime,DOC,IsUpdate,UserID,IsDelete) values (" + dtt1.Ticks + "," + int.Parse(dtgroupdata.Rows[emp]["emp_id"].ToString()) + "," + int.Parse(dr["Day_id"].ToString()) + "," + int.Parse(dr["In_hour"].ToString()) + "," + int.Parse(dr["In_min"].ToString()) + "," + int.Parse(dr["out_hour"].ToString()) + "," + int.Parse(dr["out_min"].ToString()) + "," + int.Parse(dr["Ext_Early_hour"].ToString()) + "," + int.Parse(dr["Ext_Early_min"].ToString()) + "," + int.Parse(dr["Ext_Late_hour"].ToString()) + "," + int.Parse(dr["Ext_Late_min"].ToString()) + "," + currenttimes.Ticks + "," + currenttimes.Ticks + ",1," + user_id + ",0)"); } } } } } #endregion ltrErr.Text = "Time Group Details Save Successfully"; objmysqldb.EndSQLTransaction(); } else { ltrErr.Text = "Please Enter valid Applicable change date"; objmysqldb.RollBackSQLTransaction(); } } else { ltrErr.Text = "Please try again"; return; } } catch (Exception ex) { objmysqldb.RollBackSQLTransaction(); Logger.WriteCriticalLog("Manage_TimeGroup 288: exception:" + ex.Message + "::::::::" + ex.StackTrace); } finally { objmysqldb.CloseSQlConnection(); objmysqldb.disposeConnectionObj(); } }
public static string saveHolidayProfile(string id, string Name, string userid, string holiday_day) { MySQLDB dbc = new MySQLDB(); try { string msg = ""; int ids = 0; int.TryParse(id, out ids); dbc.ConnectToDatabase(); DataTable dtHolidayProfile = dbc.GetData("SELECT Holiday_Profile_Id,Holiday_Profile_Name,Holiday_day_id FROM holiday_profile_master "); string response = ""; DataRow[] drdata = dtHolidayProfile.Select("Holiday_Profile_Name ='" + Name + "' and Holiday_Profile_Id <> " + id + " "); dbc.OpenSQlConnection(); dbc.BeginSQLTransaction(); if (drdata.Length == 0) { holiday_day = holiday_day.TrimEnd(','); DateTime currenttime = Logger.getIndiantimeDT(); int user_ids = 0; int.TryParse(userid, out user_ids); int retval = dbc.InsertUpdateDeleteData("update holiday_profile_master set Holiday_Profile_Name='" + Name + "',modify_datetime=" + currenttime.Ticks + ",IsUpdate=1,UserID=" + user_ids + ",Holiday_day_id='" + holiday_day + "' where Holiday_Profile_Id=" + id + " "); if (retval == 0) { retval = dbc.InsertUpdateDeleteData("insert into holiday_profile_master (Holiday_Profile_Name,modify_datetime,DOC,IsUpdate,UserID,Holiday_day_id) values ('" + Name + "'," + currenttime.Ticks + "," + currenttime.Ticks + ",1," + user_ids + ",'" + holiday_day + "')"); if (retval != 1) { msg = "please try again"; Logger.WriteCriticalLog("Holiday_Setup 123 Update error."); } else { msg = "Save sucessfully"; } } else { //Holiday setup code DataRow[] drdatas = dtHolidayProfile.Select("Holiday_Profile_Id = " + id + " "); if (drdatas.Length > 0) { string[] old_Weekoff = drdatas[0]["Holiday_day_id"].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] New_Weekoff = holiday_day.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (old_Weekoff.Length > 0) { string weekoff = ""; for (int k = 0; k < old_Weekoff.Length; k++) { if (!New_Weekoff.Contains(old_Weekoff[k])) { weekoff += old_Weekoff[k] + ","; } } string[] Weekoffday = weekoff.ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (Weekoffday.Length > 0) { DataTable dtholidaySetup = dbc.GetData("select distinct Holiday_Month,Holiday_Year from holiday_setup where Holiday_For_Id=2 and Holiday_Profile_Id=" + id + " and IsDelete=0;"); if (dtholidaySetup != null && dtholidaySetup.Rows.Count > 0) { int mon = 0; int year = 0; for (int mo = 0; mo < dtholidaySetup.Rows.Count; mo++) { int.TryParse(dtholidaySetup.Rows[mo]["Holiday_Month"].ToString(), out mon); int.TryParse(dtholidaySetup.Rows[mo]["Holiday_Year"].ToString(), out year); int LastDate = DateTime.DaysInMonth(year, mon); string dates = DateOfGivenDay(Weekoffday, mon, year, LastDate); dates = dates.TrimEnd(','); if (!dates.Equals("")) { DateTime currenttimes = Logger.getIndiantimeDT(); retval = dbc.InsertUpdateDeleteData("update holiday_setup set modify_datetime=" + currenttimes.Ticks + ",IsUpdate=1,UserID=" + user_ids + ",IsDelete=1 where Holiday_Day IN(" + dates + ") and Holiday_Month=" + mon + " and Holiday_Year=" + year + " and Holiday_Profile_Id=" + id + " and Holiday_For_Id=2"); } } } } } } msg = "Save sucessfully"; } dtHolidayProfile = dbc.GetData("SELECT Holiday_Profile_Id,Holiday_Profile_Name FROM holiday_profile_master "); for (int i = 0; i < dtHolidayProfile.Rows.Count; i++) { if (i == 0) { response = response + "-1,"; response = response + "Select Holiday Profile ###"; } response = response + dtHolidayProfile.Rows[i]["Holiday_Profile_Id"].ToString() + ","; response = response + dtHolidayProfile.Rows[i]["Holiday_Profile_Name"].ToString() + "###"; } response = response.TrimEnd('#'); response = response + "@@@" + msg; } else { msg = "Holiday profile name is already exists"; response = "@@@" + msg; } dbc.EndSQLTransaction(); return(response); } catch (Exception ex) { dbc.RollBackSQLTransaction(); Logger.WriteCriticalLog("Holiday_Setup 206: exception:" + ex.Message + "::::::::" + ex.StackTrace); return("@@@please try again"); } finally { dbc.CloseSQlConnection(); dbc.disposeConnectionObj(); } }
public static string MangeHolidays(string id, string type, string date, string reason, string range, string flag, string userid) { MySQLDB dbc = new MySQLDB(); try { int ids = 0; int.TryParse(id, out ids); int typ = 0; int.TryParse(type, out typ); int fla = 0; int.TryParse(flag, out fla); string msg = ""; string[] dates = date.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); int day = 0; int mon = 0; int yea = 0; dbc.ConnectToDatabase(); int user_ids = 0; int.TryParse(userid, out user_ids); if (dates.Length == 3) { dbc.OpenSQlConnection(); int.TryParse(dates[0], out day); int.TryParse(dates[1], out mon); int.TryParse(dates[2], out yea); if (fla == 1) //delete { DateTime currenttime = Logger.getIndiantimeDT(); int retval = dbc.InsertUpdateDeleteData("update holiday_setup set modify_datetime=" + currenttime.Ticks + ",IsUpdate=1,UserID=" + user_ids + ",IsDelete=1 where Holiday_Day=" + day + " and Holiday_Month=" + mon + " and Holiday_Year=" + yea + " and Holiday_Profile_Id=" + ids + " "); msg = "Holiday remove Successfully"; } else { string[] rangedates = range.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); int start = 0; int end = 0; if (rangedates.Length == 2) { int.TryParse(rangedates[0], out start); int.TryParse(rangedates[1], out end); } int diff = end - start; for (int i = 0; i <= diff; i++) { DateTime currenttime = Logger.getIndiantimeDT(); dbc.AddCommandParameter("Holiday_Reason", reason); int retval = dbc.InsertUpdateDeleteData("update holiday_setup set modify_datetime=" + currenttime.Ticks + ",IsUpdate=1,UserID=" + user_ids + ",Holiday_For_Id=" + typ + ",Holiday_Reason=?Holiday_Reason where Holiday_Day=" + day + " and Holiday_Month=" + mon + " and Holiday_Year=" + yea + " and Holiday_Profile_Id=" + id + " and IsDelete=0 "); if (retval == 0) { dbc.AddCommandParameter("Holiday_Reason", reason); retval = dbc.InsertUpdateDeleteData("insert into holiday_setup (Holiday_Day,Holiday_Month,Holiday_Year,Holiday_Reason,Holiday_For_Id,Holiday_Profile_Id,modify_datetime,DOC,IsUpdate,IsDelete,UserID) values (" + day + "," + mon + "," + yea + " ,?Holiday_Reason," + typ + "," + id + "," + currenttime.Ticks + "," + currenttime.Ticks + ",1,0," + user_ids + ")"); if (retval != 1) { msg = "Please try again"; Logger.WriteCriticalLog("Holiday_Setup 433 Update error."); break; } } day++; } if (msg.Equals("")) { msg = "Holiday save Successfully"; } } } else { msg = "Please Select Valid Date"; } DataTable dtholiday = dbc.GetData("SELECT Holiday_day_id FROM employee_management.holiday_profile_master where Holiday_Profile_Id=" + id + " "); string response = ""; if (dtholiday != null && dtholiday.Rows.Count > 0) { response = dtholiday.Rows[0]["Holiday_day_id"].ToString() + "@@@"; } response = List_of_Holiday(id, dbc, response); response = response.TrimEnd('#'); response = response + "@@##" + msg; return(response); } catch (Exception ex) { Logger.WriteCriticalLog("Holiday_Setup 468: exception:" + ex.Message + "::::::::" + ex.StackTrace); return(""); } finally { dbc.CloseSQlConnection(); dbc.disposeConnectionObj(); } }
public static string saveDefaultSetup(string id, string month, string userid) { MySQLDB dbc = new MySQLDB(); try { int ids = 0; int.TryParse(id, out ids); string[] months = month.Split('@'); int mon = 0; int year = 0; int.TryParse(months[0], out mon); int.TryParse(months[1], out year); int LastDate = DateTime.DaysInMonth(year, mon); dbc.ConnectToDatabase(); int user_ids = 0; int.TryParse(userid, out user_ids); DataTable dtholiday = dbc.GetData("SELECT Holiday_day_id FROM employee_management.holiday_profile_master where Holiday_Profile_Id=" + id + " "); string response = ""; if (dtholiday != null && dtholiday.Rows.Count > 0) { string[] Weekoff = dtholiday.Rows[0]["Holiday_day_id"].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string dates = DateOfGivenDay(Weekoff, mon, year, LastDate); dates = dates.TrimEnd(','); string[] date = dates.ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); dbc.OpenSQlConnection(); dbc.BeginSQLTransaction(); for (int i = 0; i < date.Length; i++) { DateTime currenttime = Logger.getIndiantimeDT(); int retval = dbc.InsertUpdateDeleteData("update holiday_setup set modify_datetime=" + currenttime.Ticks + ",IsUpdate=1,UserID=" + user_ids + " where Holiday_Day=" + int.Parse(date[i].ToString()) + " and Holiday_Month=" + mon + " and Holiday_Year=" + year + " and Holiday_Profile_Id=" + id + " and IsDelete=0 "); if (retval == 0) { retval = dbc.InsertUpdateDeleteData("insert into holiday_setup (Holiday_Day,Holiday_Month,Holiday_Year,Holiday_Reason,Holiday_For_Id,Holiday_Profile_Id,modify_datetime,DOC,IsUpdate,IsDelete,UserID) values (" + int.Parse(date[i].ToString()) + "," + mon + "," + year + " ,'Week off',2," + id + "," + currenttime.Ticks + "," + currenttime.Ticks + ",1,0," + user_ids + ")"); if (retval != 1) { dbc.RollBackSQLTransaction(); Logger.WriteCriticalLog("Holiday_Setup 302 Update error."); return(response); } } } response = dtholiday.Rows[0]["Holiday_day_id"].ToString() + "@@@"; } dbc.EndSQLTransaction(); response = List_of_Holiday(id, dbc, response); response = response.TrimEnd('#'); return(response); } catch (Exception ex) { Logger.WriteCriticalLog("Holiday_Setup 321: exception:" + ex.Message + "::::::::" + ex.StackTrace); return(""); } finally { dbc.CloseSQlConnection(); dbc.disposeConnectionObj(); } }
protected void BtnSave_Click(object sender, EventArgs e) { objmysqldb.ConnectToDatabase(); objmysqldb.OpenSQlConnection(); try { string Emp_Ids = ""; DataTable dtAllDate = objmysqldb.GetData("SELECT Dateticks,emp_id,Day_id From employee_management.employeewise_punchtime_details_datewise;"); DateTime currentTime = Logger.getIndiantimeDT(); int In_hour = 0; int In_min = 0; int out_hour = 0; int out_min = 0; int Ext_Early_hour = 0; int Ext_Early_min = 0; int Ext_Late_hour = 0; int Ext_Late_min = 0; string[] intime = txtinTime.Text.ToString().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); string[] outtime = txtoutTime.Text.ToString().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); string[] Earlytime = txtExtremeEarly.Text.ToString().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); string[] latetime = txtExtremeLate.Text.ToString().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); int.TryParse(intime[0], out In_hour); int.TryParse(intime[1], out In_min); int.TryParse(outtime[0], out out_hour); int.TryParse(outtime[1], out out_min); int.TryParse(Earlytime[0], out Ext_Early_hour); int.TryParse(Earlytime[1], out Ext_Early_min); int.TryParse(latetime[0], out Ext_Late_hour); int.TryParse(latetime[1], out Ext_Late_min); if (In_hour > 23 || In_min > 59 || out_hour > 23 || out_min > 59 || Ext_Early_hour > 23 || Ext_Early_min > 59 || Ext_Late_hour > 23 || Ext_Late_min > 59) { ltrErr.Text = "Please Enter valid time "; return; } //Control ctl = this.FindControlRecursive("btnAccept"); string str = string.Empty; foreach (GridViewRow gvrow in GrdEmpList.Rows) { CheckBox chk = (CheckBox)gvrow.FindControl("chkSelect"); if (chk.Checked && chk != null) { Label emp = (Label)gvrow.FindControl("lblemp_id"); Emp_Ids += emp.Text.ToString() + ","; } } string dt = ""; foreach (GridViewRow row in GvMonth.Rows) { CheckBox chkdt = (CheckBox)row.FindControl("Select"); if (chkdt.Checked && chkdt != null) { Label date1 = (Label)row.FindControl("lblDate"); dt += date1.Text.ToString() + ","; } } dt = dt.TrimEnd(','); Emp_Ids = Emp_Ids.TrimEnd(','); string date = lblDate1.Text.ToString(); //DateTime oDate = Convert.ToDateTime(date.ToString()); //long Tikcs = oDate.Ticks; //DateTime dtNew = new DateTime(Tikcs); //int day1 = (int)dtNew.DayOfWeek; string[] arrempid = Emp_Ids.Split(','); int dayid = 0; long Tikcs = 0; string[] dates = dt.Split(','); dates = dates.Where(s => !String.IsNullOrEmpty(s)).ToArray(); //string[] dates = !String.IsNullOrEmpty(dt)).ToArray(); if (dates != null && dates.Length == 0) { DateTime oDate = Convert.ToDateTime(date.ToString()); Tikcs = oDate.Ticks; //DateTime dtNew = new DateTime(Tikcs); dayid = (int)oDate.DayOfWeek; if (dayid == 0) { dayid = 7; } } if (arrempid != null && arrempid.Length > 0) { int Yes = 0; for (int j = 0; j < arrempid.Length; j++) { string EmpID = arrempid[j].ToString(); if (dates != null && dates.Length == 0) { //DataRow[] dr = dtAllDate.Select("emp_id=" + EmpID + " And Day_id=" + dayid + " and Dateticks in('" + Tikcs + "')"); DataRow[] dr = dtAllDate.Select("emp_id=" + EmpID + " And Day_id=" + dayid + " and Dateticks=" + Tikcs + ""); if (dayid == 0) { dayid = 7; } if (dr.Length > 0) { Yes = objmysqldb.InsertUpdateDeleteData("update employeewise_punchtime_details_datewise set In_hour=" + In_hour + ",In_min=" + In_min + ",out_hour=" + out_hour + ",out_min=" + out_min + " ,Ext_Early_hour=" + Ext_Early_hour + ",Ext_Early_min=" + Ext_Early_min + ",Ext_Late_hour=" + Ext_Late_hour + ",Ext_Late_min=" + Ext_Late_min + ",modify_datetime=" + MySQLDB.GetIndianTime().Ticks.ToString() + ",IsUpdate=1, UserID= " + user_id + " where emp_id=" + EmpID + " and Day_id=" + dayid); } else { Yes = objmysqldb.InsertUpdateDeleteData("insert into employeewise_punchtime_details_datewise(Dateticks,emp_id,Day_id,In_hour,In_min,out_hour,out_min,Ext_Early_hour,Ext_Late_hour,Ext_Late_min,Ext_Early_min,modify_datetime,IsDelete,DOC,IsUpdate,UserID)Values(" + Tikcs + "," + EmpID + "," + dayid + "," + In_hour + "," + In_min + "," + out_hour + "," + out_min + "," + Ext_Early_hour + "," + Ext_Late_hour + "," + Ext_Late_min + "," + Ext_Early_min + "," + MySQLDB.GetIndianTime().Ticks.ToString() + ",0," + MySQLDB.GetIndianTime().Ticks.ToString() + ",1," + user_id + ")"); } } else { for (int dat = 0; dat < dates.Length; dat++) { string dt1 = dates[dat].ToString(); DateTime oDate = Convert.ToDateTime(dt1.ToString()); Tikcs = oDate.Ticks; dayid = (int)oDate.DayOfWeek; if (dayid == 0) { dayid = 7; } //DataRow[] dr = dtAllDate.Select("emp_id=" + EmpID + " And Day_id=" + dayid + " and Dateticks in('" + Tikcs + "')"); DataRow[] dr = dtAllDate.Select("emp_id=" + EmpID + " And Day_id=" + dayid + " and Dateticks=" + Tikcs + ""); if (dr.Length > 0) { Yes = objmysqldb.InsertUpdateDeleteData("update employeewise_punchtime_details_datewise set In_hour=" + In_hour + ",In_min=" + In_min + ",out_hour=" + out_hour + ",out_min=" + out_min + " ,Ext_Early_hour=" + Ext_Early_hour + ",Ext_Early_min=" + Ext_Early_min + ",Ext_Late_hour=" + Ext_Late_hour + ",Ext_Late_min=" + Ext_Late_min + ",modify_datetime=" + MySQLDB.GetIndianTime().Ticks.ToString() + ",IsUpdate=1, UserID= " + user_id + " where emp_id=" + EmpID + " and Day_id=" + dayid); } else { Yes = objmysqldb.InsertUpdateDeleteData("insert into employeewise_punchtime_details_datewise(Dateticks,emp_id,Day_id,In_hour,In_min,out_hour,out_min,Ext_Early_hour,Ext_Late_hour,Ext_Late_min,Ext_Early_min,modify_datetime,IsDelete,DOC,IsUpdate,UserID)Values(" + Tikcs + "," + EmpID + "," + dayid + "," + In_hour + "," + In_min + "," + out_hour + "," + out_min + "," + Ext_Early_hour + "," + Ext_Late_hour + "," + Ext_Late_min + "," + Ext_Early_min + "," + MySQLDB.GetIndianTime().Ticks.ToString() + ",0," + MySQLDB.GetIndianTime().Ticks.ToString() + ",1," + user_id + ")"); } } } } if (Yes == -1) { ltrErr1.Text = "Error While Saving.."; } else { ltrErr1.Text = "Time Configuration Saved..."; } } else { ltrErr1.Text = "Select Atleast One Employee..."; } } catch (Exception ex) { Logger.WriteCriticalLog("TimeConfigForEmp BenSaveClick(): exception:" + ex.Message + "::::::::" + ex.StackTrace); } finally { objmysqldb.CloseSQlConnection(); objmysqldb.disposeConnectionObj(); } }
protected void btnSave_Click(object sender, EventArgs e) { try { this.ltrErr.Text = ""; objmysqldb.ConnectToDatabase(); objmysqldb.OpenSQlConnection(); int yes = 0; if (this.ddlEmp.SelectedIndex > 0) { string emp_id = this.ddlEmp.SelectedValue.ToString(); DataTable data = this.objmysqldb.GetData("SELECT Dateticks, emp_id,Day_id,In_hour,In_min,out_hour,out_min,Ext_Early_hour,Ext_Early_min,Ext_Late_hour,Ext_Late_min FROM employee_management.employeewise_punchtime_details_datewise where emp_id=" + int.Parse(emp_id) + " "); if (data != null && data.Rows.Count > 0) { IEnumerator enumerator = this.grdData.Rows.GetEnumerator(); try { while (enumerator.MoveNext()) { GridViewRow gridViewRow = (GridViewRow)enumerator.Current; Label lbldate = (Label)gridViewRow.FindControl("lblDate"); Label dayid = (Label)gridViewRow.FindControl("lbldayid"); TextBox txtintime = (TextBox)gridViewRow.FindControl("txtIntime"); TextBox txtouttime = (TextBox)gridViewRow.FindControl("txtoutTime"); TextBox txtearly = (TextBox)gridViewRow.FindControl("txtearly"); TextBox txtlate = (TextBox)gridViewRow.FindControl("txtlate"); string[] arr_ = txtintime.Text.ToString().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); string[] arr_2 = txtouttime.Text.ToString().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); string[] arr_3 = txtearly.Text.ToString().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); string[] arr_4 = txtlate.Text.ToString().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); int day = 0; int.TryParse(dayid.Text.ToString(), out day); if (day == 0) { day = 7; } int inmin = 0; int inhour = 0; int outmin = 0; int outhour = 0; int earlymin = 0; int earlyhour = 0; int latemin = 0; int latehour = 0; int.TryParse(arr_[0], out inmin); int.TryParse(arr_[1], out inhour); int.TryParse(arr_2[0], out outmin); int.TryParse(arr_2[1], out outhour); int.TryParse(arr_3[0], out earlymin); int.TryParse(arr_3[1], out earlyhour); int.TryParse(arr_4[0], out latemin); int.TryParse(arr_4[1], out latehour); DateTime indiantimeDT = Logger.getIndiantimeDT(); if (inmin > 23 || inhour > 59 || outmin > 23 || outhour > 59 || earlymin > 23 || earlyhour > 59 || latemin > 23 || latehour > 59) { this.ltrErr.Text = "Please enter valid time "; return; } DateTime dateTime = Convert.ToDateTime(lbldate.Text.ToString()); long ticks = dateTime.Ticks; DataRow[] dr = data.Select("emp_id=" + emp_id + "and Day_id=" + day + " and DateTicks in ('" + ticks + "')"); if (dr.Length > 0) { string in_hour = dr[0]["In_hour"].ToString(); string in_min = dr[0]["In_min"].ToString(); string out_hour = dr[0]["out_hour"].ToString(); string out_min = dr[0]["out_min"].ToString(); string early_hour = dr[0]["Ext_Early_hour"].ToString(); string early_min = dr[0]["Ext_Early_min"].ToString(); string late_hour = dr[0]["Ext_Late_hour"].ToString(); string late_min = dr[0]["Ext_Late_min"].ToString(); if (!in_hour.Equals("inhour") || !in_min.Equals("inmin") || !out_hour.Equals("outhour") || !out_min.Equals("outmin") || !early_hour.Equals("earlyhour") || !early_min.Equals("earlymin") || !late_hour.Equals("latehour") || !late_min.Equals("latemin")) { yes = objmysqldb.InsertUpdateDeleteData("update employeewise_punchtime_details_datewise set In_hour=" + inhour + ",In_min=" + inmin + ",out_hour=" + outhour + ",out_min=" + outmin + " ,Ext_Early_hour=" + earlyhour + ",Ext_Early_min=" + earlymin + ",Ext_Late_hour=" + latehour + ",Ext_Late_min=" + latemin + ",modify_datetime=" + MySQLDB.GetIndianTime().Ticks.ToString() + ",IsUpdate=1, UserID= " + user_id + " where emp_id=" + emp_id + " and Day_id=" + day + " and DateTicks=" + ticks + ""); } } else { DateTime dateTime2 = new DateTime(ticks); int dayOfWeek = (int)dateTime2.DayOfWeek; yes = objmysqldb.InsertUpdateDeleteData("insert into employeewise_punchtime_details_datewise(Dateticks,emp_id,Day_id,In_hour,In_min,out_hour,out_min,Ext_Early_hour,Ext_Late_hour,Ext_Late_min,Ext_Early_min,modify_datetime,IsDelete,DOC,IsUpdate,UserID)Values(" + ticks + "," + emp_id + "," + dayid + "," + inhour + "," + inmin + "," + outhour + "," + outmin + "," + earlyhour + "," + latehour + "," + latemin + "," + earlymin + "," + MySQLDB.GetIndianTime().Ticks.ToString() + ",0," + MySQLDB.GetIndianTime().Ticks.ToString() + ",1," + user_id + ")"); } } } finally { objmysqldb.CloseSQlConnection(); objmysqldb.disposeConnectionObj(); } if (yes > 0) { this.ltrErr.Text = "Time Detail Saved..."; } else { this.ltrErr.Text = "Error..."; } } } } catch (Exception exception) { //Exception exception = varVVJ0; Logger.WriteCriticalLog("EmpWiseTimeConfig 307: exception:" + exception.Message + "::::::::" + exception.StackTrace); } }
private void Savedata() { objmysqldb.ConnectToDatabase(); try { objmysqldb.OpenSQlConnection(); objmysqldb.BeginSQLTransaction(); foreach (GridViewRow row in grd.Rows) { int emp_id = 0; string timegrp = ""; int late = 0; int absent = 0; int forgetoutPunch = 0; int Email = 0; int grp_id = 0; Label emp = (Label)row.FindControl("lblEmp_id"); Label grp = (Label)row.FindControl("lblgrp_id"); CheckBox chkleft = (CheckBox)row.FindControl("cbSelectlate"); CheckBox chkabsent = (CheckBox)row.FindControl("cbSelectabsent"); CheckBox chkforgetOut = (CheckBox)row.FindControl("cbSelectOutpunch"); CheckBox chkEmail = (CheckBox)row.FindControl("cbSelectEmail"); HtmlSelect ddlgrp = (HtmlSelect)row.FindControl("ddltime"); if (chkleft.Checked) { late = 1; } if (chkabsent.Checked) { absent = 1; } if (chkforgetOut.Checked) { forgetoutPunch = 1; } if (chkEmail.Checked) { Email = 1; } int.TryParse(emp.Text.ToString(), out emp_id); timegrp = ddlgrp.Value.ToString(); if (!timegrp.Equals("1000")) { int.TryParse(timegrp.ToString(), out grp_id); } DateTime currenttime = Logger.getIndiantimeDT(); if (grp_id > 0) { int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id); int retval = objmysqldb.InsertUpdateDeleteData("update time_group_assign_emplyee_wise set Group_id=" + grp_id + ",OutPuch_SMS=" + forgetoutPunch + ",Absent_Sms=" + absent + ",Late_SMS=" + late + ",Email_Sent=" + Email + ",modify_datetime=" + currenttime.Ticks + ",IsUpdate=1,UserID=" + user_id + " where IsDelete=0 and emp_id=" + emp_id + " "); if (retval == 0) { retval = objmysqldb.InsertUpdateDeleteData("insert into time_group_assign_emplyee_wise (emp_id,Group_id,OutPuch_SMS,Absent_Sms,Late_SMS,Email_Sent,modify_datetime,DOC,IsDelete,IsUpdate,UserID) values (" + emp_id + " ," + grp_id + "," + forgetoutPunch + "," + absent + "," + late + "," + Email + "," + currenttime.Ticks + "," + currenttime.Ticks + ",0,1," + user_id + ")"); if (retval != 1) { ltrErr.Text = "Please Try Again."; Logger.WriteCriticalLog("TimeGroup_AssignToEmployee 345 Update error."); objmysqldb.RollBackSQLTransaction(); return; } } DataTable dtgroup = new DataTable(); dtgroup = objmysqldb.GetData("select * from group_master where Group_id=" + grp_id + ""); DataTable dtgrouptime = new DataTable(); dtgrouptime = objmysqldb.GetData("select * from groupwise_time_config where Group_Time_Id=" + grp_id + ""); if (dtgrouptime != null && dtgrouptime.Rows.Count > 0) { DateTime currenttimes = Logger.getIndiantimeDT(); retval = objmysqldb.InsertUpdateDeleteData("update employeewise_punchtime_details_datewise set IsDelete=1,modify_datetime=" + currenttimes.Ticks + ",IsUpdate=1,UserID=" + user_id + " where emp_id=" + emp_id + ""); long dateticks = 0; long.TryParse(dtgroup.Rows[0]["Changes_Applicable_Date"].ToString(), out dateticks); DateTime dtcur = MySQLDB.GetIndianTime(); DateTime dtcurrent = new DateTime(dtcur.Year, dtcur.Month, dtcur.Day); long curdateticks = 0; long ticks = long.Parse(dtgroup.Rows[0]["Changes_Applicable_Date"].ToString()); DateTime dt = new DateTime(ticks); String myString_new = String.Format("{0:dd/MM/yyyy}", dt); TimeSpan dtDiff = dt - dtcurrent; DateTime dtstartdate = dtcurrent; if (dtDiff.Days < 0) { dtDiff = dtcurrent - dt; dtstartdate = dt; } for (int d1 = 0; d1 <= dtDiff.Days; d1++) { DateTime dtt1 = dtstartdate.AddDays(d1); //foreach (DataRow dr in dtdata.Rows) int days1 = (int)dtt1.DayOfWeek; if (days1 == 0) { days1 = 7; } DataRow[] drdaywise1 = dtgrouptime.Select("Day_id =" + days1 + " "); foreach (DataRow dr in drdaywise1) { retval = objmysqldb.InsertUpdateDeleteData("insert into employeewise_punchtime_details_datewise (Dateticks,emp_id,Day_id,In_hour,In_min,out_hour,out_min,Ext_Early_hour,Ext_Early_min,Ext_Late_hour,Ext_Late_min,modify_datetime,DOC,IsUpdate,UserID,IsDelete) values (" + dtt1.Ticks + "," + emp_id + "," + int.Parse(dr["Day_id"].ToString()) + "," + int.Parse(dr["In_hour"].ToString()) + "," + int.Parse(dr["In_min"].ToString()) + "," + int.Parse(dr["out_hour"].ToString()) + "," + int.Parse(dr["out_min"].ToString()) + "," + int.Parse(dr["Ext_Early_hour"].ToString()) + "," + int.Parse(dr["Ext_Early_min"].ToString()) + "," + int.Parse(dr["Ext_Late_hour"].ToString()) + "," + int.Parse(dr["Ext_Late_min"].ToString()) + "," + currenttimes.Ticks + "," + currenttimes.Ticks + ",1," + user_id + ",0)"); } } } } } objmysqldb.EndSQLTransaction(); Search(); ltrErr.Text = "Time Group Assign Successfully."; } catch (Exception ex) { objmysqldb.RollBackSQLTransaction(); Logger.WriteCriticalLog("Employee_AssignToTimeGroup 360: exception:" + ex.Message + "::::::::" + ex.StackTrace); } finally { objmysqldb.disposeConnectionObj(); objmysqldb.CloseSQlConnection(); } }