Ejemplo n.º 1
0
 private void LoadData1()
 {
     try
     {
         SMHR_LOANREQUEST _obj_smhr_empcompoff = new SMHR_LOANREQUEST();
         _obj_smhr_empcompoff.OPERATION = operation.Select3;
         Rg_Mamager.DataSource          = BLL.get_Error_Log(_obj_smhr_empcompoff);
         Rg_Mamager.DataBind();
     }
     catch (System.Exception ex)
     {
         SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "Error_Log", ex.StackTrace, DateTime.Now);
         Response.Redirect("~/Frm_ErrorPage.aspx");
     }
 }
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        try
        {
            CheckBox chk_box1 = new CheckBox();

            int j = 0;

            for (int i = 0; i < Rg_Mamager.Items.Count; i++)
            {
                chk_box1 = Rg_Mamager.Items[i].FindControl("chk_Select") as CheckBox;

                if (chk_box1.Checked)
                {
                    j = j + 1;
                }
            }
            SMHR_LOANREQUEST _obj_Smhr_Loan = new SMHR_LOANREQUEST();
            _obj_Smhr_Loan.OPERATION = operation.Update;
            Label            lbl_approveid          = new Label();
            Label            lbl_sanctionid         = new Label();
            SMHR_LOANREQUEST _obj_Smhr_BusinessUnit = new SMHR_LOANREQUEST();
            _obj_Smhr_BusinessUnit.OPERATION = operation.New;
            //as we are getting the status of the loans by passing loanstatus id but not checking corresponding with organisation
            _obj_Smhr_BusinessUnit.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
            DataTable dt_status = BLL.get_EmployeeStatus(_obj_Smhr_BusinessUnit);
            if (dt_status.Rows.Count > 0)
            {
                for (int i = 0; i < dt_status.Rows.Count; i++)
                {
                    if (Convert.ToString(dt_status.Rows[i]["hr_master_desc"]).Trim() == "Approved")
                    {
                        lbl_approveid.Text = Convert.ToString(dt_status.Rows[i]["hr_master_id"]);
                    }
                    else
                    {
                        lbl_sanctionid.Text = Convert.ToString(dt_status.Rows[i]["hr_master_id"]);
                    }
                }
            }
            RadComboBox   lblCode  = new RadComboBox();
            Label         lblid    = new Label();
            Label         date     = new Label();
            CheckBox      chk_Open = new CheckBox();
            RadDatePicker lblMode  = new RadDatePicker();
            int           count    = 0;
            for (int i = 0; i < Rg_Mamager.Items.Count; i++)
            {
                chk_Open = Rg_Mamager.Items[i].FindControl("chk_Select") as CheckBox;
                if (chk_Open.Checked == true)
                {
                    count++;
                }
            }
            if (count == 0)
            {
                BLL.ShowMessage(this, "Please Select atleast one Employee");
                return;
            }
            for (int i = 0; i < Rg_Mamager.Items.Count; i++)
            {
                lblid    = Rg_Mamager.Items[i].FindControl("Label1") as Label;
                lblCode  = Rg_Mamager.Items[i].FindControl("rcmb_Status") as RadComboBox;
                lblMode  = Rg_Mamager.Items[i].FindControl("lbl_DPname") as RadDatePicker;
                chk_Open = Rg_Mamager.Items[i].FindControl("chk_Select") as CheckBox;
                if (chk_Open.Checked == true)
                {
                    date.Text = DateTime.Now.ToShortDateString();
                    _obj_Smhr_Loan.APPROVEDDATE        = DateTime.Now;
                    _obj_Smhr_Loan.APPROVEDBY          = Convert.ToInt32(Session["EMP_ID"]);
                    _obj_Smhr_Loan.SMHR_LOANREQUEST_ID = Convert.ToInt32(lblid.Text);
                    //if (lblCode.Text == "Approved")
                    //{
                    //    _obj_Smhr_Loan.STATUS = "B";
                    //}
                    //else if (lblCode.Text == "Declined")
                    //{
                    //    _obj_Smhr_Loan.STATUS = "D";
                    //}
                    _obj_Smhr_Loan.LOANNAME    = Convert.ToString(Rg_Mamager.Items[i].Cells[7].Text).Replace("'", "''");
                    _obj_Smhr_Loan.STATUS      = Convert.ToInt32(lblCode.SelectedItem.Value);
                    _obj_Smhr_Loan.LEVEL1      = Convert.ToInt32(lblCode.SelectedItem.Value);
                    _obj_Smhr_Loan.LASTMDFBY   = Convert.ToInt32(Session["USER_ID"]);
                    _obj_Smhr_Loan.LASTMDFDATE = DateTime.Now;
                    if (Convert.ToInt32(lbl_approveid.Text) == Convert.ToInt32(lblCode.SelectedItem.Value))
                    {
                        _obj_Smhr_Loan.OPERATION = operation.Update;
                    }
                    else
                    {
                        _obj_Smhr_Loan.OPERATION = operation.Update1;
                    }
                    if (BLL.set_LoanRequest(_obj_Smhr_Loan))
                    {
                        s = "yes";
                    }
                    else
                    {
                        s = "no";
                    }
                }
                //else
                //{
                //    //BLL.ShowMessage(this, "Please select Choose Option");
                //    //return;
                //    s = "no";
                //}
            }
            if (s == "yes")
            {
                BLL.ShowMessage(this, "Information Saved Sucessfully.");
                LoadData();
                Rg_Mamager.DataBind();
            }
            else
            {
                BLL.ShowMessage(this, "Error Occured While Saving Information.");
                return;
            }
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "LoanManagerApproval", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }