Example #1
0
        protected void btnsaveA4L_Click(object sender, EventArgs e)
        {
            try
            {
                ltrA4L.Text = "";
                ltrLL.Text  = "";
                ltrLP.Text  = "";
                objmysqldb.ConnectToDatabase();
                if (fileA4L.HasFile)
                {
                    string uploadFolderPath = "~/HeaderImages/";
                    string filePath         = HttpContext.Current.Server.MapPath(uploadFolderPath);
                    if (!Directory.Exists(filePath))
                    {
                        Directory.CreateDirectory(filePath);
                    }
                    if (fileA4L.FileName.ToString().ToLower().Equals("HeaderImages.jpg"))
                    {
                    }
                    else
                    {
                        string ext  = System.IO.Path.GetExtension(fileA4L.FileName.ToString());
                        long   mode = Logger.getIndiantimeDT().Ticks;
                        int.TryParse(Request.QueryString["repgrp"].ToString(), out repgrp);
                        string fileName = repgrp.ToString() + "_" + "A4Landscape" + "_" + mode + ext;

                        fileA4L.SaveAs(filePath + "\\" + fileName);
                        string imgPath;
                        imgPath = System.IO.Path.Combine(filePath, fileName);
                        System.Drawing.Image img = System.Drawing.Image.FromFile(imgPath);
                        IMgA4L.ImageUrl = "~/HeaderImages/" + "/" + fileName.ToString();

                        objmysqldb.OpenSQlConnection();
                        objmysqldb.AddCommandParameter("A4L_Img", fileName);
                        int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id);
                        int retval = objmysqldb.InsertUpdateDeleteData("update report_group_list set A4L_Img=?A4L_Img,modify_datetime=" + mode + ",IsUpdate=1,UserID=" + user_id + " where report_grp_id=" + repgrp + " ");
                        if (retval > 0)
                        {
                            ltrA4L.Text = "Header Image Update Successfully";
                        }
                        else
                        {
                            ltrA4L.Text = "Header Image Not Update Successfully";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteCriticalLog("ManageEmployeeGroupReportsHeaderImage 169: exception:" + ex.Message + "::::::::" + ex.StackTrace);
            }
            finally
            {
                objmysqldb.CloseSQlConnection();
                objmysqldb.disposeConnectionObj();
            }
        }
Example #2
0
        protected void btnsave_Click(object sender, EventArgs e)
        {
            ltrErr.Text = "";
            DataTable dtSearch = new DataTable();

            try
            {
                if (!txtdept.Text.ToString().Equals(""))
                {
                    //objmysqldb.ConnectToDatabase();
                    //ConfigurationManager cm=
                    dtSearch = objmysqldb.GetData("Select * from cities WHERE IsDelete=0 and (Department_Name like '" + txtdept.Text.ToString() + "') ");


                    if (dtSearch != null && dtSearch.Rows.Count > 0)
                    {
                        ltrErr.Text = " Department Is Already Exist.";
                        return;
                    }
                    DateTime currenttime = Logger.getIndiantimeDT();
                    int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id);
                    objmysqldb.AddCommandParameter("deptnm", txtdept.Text.ToString());

                    string query = "Insert into   department_master (Department_Name,modify_datetime,DOC,UserID,IsDelete,IsUpdate,IsMasterData) values (?deptnm," + currenttime.Ticks + "," + currenttime.Ticks + "," + user_id + ",0,1,1) ";

                    objmysqldb.OpenSQlConnection();
                    int res = objmysqldb.InsertUpdateDeleteData(query);
                    if (res != 1)
                    {
                        ltrErr.Text = "Please Try Again.";

                        Logger.WriteCriticalLog("Manage_Department 128 Update error.");
                    }
                    else
                    {
                        grd.EditIndex = -1;
                        showgrid();
                        ltrErr.Text  = "Department Save Successfully.";
                        txtdept.Text = "";
                    }
                }
                else
                {
                    ltrErr.Text = "Please Enter All Details.";
                    return;
                }
            }

            catch (Exception ex)
            {
                Logger.WriteCriticalLog("Manage_Department 149: exception:" + ex.Message + "::::::::" + ex.StackTrace);
            }
        }
        protected void btnsave_Click(object sender, EventArgs e)
        {
            try
            {
                ltrErr.Text = "";
                if (!txtdesignames.Text.ToString().Equals(""))
                {
                    objmysqldb.ConnectToDatabase();
                    DataTable dtdesigList = objmysqldb.GetData("select designation_id,Designation_Name from designation_master where Designation_Name like '" + txtdesignames.Text.ToString() + "' and IsDelete=0  ;");

                    if (dtdesigList != null && dtdesigList.Rows.Count > 0)
                    {
                        ltrErr.Text = " Designation Is Already Exist.";
                        return;
                    }

                    DateTime currenttime = Logger.getIndiantimeDT();
                    int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id);
                    objmysqldb.AddCommandParameter("designame", txtdesignames.Text.ToString());
                    string query = "Insert into  designation_master (Designation_Name,DOC,UserID,IsDelete,IsUpdate,modify_datetime,IsMasterData) values (?designame," + currenttime.Ticks + "," + user_id + ",0,1," + currenttime.Ticks + ",1) ";
                    objmysqldb.OpenSQlConnection();
                    int res = objmysqldb.InsertUpdateDeleteData(query);
                    if (res != 1)
                    {
                        ltrErr.Text = "Please Try Again.";
                        Logger.WriteCriticalLog("ManageDesignation 111 Update error.");
                    }
                    else
                    {
                        grd.EditIndex = -1;
                        showgrid();
                        ltrErr.Text        = "Designation Save Successfully.";
                        txtdesignames.Text = "";
                    }
                }
                else
                {
                    ltrErr.Text = "Please Enter All Details.";
                    return;
                }
            }
            catch (Exception ex)
            {
                Logger.WriteCriticalLog("ManageDesignation 128: exception:" + ex.Message + "::::::::" + ex.StackTrace);
            }
            finally
            {
                objmysqldb.CloseSQlConnection();
                objmysqldb.disposeConnectionObj();
            }
        }
        protected void btnsave_Click(object sender, EventArgs e)
        {
            try
            {
                ltrErr.Text = "";
                if (!txtschID.Text.ToString().Equals("") && !txtschnames.Text.ToString().Equals(""))
                {
                    objmysqldb.ConnectToDatabase();
                    DataTable dtschList = objmysqldb.GetData("Select * from school_list WHERE IsDelete=0 and (School_Name like '" + txtschnames.Text.ToString() + "' OR School_Id = " + int.Parse(txtschID.Text.ToString()) + ")  ");
                    if (dtschList != null && dtschList.Rows.Count > 0)
                    {
                        ltrErr.Text = " Organization  Is Already Exist";
                        return;
                    }
                    DateTime currenttime = Logger.getIndiantimeDT();
                    int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id);
                    objmysqldb.AddCommandParameter("schanme", txtschnames.Text.ToString());
                    string query = "Insert into  school_list (School_Name,School_Id,DOC,UserID,IsDelete,IsUpdate,modify_datetime) values (?schanme," + int.Parse(txtschID.Text.ToString()) + "," + currenttime.Ticks + "," + user_id + ",0,1," + currenttime.Ticks + ") ";
                    objmysqldb.OpenSQlConnection();
                    int res = objmysqldb.InsertUpdateDeleteData(query);
                    if (res != 1)
                    {
                        ltrErr.Text = "Please Try Again.";

                        Logger.WriteCriticalLog("Manage_Organization 110 Update error.");
                    }
                    else
                    {
                        grd.EditIndex = -1;
                        showgrid();
                        ltrErr.Text      = "Organization Save Successfully";
                        txtschID.Text    = "";
                        txtschnames.Text = "";
                    }
                }
                else
                {
                    ltrErr.Text = "Please Enter All Details.";
                    return;
                }
            }
            catch (Exception ex)
            {
                Logger.WriteCriticalLog("Manage_Organization 130: exception:" + ex.Message + "::::::::" + ex.StackTrace);
            }
            finally
            {
                objmysqldb.CloseSQlConnection();
                objmysqldb.disposeConnectionObj();
            }
        }
