コード例 #1
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                string OCODE = Convert.ToString(((SessionUser)Session["SessionUser"]).OCode);

                HRM_OfficialDay OfficialDayObj = new HRM_OfficialDay();
                OfficialDayObj.Official_Date = Convert.ToDateTime(txtAttDate.Text);
                OfficialDayObj.Working_Day   = ddlWorkingDay.Text;
                OfficialDayObj.OT_Applicable = Convert.ToBoolean(ddlOTAppliocable.SelectedValue);
                OfficialDayObj.Edit_User     = ((SessionUser)Session["SessionUser"]).UserId;
                OfficialDayObj.Edit_Date     = DateTime.Now;
                OfficialDayObj.OCode         = OCODE;

                var result = objAtt_BLL.GetAllOfficeDay(OCODE, Convert.ToDateTime(txtAttDate.Text));
                if (result.Count > 0)
                {
                    objAtt_BLL.UpdateOffialType(OfficialDayObj, Convert.ToDateTime(txtAttDate.Text));  //update working day
                }
                else
                {
                    objAtt_BLL.InsertOffialType(OfficialDayObj);
                }

                HRM_ATTENDANCE attendanceDay = new HRM_ATTENDANCE();
                attendanceDay.Working_Day = ddlWorkingDay.Text;

                var result1 = objAtt_BLL.UpdateAtt_WorkingDay(OCODE, txtAttDate.Text, ddlWorkingDay.Text);
                if (result1 == 1)
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Updated Successfully')", true);
                    //lblMessage.Text = "Data Update successfully!";
                    //lblMessage.ForeColor = System.Drawing.Color.Green;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Updating Error!')", true);
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }