Ejemplo n.º 1
0
        public static string[] GetAllEmployeeNameForReport(string prefixText, int TrustMID, int SchoolMID)
        {
            UserTemplateTBl   objEmployeeMbl = new UserTemplateTBl();
            ApplicationResult objResult      = new ApplicationResult();
            string            strSearchText  = prefixText + "%";
            List <string>     result         = new List <string>();

            objResult = objEmployeeMbl.Employee_Select_AutocomleteForPayroll(strSearchText, TrustMID, SchoolMID);
            if (objResult != null)
            {
                for (int i = 0; i < objResult.resultDT.Rows.Count; i++)
                {
                    string strEmployeeCodeName = objResult.resultDT.Rows[i]["EmployeeName"].ToString();
                    string strEmployeeMID      = objResult.resultDT.Rows[i][EmployeeMBO.EMPLOYEEM_EMPLOYEEMID].ToString();
                    result.Add(string.Format("{0}~{1}", strEmployeeCodeName, strEmployeeMID));
                }
            }
            return(result.ToArray());
        }
Ejemplo n.º 2
0
        protected void btnApplyTemplate_Click(object sender, EventArgs e)
        {
            if (Page.IsValid == true)
            {
                double BasicAmt = 0;
                double Earnings = 0;
                double DA       = 0;


                //if (txtGross.Text == "")
                //{
                //    lblMsg.Text = "Please Enter the Gross Amount";
                //    lblMsg.Visible = true;
                //}
                UserTemplateTBl   objUserTemplateBl = new UserTemplateTBl();
                UserTemplateTBo   objUTemplateBo    = new UserTemplateTBo();
                ApplicationResult objResult         = new ApplicationResult();
                Controls          objControls       = new Controls();
                try
                {
                    objUTemplateBo.UserID             = Convert.ToInt32(Convert.ToInt32(ViewState["EmployeeMID"].ToString()));
                    objUTemplateBo.TrustMID           = Convert.ToInt32(Session[ApplicationSession.TRUSTID]);
                    objUTemplateBo.SchoolMID          = Convert.ToInt32(Convert.ToInt32(ViewState["SchoolMID"].ToString()));
                    objUTemplateBo.TrustTemplateID    = Convert.ToInt32(ddlTemplate.SelectedValue.ToString());
                    objUTemplateBo.Annual             = 0; // Convert.ToDouble(txtAnnual.Text.Trim());
                    objUTemplateBo.Monthly            = 0; // Convert.ToDouble(txtMonthly.Text.Trim());
                    objUTemplateBo.Gross              = Convert.ToDouble(txtGross.Text.ToString());
                    objUTemplateBo.LastModifiedDate   = DateTime.UtcNow.AddHours(5.5).ToString();
                    objUTemplateBo.LastModifiedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]);
                    objUTemplateBo.CreatedDate        = DateTime.UtcNow.AddHours(5.5).ToString();
                    objUTemplateBo.CreatedUserID      = Convert.ToInt32(Session[ApplicationSession.USERID]);
                    objResult = objUserTemplateBl.UserTemplateT_Insert(objUTemplateBo);

                    int i;
                    ViewState["UserTemplateID"] = objResult.resultDT.Rows[0][0].ToString();
                    UserPayItemTemplateTBl objUserPayItemTemplateBl  = new UserPayItemTemplateTBl();
                    UserPayItemTemplateTBo objUserPayItemTemplateTBo = new UserPayItemTemplateTBo();

                    for (i = 0; i < gvPayItem.Rows.Count; ++i)
                    {
                        objUserPayItemTemplateTBo.UserTemplateID = Convert.ToInt32(ViewState["UserTemplateID"].ToString());
                        objUserPayItemTemplateTBo.PayItem        = Convert.ToInt32(gvPayItem.Rows[i].Cells[0].Text);
                        objUserPayItemTemplateTBo.Type           = gvPayItem.Rows[i].Cells[2].Text;
                        if (gvPayItem.Rows[i].Cells[5].Text == "&nbsp;")
                        {
                            objUserPayItemTemplateTBo.Percentage = 0;
                        }
                        else
                        {
                            objUserPayItemTemplateTBo.Percentage = Convert.ToDouble(gvPayItem.Rows[i].Cells[5].Text);
                        }
                        //objUserPayItemTemplateTBo.Percentage = Convert.ToDouble(gvPayItem.Rows[i].Cells[5].Text);
                        objUserPayItemTemplateTBo.TrustMID  = Convert.ToInt32(Session[ApplicationSession.TRUSTID]);
                        objUserPayItemTemplateTBo.SchoolMID = Convert.ToInt32(Convert.ToInt32(ViewState["SchoolMID"].ToString()));
                        if (gvPayItem.Rows[i].Cells[2].Text == "&nbsp;")
                        {
                            gvPayItem.Rows[i].Cells[2].Text     = "";
                            objUserPayItemTemplateTBo.DependsOn = gvPayItem.Rows[i].Cells[3].Text.ToString();
                        }
                        else
                        {
                            objUserPayItemTemplateTBo.DependsOn = gvPayItem.Rows[i].Cells[3].Text.ToString();
                        }

                        #region Riken changes
                        String   str;
                        String[] strPatItem;
                        if (gvPayItem.Rows[i].Cells[2].Text.ToString() == "Independent")
                        {
                            objUserPayItemTemplateTBo.Amount = Convert.ToDouble(gvPayItem.Rows[i].Cells[6].Text);
                        }
                        if (gvPayItem.Rows[i].Cells[2].Text.ToString() == "Depends On Gross")
                        {
                            BasicAmt = Convert.ToDouble(txtGross.Text) * Convert.ToDouble(gvPayItem.Rows[i].Cells[5].Text.ToString()) / 100;
                            BasicAmt = Math.Round(BasicAmt);
                            objUserPayItemTemplateTBo.Amount = BasicAmt;
                            gvPayItem.Rows[i].Cells[6].Text  = BasicAmt.ToString();
                        }
                        if (gvPayItem.Rows[i].Cells[2].Text.ToString() == "Dependent")
                        {
                            Double SumAmount = 0;
                            Double amt       = 0;
                            str        = gvPayItem.Rows[i].Cells[4].Text.ToString();
                            strPatItem = str.Split(',');
                            // for (int j = 0; j < strPatItem.Length; j++)
                            for (int j = 0; j < gvPayItem.Rows.Count; j++)
                            {
                                for (int k = 0; k < strPatItem.Length; k++)
                                {
                                    if (strPatItem[k] == gvPayItem.Rows[j].Cells[1].Text.ToString())
                                    {
                                        SumAmount = SumAmount + Convert.ToDouble(gvPayItem.Rows[j].Cells[6].Text.ToString());
                                    }
                                }
                            }
                            amt = SumAmount * Convert.ToDouble(gvPayItem.Rows[i].Cells[5].Text.ToString()) / 100;
                            amt = Math.Round(amt);
                            objUserPayItemTemplateTBo.Amount = amt;
                            gvPayItem.Rows[i].Cells[6].Text  = amt.ToString();
                        }
                        #endregion
                        objUserPayItemTemplateTBo.LastModifiedDate   = DateTime.UtcNow.AddHours(5.5).ToString();
                        objUserPayItemTemplateTBo.LastModifiedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]);
                        objUserPayItemTemplateTBo.CreatedDate        = DateTime.UtcNow.AddHours(5.5).ToString();
                        objUserPayItemTemplateTBo.CreatedUserID      = Convert.ToInt32(Session[ApplicationSession.USERID]);
                        //}
                        //objUserPayItemTemplateBO.Amount = Convert.ToDouble(gdPayItem.Rows[i].Cells[6].Text);
                        objResult = objUserPayItemTemplateBl.UserPayItemTemplateT_Insert(objUserPayItemTemplateTBo);

                        // intResult = objUserPayItemTemplateBA.UserPayItemTemplate_Insert(objUserPayItemTemplateBO);
                    }

                    foreach (GridViewRow rowItem in gvPayItem.Rows)
                    {
                        if (rowItem.Cells[1].Text == "SA")
                        {
                            objResult = objUserTemplateBl.EmployeeTemplate_SelectForZero(Convert.ToInt32(ViewState["EmployeeMID"].ToString()), Convert.ToInt32(Session[ApplicationSession.TRUSTID]), Convert.ToInt32(Session[ApplicationSession.SCHOOLID]));

                            for (int a = 0; a < objResult.resultDT.Rows.Count; a++)
                            {
                                Earnings = Earnings + (Convert.ToDouble(objResult.resultDT.Rows[a]["Amount"].ToString()));
                            }
                            objUserPayItemTemplateTBo.UserTemplateID = Convert.ToInt32(ViewState["UserTemplateID"].ToString());
                            objUserPayItemTemplateTBo.PayItem        = 5;
                            objUserPayItemTemplateTBo.Type           = "1";
                            objUserPayItemTemplateTBo.DependsOn      = "0";
                            objUserPayItemTemplateTBo.Percentage     = 0;
                            objUserPayItemTemplateTBo.Amount         = Math.Round(Convert.ToDouble(txtGross.Text.ToString()) - Earnings, 2);
                            objResult = objUserPayItemTemplateBl.UserPayItemTemplateT_Insert(objUserPayItemTemplateTBo);
                            break;
                        }
                    }
                    if (objResult.status == ApplicationResult.CommonStatusType.SUCCESS)
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Record Inserted Successfully');</script>");

                        objResult = objUserTemplateBl.Employee_Select_ForPayItemTemplate(Convert.ToInt32(ViewState["EmployeeMID"].ToString()), Convert.ToInt32(Session[ApplicationSession.TRUSTID]), Convert.ToInt32(Session[ApplicationSession.SCHOOLID]));
                        if (objResult != null)
                        {
                            if (objResult.resultDT.Rows.Count > 0)
                            {
                                gvSelectedPayItem.Visible = true;
                                objResult = objUserPayItemTemplateBl.Employee_Select_ByEmployeeID(Convert.ToInt32(ViewState["EmployeeMID"].ToString()), Convert.ToInt32(Session[ApplicationSession.TRUSTID]), Convert.ToInt32(Session[ApplicationSession.SCHOOLID]));
                                gvSelectedPayItem.DataSource = objResult.resultDT;
                                gvSelectedPayItem.DataBind();
                                for (int j = 0; j < gvSelectedPayItem.Rows.Count; ++j)
                                {
                                    sum = sum + Math.Round(Convert.ToDouble(gvSelectedPayItem.Rows[j].Cells[7].Text), 2);
                                }
                                txtMonthly.Text = Convert.ToString(Math.Round(Convert.ToDouble(objControls.ConvertToCurrancy(sum.ToString())), 2));
                                txtAnnual.Text  = Convert.ToString(Math.Round(Convert.ToDouble(objControls.ConvertToCurrancy((12 * sum).ToString())), 2));
                                GridConvertion();

                                PanelVisibility(false, true, true, false);
                                btnApplyTemplate.Visible = false;
                                txtMonthly.Enabled       = false;
                                txtAnnual.Enabled        = false;
                                txtGross.Enabled         = false;
                                ddlTemplate.Enabled      = false;
                            }
                            else
                            {
                                PanelVisibility(true, false, false, true);
                                objControls.EnableControls(Master.FindControl("ContentPlaceHolder1"));
                                ddlDependsOn.Enabled = false;
                                ddlDependsOn.Items.Clear();
                                ddlDependsOn.BackColor   = System.Drawing.Color.Gainsboro;
                                ddlPayItemType.Enabled   = false;
                                ddlPayItemType.BackColor = System.Drawing.Color.Gainsboro;
                                txtAmount.Enabled        = false;
                                txtAmount.BackColor      = System.Drawing.Color.Gainsboro;
                                //txtPayItemName.Enabled = false;
                                //txtPayItemName.BackColor = System.Drawing.Color.Gainsboro;
                                txtPercentage.Enabled   = false;
                                txtPercentage.BackColor = System.Drawing.Color.Gainsboro;
                                // btnApplyOrganisationTemplate.Enabled = true;
                                txtAnnual.Enabled    = false;
                                txtAnnual.BackColor  = System.Drawing.Color.Gainsboro;
                                txtMonthly.Enabled   = false;
                                txtMonthly.BackColor = System.Drawing.Color.Gainsboro;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Ejemplo n.º 3
0
        protected void gvEmployee_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                UserTemplateTBl        objUserTemplateBL = new UserTemplateTBl();
                UserPayItemTemplateTBl objUserPayItemBl  = new UserPayItemTemplateTBl();
                ApplicationResult      objResult         = new ApplicationResult();
                Controls objControls = new Controls();
                string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ',' });
                ViewState["EmployeeMID"] = commandArgs[0];
                ViewState["SchoolMID"]   = commandArgs[1];
                if (e.CommandName.ToString() == "Edit1")
                {
                    objResult = objUserTemplateBL.Employee_Select_ForPayItemTemplate(Convert.ToInt32(ViewState["EmployeeMID"].ToString()), Convert.ToInt32(Session[ApplicationSession.TRUSTID]), Convert.ToInt32(Session[ApplicationSession.SCHOOLID]));
                    if (objResult != null)
                    {
                        PanelVisibility(false, false, true, false);
                        if (objResult.resultDT.Rows.Count > 0)
                        {
                            ViewState["Gross"] = Convert.ToInt32(objResult.resultDT.Rows[0]["Gross"].ToString());

                            objResult = objUserPayItemBl.Employee_Select_ByEmployeeID(Convert.ToInt32(ViewState["EmployeeMID"].ToString()), Convert.ToInt32(Session[ApplicationSession.TRUSTID]), Convert.ToInt32(Session[ApplicationSession.SCHOOLID]));
                            if (objResult != null)
                            {
                                if (objResult.resultDT.Rows.Count > 0)
                                {
                                    PanelVisibility(false, true, true, false);
                                    btnApplyTemplate.Visible     = false;
                                    ddlTemplate.Enabled          = false;
                                    txtAnnual.Enabled            = false;
                                    txtMonthly.Enabled           = false;
                                    txtGross.Enabled             = false;
                                    gvSelectedPayItem.DataSource = objResult.resultDT;
                                    gvSelectedPayItem.DataBind();

                                    gvSelectedPayItem.Visible = true;
                                    for (int i = 0; i < gvSelectedPayItem.Rows.Count; ++i)
                                    {
                                        sum = sum + Convert.ToDouble(gvSelectedPayItem.Rows[i].Cells[7].Text);
                                    }
                                    txtMonthly.Text = Convert.ToString(Math.Round(Convert.ToDouble(objControls.ConvertToCurrancy(sum.ToString())), 2));
                                    txtAnnual.Text  = Convert.ToString(Math.Round(Convert.ToDouble(objControls.ConvertToCurrancy((12 * sum).ToString())), 2));
                                    txtGross.Text   = Convert.ToString(ViewState["Gross"].ToString());
                                    objResult       = objUserPayItemBl.EmployeeTemplate_Select_ByEmployeeID(Convert.ToInt32(ViewState["EmployeeMID"].ToString()), Convert.ToInt32(Session[ApplicationSession.TRUSTID]), Convert.ToInt32(Session[ApplicationSession.SCHOOLID]));
                                    if (objResult != null)
                                    {
                                        if (objResult.resultDT.Rows.Count > 0)
                                        {
                                            ddlTemplate.SelectedValue = objResult.resultDT.Rows[0]["TrustTemplateID"].ToString();
                                        }
                                    }
                                }
                            }

                            GridConvertion();
                        }
                        else
                        {
                            ViewState["Gross"] = txtGross.Text;
                            PanelVisibility(false, false, true, false);
                            ddlTemplate.Enabled       = true;
                            txtAnnual.Enabled         = true;
                            txtMonthly.Enabled        = true;
                            txtGross.Enabled          = true;
                            btnApplyTemplate.Visible  = true;
                            ddlTemplate.SelectedIndex = -1;
                            txtGross.Text             = "";
                            txtMonthly.Text           = "";
                            txtAnnual.Text            = "";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error", ex);
                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>");
            }
        }