Example #5
0
        protected void btnsave_Click(object sender, EventArgs e)
        {
            try
            {
                ltrErr.Text = "";
                if (!txtcategorynames.Text.ToString().Equals(""))
                {
                    objmysqldb.ConnectToDatabase();
                    DataTable dtcategory = objmysqldb.GetData("Select * from category_master WHERE (category_name like '" + txtcategorynames.Text.ToString() + "') and  IsDelete=0  ");
                    if (dtcategory != null && dtcategory.Rows.Count > 0)
                    {
                        ltrErr.Text = " Category Is Already Exist";
                        return;
                    }
                    DateTime currenttime = Logger.getIndiantimeDT();
                    int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id);
                    objmysqldb.AddCommandParameter("categoryname", txtcategorynames.Text.ToString());
                    string query = "Insert into  category_master (category_name,UserID,modify_datetime,DOC,IsUpdate,IsMasterData,IsDelete) values (?categoryname," + user_id + "," + currenttime.Ticks + "," + currenttime.Ticks + ",1,1,0) ";
                    objmysqldb.OpenSQlConnection();
                    int res = objmysqldb.InsertUpdateDeleteData(query);
                    if (res != 1)
                    {
                        ltrErr.Text = "Please Try Again.";

                        Logger.WriteCriticalLog("Manage_Category 106 Update error.");
                    }
                    else
                    {
                        grd.EditIndex = -1;
                        showgrid();
                        txtcategorynames.Text = "";
                        ltrErr.Text           = "Category Save Successfully.";
                    }
                }
                else
                {
                    ltrErr.Text = "Please Enter All Details.";
                    return;
                }
            }
            catch (Exception ex)
            {
                Logger.WriteCriticalLog("Manage_Category 125: exception:" + ex.Message + "::::::::" + ex.StackTrace);
            }
            finally
            {
                objmysqldb.CloseSQlConnection();
                objmysqldb.disposeConnectionObj();
            }
        }
