protected void btn_Save_Click(object sender, EventArgs e) { try { SMHR_EMPCOMOFF _obj_smhr_compoff = new SMHR_EMPCOMOFF(); _obj_smhr_compoff.EMPCOMPOFF_WORKDAY = Convert.ToDateTime(rdtp_Dateofwork.SelectedDate); _obj_smhr_compoff.EMPCOMPOFF_LOGINTIME = Convert.ToString(Convert.ToDateTime(rtp_LoginTime.SelectedDate).TimeOfDay); _obj_smhr_compoff.EMPCOMPOFF_LOGOUTTIME = Convert.ToString(Convert.ToDateTime(rtp_LogoutTime.SelectedDate).TimeOfDay); if (Convert.ToDateTime(rtp_LoginTime.SelectedDate).TimeOfDay > Convert.ToDateTime(rtp_LogoutTime.SelectedDate).TimeOfDay) { BLL.ShowMessage(this, "Login time should be less than Logout time."); return; } _obj_smhr_compoff.EMPCOMPOFF_EMPID = Convert.ToInt32(rcmb_CmpOffEmployeeID.SelectedItem.Value); _obj_smhr_compoff.EMPCOMPOFF_DAYS = 1;//Convert.ToInt32(rtxt_NDays.Text); //string strTest = rtxt_Reason.Text; //StringBuilder sb = new StringBuilder(); //for (int i = 0; i < strTest.Length; i++) //{ // if (i % 12 == 0) // sb.Append("</br>"); // sb.Append(strTest[i]); //} //string strReason = sb.ToString(); //_obj_smhr_compoff.EMPCOMPOFF_REASON = strReason; _obj_smhr_compoff.EMPCOMPOFF_REASON = Convert.ToString(BLL.ReplaceQuote(rtxt_Reason.Text)); _obj_smhr_compoff.EMPCOMPOFF_APPLIEDDATE = Convert.ToDateTime(rdp_AppDate.SelectedDate); _obj_smhr_compoff.EMPCOMPOFF_STATUS = 0; _obj_smhr_compoff.CREATEDBY = Convert.ToInt32(Session["USER_ID"]); // ### Need to Get the Session _obj_smhr_compoff.CREATEDDATE = DateTime.Now; _obj_smhr_compoff.LASTMDFBY = Convert.ToInt32(Session["USER_ID"]); // ### Need to Get the Session _obj_smhr_compoff.LASTMDFDATE = DateTime.Now; //_obj_smhr_compoff.EMPCOMPOFF_COMPOFFDAY = Convert.ToDateTime(rdtp_compoffday.SelectedDate); //DataTable dt_comp = BLL.CheckCompoffDay(_obj_smhr_compoff); //if (dt_comp.Rows[0]["RESULT"].ToString() == "1") //{ // BLL.ShowMessage(this, "Entered Compoff Day is Not a Working Day"); // return; //} DataTable dt_val = BLL.CheckWorkDay(_obj_smhr_compoff); _obj_smhr_compoff.EMPCOMPOFF_WORKDAY = Convert.ToDateTime(rdtp_Dateofwork.SelectedDate); _obj_smhr_compoff.EMPCOMPOFF_EMPID = Convert.ToInt32(rcmb_CmpOffEmployeeID.SelectedItem.Value); _obj_smhr_compoff.EMPCOMPOFF_LEAVETYPE = Convert.ToInt32(rcmb_Compoff.SelectedItem.Value); //_obj_smhr_compoff.OPERATION = operation.Validate; //if (Convert.ToString(BLL.get_empcompffs(_obj_smhr_compoff).Rows[0]["Count"]) == "1") //{ // BLL.ShowMessage(this, "Compensatory off is already approved for this work day"); // return; //} if (dt_val.Rows[0]["RESULT"].ToString() == "1") { switch (((Button)sender).ID.ToUpper()) { case "BTN_UPDATE": _obj_smhr_compoff.OPERATION = operation.Update; _obj_smhr_compoff.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]); _obj_smhr_compoff.EMPCOMPOFF_ID = Convert.ToInt32(lbl_CmpDetID.Text); BLL.set_empcompoffs(_obj_smhr_compoff); BLL.ShowMessage(this, "Comp Off Request Updated successfully"); break; case "BTN_SAVE": _obj_smhr_compoff.OPERATION = operation.Validate; if (Convert.ToString(BLL.get_empcompffs(_obj_smhr_compoff).Rows[0]["Count"]) == "1") { BLL.ShowMessage(this, "Compensatory off is already approved for this work day"); return; } //_obj_smhr_compoff.OPERATION = operation.Validate1; //if (Convert.ToString(BLL.get_empcompffs(_obj_smhr_compoff).Rows[0]["Count"]) == "1") //{ // BLL.ShowMessage(this, "Compensatory off is already applied for this Compoff day"); // return; //} _obj_smhr_compoff.OPERATION = operation.Insert; _obj_smhr_compoff.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]); BLL.set_empcompoffs(_obj_smhr_compoff); BLL.ShowMessage(this, "Comp Off Request Submitted successfully"); break; default: break; } clearcontrols(); Rm_CMPOFF_page.SelectedIndex = 0; LoadMainGrid(); Rg_CmpOffDet.DataBind(); //clearcontrols(); } else { BLL.ShowMessage(this, "Not a valid day to apply for Compensatory Off"); return; } } catch (Exception ex) { SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_comoffrequest", ex.StackTrace, DateTime.Now); Response.Redirect("~/Frm_ErrorPage.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { try { Page.Validate(); Control = Convert.ToString(Request.QueryString["Control"]); if (!Page.IsPostBack) { Session.Remove("WRITEFACILITY"); SMHR_LOGININFO _obj_Smhr_LoginInfo = new SMHR_LOGININFO(); _obj_Smhr_LoginInfo.OPERATION = operation.Empty1; _obj_Smhr_LoginInfo.LOGIN_USERNAME = Convert.ToString(Session["USERNAME"]).Trim(); _obj_Smhr_LoginInfo.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]); _obj_Smhr_LoginInfo.LOGIN_PASS_CODE = Convert.ToString("COMPENSATORY OFF REQUEST"); if (Control != null) { if (Control.ToUpper() == "SELFCOMP") { _obj_Smhr_LoginInfo.LOGIN_ID = 12; } } else { _obj_Smhr_LoginInfo.LOGIN_ID = 3; } DataTable dtformdtls = BLL.get_LoginInfo(_obj_Smhr_LoginInfo); if (dtformdtls.Rows.Count != 0) { if ((Convert.ToBoolean(dtformdtls.Rows[0]["TYPSEC_READ"]) == true) && (Convert.ToBoolean(dtformdtls.Rows[0]["TYPSEC_WRITE"]) == true)) { Session["WRITEFACILITY"] = 1;//WHICH MEANS READ AND WRITE } else if ((Convert.ToBoolean(dtformdtls.Rows[0]["TYPSEC_READ"]) == true) && (Convert.ToBoolean(dtformdtls.Rows[0]["TYPSEC_WRITE"]) == false)) { Session["WRITEFACILITY"] = 2;//WHICH MEANS READ NO WRITE } else if ((Convert.ToBoolean(dtformdtls.Rows[0]["TYPSEC_READ"]) == false) && (Convert.ToBoolean(dtformdtls.Rows[0]["TYPSEC_WRITE"]) == false)) { Session["WRITEFACILITY"] = 3;//WHICH MEANS NO READ AND NO WRITE } } else { smhr_UNAUTHORIZED _obj_smhr_unauthorized = new smhr_UNAUTHORIZED(); _obj_smhr_unauthorized.UNAUTHORIZED_USERID = Convert.ToInt32(Session["USER_ID"]); _obj_smhr_unauthorized.UNAUTHORIZED_FORMID = Convert.ToInt32(ViewState["FORMS_ID"]); _obj_smhr_unauthorized.UNAUTHORIZED_MODULEID = Convert.ToInt32(ViewState["MODULE_ID"]); _obj_smhr_unauthorized.UNAUTHORIZED_ACCESSDATE = Convert.ToDateTime(DateTime.Now.ToString()); SMHR.BLL.UnAuthorized_Log(_obj_smhr_unauthorized); Response.Redirect("~/frm_UnAuthorized.aspx", false); } if (Convert.ToInt32(Session["WRITEFACILITY"]) == 2) { Rg_CmpOffDet.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None; btn_Save.Visible = false; btn_Update.Visible = false; // added to support Only-View functionality. foreach (GridColumn col in Rg_CmpOffDet.Columns) { if (col.UniqueName == "ColEdit") { col.Visible = false; } } } else if (Convert.ToInt32(Session["WRITEFACILITY"]) == 3) { smhr_UNAUTHORIZED _obj_smhr_unauthorized = new smhr_UNAUTHORIZED(); _obj_smhr_unauthorized.UNAUTHORIZED_USERID = Convert.ToInt32(Session["USER_ID"]); _obj_smhr_unauthorized.UNAUTHORIZED_FORMID = Convert.ToInt32(ViewState["FORMS_ID"]); _obj_smhr_unauthorized.UNAUTHORIZED_MODULEID = Convert.ToInt32(ViewState["MODULE_ID"]); _obj_smhr_unauthorized.UNAUTHORIZED_ACCESSDATE = Convert.ToDateTime(DateTime.Now.ToString()); SMHR.BLL.UnAuthorized_Log(_obj_smhr_unauthorized); Response.Redirect("~/frm_UnAuthorized.aspx", false); } BLL.ChangeDateFormat(Convert.ToString(Session["EMP_ID"]), rdtp_Dateofwork, rdp_AppDate); BLL.gridDateFormat(Convert.ToString(Session["EMP_ID"]), Rg_CmpOffDet, "EMPCOMPOFF_WORKDAY"); loaddropdowns(); //LoadMainGrid(); Rg_CmpOffDet.DataBind(); } } catch (Exception ex) { SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_comoffrequest", ex.StackTrace, DateTime.Now); Response.Redirect("~/Frm_ErrorPage.aspx"); } }