Example #6
0
        protected void grd_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                ltrErr.Text = "";
                int     masterdata       = 0;
                TextBox txtreligionnames = (TextBox)grd.Rows[e.RowIndex].FindControl("txtreligion_name");

                Label  lbid      = (Label)grd.Rows[e.RowIndex].FindControl("lblreligion_id");
                string relListId = lbid.Text;
                string relName   = txtreligionnames.Text.ToString().Trim();
                int    relid     = 0;
                int.TryParse(relListId, out relid);
                DateTime currenttime = Logger.getIndiantimeDT();
                if (relName != "" && relid > 0)
                {
                    objmysqldb.ConnectToDatabase();
                    DataTable dtreligion = objmysqldb.GetData("Select * from religion_master WHERE IsDelete=0 and religion_name like '" + relName + "' and religion_id<> " + int.Parse(relListId) + "  ");

                    DataTable dtrelDetails = objmysqldb.GetData("Select * from religion_master WHERE religion_id= " + int.Parse(relListId) + "  ");

                    if (dtreligion != null && dtreligion.Rows.Count > 0)
                    {
                        ltrErr.Text = "Same Religion Name Is Already Exist";
                        return;
                    }

                    if (dtrelDetails != null && dtrelDetails.Rows.Count > 0)
                    {
                        int.TryParse(dtrelDetails.Rows[0]["IsMasterData"].ToString(), out masterdata);

                        if (masterdata == 0)
                        {
                            ltrErr.Text = "Select Religion is Masterdata,So can't delete it";
                            return;
                        }
                        else
                        {
                            //int.TryParse(dtcatDetails.Rows[0]["category_id"].ToString(), out oldcatid);
                            objmysqldb.AddCommandParameter("religionname", relName);
                            int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id);
                            string query = "Update religion_master set religion_name=?religionname,modify_datetime=" + currenttime.Ticks + ",IsUpdate=1,UserID=" + user_id + "  where religion_id=" + int.Parse(relListId) + " ";
                            objmysqldb.OpenSQlConnection();
                            int res = objmysqldb.InsertUpdateDeleteData(query);
                            if (res != 1)
                            {
                                ltrErr.Text = "Please Try Again.";

                                Logger.WriteCriticalLog("Manage_Religion 243 Update error.");
                                return;
                            }
                            grd.EditIndex = -1;
                            showgrid();
                            ltrErr.Text = "Religion Name Updated Successfully";
                        }
                    }
                    else
                    {
                        ltrErr.Text = "Please Try Again.";
                        return;
                    }
                }
                else
                {
                    //showgrid();
                    ltrErr.Text = "Please Enter All Details.";
                }

                grd.EditIndex = -1;
            }
            catch (Exception ex)
            {
                ltrErr.Text = "Please Try Again.";
                Logger.WriteCriticalLog("Manage_Religion 272: exception:" + ex.Message + "::::::::" + ex.StackTrace);
            }

            finally
            {
                objmysqldb.CloseSQlConnection();
                objmysqldb.disposeConnectionObj();
            }
        }
Example #7
0
        protected void btnsave_Click(object sender, EventArgs e)
        {
            try
            {
                objmysqldb.ConnectToDatabase();
                if (txtleftDate.Text.ToString().Equals(""))
                {
                    ltrErr.Text = "Please enter left date";
                    return;
                }
                else
                {
                    string[] arrlft = txtleftDate.Text.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                    if (arrlft.Length == 3)
                    {
                        string lftdate = ((arrlft[0]).ToString().Length == 1 ? "0" + (arrlft[0]).ToString() : (arrlft[0]).ToString()) + "/" + ((arrlft[1]).ToString().Length == 1 ? "0" + (arrlft[1]).ToString() : (arrlft[1]).ToString()) + "/" + ((arrlft[2]).ToString());
                        txtleftDate.Text = lftdate;
                    }
                    else
                    {
                        ltrErr.Text = "Left Date is not in proper format.";
                        return;
                    }
                }
                int emp_id = 0;
                int.TryParse(Request.QueryString["Emp"].ToString(), out emp_id);
                int user_ids = 0;
                int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_ids);
                DateTime currenttime = Logger.getIndiantimeDT();
                string   query       = "Update employee_master set EmpStatusFlag=1,modify_datetime=" + currenttime.Ticks + ",IsUpdate=1,UserID=" + user_ids + " where EmpId=" + emp_id + " ";
                objmysqldb.OpenSQlConnection();
                int res = objmysqldb.InsertUpdateDeleteData(query);
                if (res == 1)
                {
                    objmysqldb.AddCommandParameter("Left_Date", txtleftDate.Text.ToString());
                    objmysqldb.AddCommandParameter("Left_Reason", txtreason.Text.ToString());
                    res = objmysqldb.InsertUpdateDeleteData("insert into left_employee (Emp_Id,Left_Date,Left_Reason,UserID,modify_datetime,DOC,IsUpdate,IsDelete) values(" + emp_id + ",?Left_Date,?Left_Reason," + user_ids + " ," + currenttime.Ticks + "," + currenttime.Ticks + ",1,0) ");

                    if (res != 1)
                    {
                        ltrErr.Text = "Please Try Again.";
                        Logger.WriteCriticalLog("LeftEmployee 98 Update error.");
                    }
                    else
                    {
                        ltrErr.Text      = "Status Update Successfully";
                        txtleftDate.Text = "";
                        txtreason.Text   = "";
                    }
                    grd.EditIndex = -1;
                    showgrid();
                }
            }
            catch (Exception ex)
            {
                Logger.WriteCriticalLog("LeftEmployee 113:: exception:" + ex.Message + "::::::::" + ex.StackTrace);
            }
            finally
            {
                objmysqldb.CloseSQlConnection();
                objmysqldb.disposeConnectionObj();
            }
        }
Example #8
0
        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();
            }
        }
Example #9
0
        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();
            }
        }
        protected void btnsave_Click(object sender, EventArgs e)
        {
            try
            {
                query_insert_update();
                objmysqldb.ConnectToDatabase();
                objmysqldb.OpenSQlConnection();
                if (allowinsert)
                {
                    int profileid = 0;
                    int.TryParse(profile_idHidden.Value.ToString(), out profileid);
                    if (txtprofile.Text == "" || txtquery.Text == "")
                    {
                        ltrErr.Text = "Please Enter all Data.";
                    }
                    else
                    {
                        DateTime currenttime = Logger.getIndiantimeDT();
                        int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id);
                        DataTable dtdata = objmysqldb.GetData("Select * from employee_query_profile where Profile_Id=" + profileid +
                                                              "");
                        DataTable dtprofile = objmysqldb.GetData("Select * from employee_query_profile  where Profile_Name='" + txtprofile.Text + "' and Profile_Id<>" + profileid + " and IsDelete=0");
                        if (dtdata != null && dtdata.Rows.Count > 0)
                        {
                            if (dtprofile != null && dtprofile.Rows.Count > 0)
                            {
                                ltrErr.Text = "Profile Name Already Exist.";
                                return;
                            }
                            else
                            {
                                objmysqldb.AddCommandParameter("profile", txtprofile.Text.ToString());
                                objmysqldb.AddCommandParameter("query", txtquery.Text.ToString());
                                string updatequery = "update employee_query_profile set Profile_Name=?profile,Profile_Text=?query,modify_datetime=" + currenttime.Ticks + ",UserID=" + user_id + ",IsDelete=0,IsUpdate=1 where Profile_Id=" + profileid + " ";
                                int    resupdate   = objmysqldb.InsertUpdateDeleteData(updatequery);
                                if (resupdate != 1)
                                {
                                    ltrErr.Text = "Please Try Again.";

                                    Logger.WriteCriticalLog("Add New Query Profile 194 Update error.");
                                }
                                else
                                {
                                    long lastp_id = objmysqldb.LastNo("employee_query_profile", "Profile_Id", currenttime.Ticks);
                                    profile_idHidden.Value = lastp_id.ToString();


                                    btnExport.Visible  = true;
                                    ltrErr.Text        = "Query Profile Updated Successfully";
                                    ViewState["p_id="] = profile_idHidden.Value;
                                    ViewState["msg"]   = ltrErr.Text;
                                }
                            }
                        }
                        else
                        {
                            DataTable dtprofiles = objmysqldb.GetData("Select * from employee_query_profile  where Profile_Name='" + txtprofile.Text + "' and IsDelete=0");
                            if (dtprofiles != null && dtprofiles.Rows.Count > 0)
                            {
                                ltrErr.Text = "Profile Name Already Exist.";
                                return;
                            }
                            else
                            {
                                objmysqldb.AddCommandParameter("profile", txtprofile.Text.ToString());
                                objmysqldb.AddCommandParameter("query", txtquery.Text.ToString());
                                string query = "Insert into employee_query_profile(Profile_Name,Profile_Text,modify_datetime,DOC,UserID,IsDelete,IsUpdate)values(?profile,?query," + currenttime.Ticks + "," + currenttime.Ticks + "," + user_id + ",0,1)";
                                int    res   = objmysqldb.InsertUpdateDeleteData(query);
                                if (res != 1)
                                {
                                    ltrErr.Text = "Please Try Again.";

                                    Logger.WriteCriticalLog("Add New Query Profile 227 Update error.");
                                }
                                else
                                {
                                    long lastp_id = objmysqldb.LastNo("employee_query_profile", "Profile_Id", currenttime.Ticks);
                                    profile_idHidden.Value = lastp_id.ToString();
                                    ltrErr.Text            = "Query Profile Save Successfully";

                                    btnExport.Visible  = true;
                                    ViewState["p_id="] = profile_idHidden.Value;
                                    ViewState["msg"]   = ltrErr.Text;
                                }
                            }
                        }
                    }
                }
                else
                {
                    ltrErr.Text = "Query Not Run Successfully.";
                }
            }
            catch (Exception ex)
            {
                Logger.WriteCriticalLog("Add New Query Profile 251: exception:" + ex.Message + "::::::::" + ex.StackTrace);
            }
            finally
            {
                objmysqldb.CloseSQlConnection();
                objmysqldb.disposeConnectionObj();
            }
        }
        protected void btnsave_Click(object sender, EventArgs e)
        {
            ltrErr.Text = "";
            try
            {
                objmysqldb.ConnectToDatabase();
                int fid        = 0;
                int sortnumber = 0;
                //for (int i = 0; i < grd.Rows.Count; i++)
                //{
                //    DataTable dataTable = (DataTable)grd.DataSource;
                //    foreach (DataRow dr in dataTable.Rows)
                //    {
                //        TextBox txtsno = (TextBox)grd.Rows[i].Cells[1].FindControl("txtsortnumber");
                //        if (dr["SortNumber"].ToString() == txtsno.Text)
                //        {
                //            ltrErr.Text = "Sort Number already exist";
                //            break;
                //        }
                //    }
                //}
                objmysqldb.OpenSQlConnection();
                foreach (GridViewRow row in grd.Rows)
                {
                    CheckBox chk1     = (CheckBox)row.FindControl("cbSelect");
                    TextBox  txtfield = new TextBox();
                    Label    lblfid   = new Label();
                    TextBox  txtsort  = new TextBox();
                    txtfield = (TextBox)row.FindControl("txtDisplay_Name");
                    lblfid   = (Label)row.FindControl("lblEmployee_Field_id");
                    txtsort  = (TextBox)row.FindControl("txtsortnumber");
                    string fieldname = txtfield.Text.ToString().Trim();
                    int.TryParse(txtsort.Text.ToString(), out sortnumber);
                    int.TryParse(lblfid.Text.ToString(), out fid);
                    DateTime  currenttime = Logger.getIndiantimeDT();
                    DataTable dtsort      = objmysqldb.GetData("Select * from employee_search_field_config where SortNumber=" + sortnumber + " and Is_Show=1 and Employee_field_id<>" + fid + "");
                    if (chk1.Checked)
                    {
                        if (fieldname == "")
                        {
                            ltrErr.Text = "Please Enter Field Display Name.";
                            return;
                        }
                        else
                        {
                            if (dtsort.Rows.Count > 0 && dtsort != null)
                            {
                                ltrErr.Text = "Please Enter Different Sort Number";
                                return;
                            }
                            else
                            {
                                //objmysqldb.ConnectToDatabase();
                                objmysqldb.AddCommandParameter("fieldname", fieldname);
                                int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id);
                                string query = "update employee_search_field_config set FieldDisplayName=?fieldname,Is_Show=1,modify_datetime=" + currenttime.Ticks + ",IsUpdate=1,UserID=" + user_id + ", SortNumber=" + sortnumber + " where Employee_Field_id=" + fid + "";

                                int res = objmysqldb.InsertUpdateDeleteData(query);
                                if (res != 1)
                                {
                                    ltrErr.Text = "Please Try Again.";
                                    Logger.WriteCriticalLog("DisplayColumnConfigurationForSearchEmployee 188 Update error.");
                                    return;
                                }
                                else
                                {
                                    grd.EditIndex = -1;
                                    chk1.Checked  = true;
                                    ltrErr.Text   = "Save successfully.";
                                }
                            }
                        }
                    }
                    else
                    {
                        if (fieldname == "")
                        {
                            ltrErr.Text = "Please Enter Field Display Name.";
                            return;
                        }
                        else
                        {
                            // objmysqldb.ConnectToDatabase();
                            objmysqldb.AddCommandParameter("fieldname", fieldname);
                            int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id);
                            string query = "update employee_search_field_config set FieldDisplayName=?fieldname,Is_Show=0,modify_datetime=" + currenttime.Ticks + ",IsUpdate=1,UserID=" + user_id + " ,SortNumber=" + sortnumber + " where Employee_Field_id=" + fid + "";
                            int    res   = objmysqldb.InsertUpdateDeleteData(query);
                            if (res != 1)
                            {
                                ltrErr.Text = "Please Try Again.";
                                Logger.WriteCriticalLog("DisplayColumnConfigurationForSearchEmployee 218 Update error.");
                                return;
                            }
                            else
                            {
                                grd.EditIndex = -1;
                                chk1.Checked  = false;
                                ltrErr.Text   = "Save successfully.";
                            }
                        }
                    }
                }
                showgrid();
            }
            catch (Exception ex)
            {
                Logger.WriteCriticalLog("DisplayColumnConfigurationForSearchEmployee 234: exception:" + ex.Message + "::::::::" + ex.StackTrace);
            }
            finally
            {
                objmysqldb.CloseSQlConnection();
                objmysqldb.disposeConnectionObj();
            }
        }
        private void savedata()
        {
            objmysqldb.ConnectToDatabase();
            try
            {
                ltrErr.Text = "";
                int rep_grp = 0;
                int.TryParse(report_grp.Value.ToString(), out rep_grp);
                if (txtgroup.Text.Equals(""))
                {
                    ltrErr.Text = "Please enter Report Group Name";
                    return;
                }
                DataTable dtprevData = objmysqldb.GetData("select report_grp_id from report_group_list where IsDelete=0 and report_grp_name = '" + txtgroup.Text.ToString() + "' ");
                //if (dtprevData != null && dtprevData.Rows.Count > 0)
                //{
                //    ltrErr.Text = "Report Group Name Is Already Exsits";
                //    return;
                //}
                string emp_ids = "";
                foreach (GridViewRow row in GridView1.Rows)
                {
                    CheckBox chkshow = (CheckBox)row.FindControl("cbSelect");
                    if (chkshow.Checked)
                    {
                        int   emp_id = 0;
                        Label emp    = (Label)row.FindControl("lblemp_id");
                        int.TryParse(emp.Text.ToString(), out emp_id);
                        emp_ids += emp_id + ",";
                    }
                }
                if (emp_ids.Equals(""))
                {
                    ltrErr.Text = "Please select atleast one emoloyee";
                    return;
                }
                else
                {
                    emp_ids = emp_ids.TrimEnd(',');
                    DateTime currentTime = Logger.getIndiantimeDT();
                    int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id);
                    objmysqldb.OpenSQlConnection();
                    objmysqldb.AddCommandParameter("report_grp_name", txtgroup.Text.ToString());
                    int retval = objmysqldb.InsertUpdateDeleteData("update report_group_list set modify_datetime=" + currentTime.Ticks + ",IsDelete=0,IsUpdate=1,UserID=" + user_id + ",emp_ids='" + emp_ids + "',Is_Default=0,report_grp_name=?report_grp_name where report_grp_id=" + rep_grp + "  ");

                    if (retval == 0)
                    {
                        long mode = Logger.getIndiantimeDT().Ticks;
                        objmysqldb.AddCommandParameter("report_grp_name", txtgroup.Text.ToString());
                        if (dtprevData != null && dtprevData.Rows.Count > 0)
                        {
                            ltrErr.Text = "Report Group Name Is Already Exsits";
                            return;
                        }
                        retval = objmysqldb.InsertUpdateDeleteData("insert into report_group_list (emp_ids,modify_datetime,DOC,IsDelete,IsUpdate,UserID,report_grp_name,Is_Default) values ('" + emp_ids + "'," + mode + "," + currentTime.Ticks + ",0,1," + user_id + ",?report_grp_name,0) ");

                        if (retval != 1)
                        {
                            ltrErr.Text = "please try again";

                            Logger.WriteCriticalLog("ManageEmployeeGroupReports 204 Update error.");
                            return;
                        }
                        rep_grp = int.Parse(objmysqldb.LastNo("report_group_list", "report_grp_id", mode).ToString());
                        if (rep_grp == 1)
                        {
                            objmysqldb.InsertUpdateDeleteData("update report_group_list set Is_Default=1 where report_grp_id=" + rep_grp + "  ");
                        }
                    }
                    if (chkIsDefault.Checked)
                    {
                        objmysqldb.InsertUpdateDeleteData("update report_group_list set modify_datetime=" + currentTime.Ticks + ",IsDelete=0,IsUpdate=1,UserID=" + user_id + ",Is_Default=0  ");
                        objmysqldb.InsertUpdateDeleteData("update report_group_list set Is_Default=1 where report_grp_id=" + rep_grp + " ");
                    }
                }

                int flg = 0;
                if (chkleft.Checked)
                {
                    flg = 1;
                }
                bindgvdata(rep_grp, flg);
                ltrErr.Text = "Report group Assign to employee Successfully.";
            }
            catch (Exception ex)
            {
                Logger.WriteCriticalLog("ManageEmployeeGroupReports 243: exception:" + ex.Message + "::::::::" + ex.StackTrace);
            }
            finally
            {
                objmysqldb.CloseSQlConnection();
                objmysqldb.disposeConnectionObj();
            }
        }
        protected void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                int i = 0;
                ltrErr.Text = "";
                int grpid = 0;
                objmysqldb.ConnectToDatabase();
                objmysqldb.OpenSQlConnection();
                int.TryParse(grp_idHidden.Value.ToString(), out grpid);
                DataTable dt      = objmysqldb.GetData("Select * from employee_app_module_group where module_group_id=" + grpid + " ");
                DataTable dtgname = objmysqldb.GetData("Select * from employee_app_module_group where module_group_name='" + txtgroup.Text + "' and module_group_id <> " + grpid + " and IsDelete=0");
                if (dt != null && dt.Rows.Count > 0)
                {
                    upadteGeneralDetails();
                    return;
                }
                else
                {
                    dt1.Columns.Add("module_id", typeof(Int32));
                    dt1.Columns.Add("module_name");
                    dt1.Columns.Add("SortNumber", typeof(Int32));
                    string mname = "";
                    string gid   = "";
                    string sno   = "";
                    foreach (GridViewRow row in GridView1.Rows)
                    {
                        CheckBox chk1     = (CheckBox)row.FindControl("cbSelect");
                        Label    lblmid   = new Label();
                        Label    lblmname = new Label();
                        TextBox  txtsort  = new TextBox();
                        lblmid   = (Label)row.FindControl("lblModule_id");
                        lblmname = (Label)row.FindControl("lblmoduledName");
                        txtsort  = (TextBox)row.FindControl("txtsortnumber");
                        string a = txtsort.Text.ToString().Trim();
                        if (chk1.Checked)
                        {
                            gid   = lblmid.Text;
                            sno   = txtsort.Text;
                            mname = lblmname.Text;
                            dt1.Rows.Add();
                            dt1.Rows[i]["module_id"]   = int.Parse(gid);
                            dt1.Rows[i]["module_name"] = mname;

                            int sort = 0;
                            int.TryParse(sno.ToString(), out sort);
                            dt1.Rows[i]["SortNumber"] = sort;
                            if (sno.Equals(""))
                            {
                                dt1.Rows[i]["SortNumber"] = 1000;
                            }
                            i++;
                        }
                    }
                    DataView dv = dt1.DefaultView;
                    dv.Sort = "SortNumber,module_id";
                    dt1     = dv.ToTable();
                    int.TryParse(Request.Cookies["LoginCookies"]["UserId"].ToString(), out user_id);
                    objmysqldb.AddCommandParameter("module_group_name", txtgroup.Text.ToString());
                    string id = "";
                    for (int b = 0; b < dt1.Rows.Count; b++)
                    {
                        id += dt1.Rows[b]["module_id"].ToString() + ",";
                    }
                    DateTime currenttime = Logger.getIndiantimeDT();
                    if (txtgroup.Text == "")
                    {
                        ltrErr.Text = "Please Fill all Details.";
                    }
                    else
                    {
                        if (dtgname.Rows.Count > 0 && dtgname != null)
                        {
                            ltrErr.Text = "Same Group Name Is Already Exist";
                        }
                        else
                        {
                            string query = "Insert into  employee_app_module_group(module_group_name,module_ids,modify_datetime,DOC,IsDelete,IsUpdate,UserID) values (?module_group_name,'" + id.TrimEnd(',') + "'," + currenttime.Ticks + "," + currenttime.Ticks + ",0,1,1)";
                            int    res   = objmysqldb.InsertUpdateDeleteData(query);
                            if (res != 1)
                            {
                                ltrErr.Text = "Please Try Again.";

                                Logger.WriteCriticalLog("employee_module_group 290 Update error.");
                            }
                            else
                            {
                                txtgroup.Text = "";
                                showgrid();
                                Search();
                                ltrErr.Text = "Group Save Successfully.";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteCriticalLog("Employee_Module_Group 307: exception:" + ex.Message + "::::::::" + ex.StackTrace);
            }
            finally
            {
                objmysqldb.CloseSQlConnection();
                objmysqldb.disposeConnectionObj();
            }
        }