private void BindListbox()
        {
            TrustPayItemTemplateTBl objTrustPayItemTemplateBl = new TrustPayItemTemplateTBl();
            ApplicationResult       objResults = new ApplicationResult();
            Controls objControls = new Controls();

            objResults = objTrustPayItemTemplateBl.TrustPayItemTemplate_Select_PayItemWise(Convert.ToInt32(ddlSelectTemplateName.SelectedValue));
            if (objResults != null)
            {
                if (objResults.resultDT.Rows.Count > 0)
                {
                    objControls.BindDropDown_ListBox(objResults.resultDT, lbDependsOn, "Name", "PayItemMID");
                    //lbDependsOn.Items.Insert(0, new ListItem("-Select-", "-1"));
                }
            }
        }
        protected void gvPayTemplate_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            TrustPayItemTemplateTBl objTrustPayItemTemplateBl = new TrustPayItemTemplateTBl();
            ApplicationResult       objResultsEdit            = new ApplicationResult();

            try
            {
                ViewState["TrustTemplateID"] = Convert.ToInt32(e.CommandArgument.ToString());
                GridViewRow gvr      = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                int         rowIndex = gvr.RowIndex;
                if (e.CommandName.ToString() == "Edit1")
                {
                    ddlSelectTemplateName.Enabled = false;
                    ddlPayItemName.Enabled        = false;
                    objResultsEdit = objTrustPayItemTemplateBl.TrustPayItemTemplateT_Select(Convert.ToInt32(ViewState["TrustTemplateID"].ToString()));
                    String[] str;
                    if (objResultsEdit != null)
                    {
                        if (objResultsEdit.resultDT.Rows.Count > 0)
                        {
                            ddlSelectTemplateName.SelectedValue = objResultsEdit.resultDT.Rows[0][TrustPayItemTemplateTBo.TRUSTPAYITEMTEMPLATET_TEMPLATEID].ToString();
                            ViewState["TemplateNameID"]         = objResultsEdit.resultDT.Rows[0][TrustPayItemTemplateTBo.TRUSTPAYITEMTEMPLATET_TEMPLATEID].ToString();
                            ddlPayItemType.SelectedValue        = objResultsEdit.resultDT.Rows[0][TrustPayItemTemplateTBo.TRUSTPAYITEMTEMPLATET_PAYITEMTYPE].ToString();
                            ddlPayItemName.SelectedValue        = objResultsEdit.resultDT.Rows[0][TrustPayItemTemplateTBo.TRUSTPAYITEMTEMPLATET_PAYITEMID].ToString();
                            txtAmount.Text     = objResultsEdit.resultDT.Rows[0][TrustPayItemTemplateTBo.TRUSTPAYITEMTEMPLATET_AMOUNT].ToString();
                            txtPercentage.Text = objResultsEdit.resultDT.Rows[0][TrustPayItemTemplateTBo.TRUSTPAYITEMTEMPLATET_PERCENTAGE].ToString();

                            str = gvPayTemplate.Rows[rowIndex].Cells[4].Text.ToString().Split(',');
                            int i   = 0;
                            int len = str.Length;
                            for (i = 0; i < len; i++)
                            {
                                if (i >= len)
                                {
                                    break;
                                }
                                else
                                {
                                    if (str[i] != "NULL" && str[i] != "&nbsp;")
                                    {
                                        //cbDependsOn.SelectedValue = str[i];
                                        lbDependsOn.Items.Add(str[i]);
                                    }
                                    else
                                    {
                                        lbDependsOn.SelectedValue = null;
                                    }
                                }
                            }

                            if (ddlPayItemType.SelectedItem.Text == "Depends On Gross")
                            {
                                txtPercentage.Enabled   = true;
                                txtPercentage.BackColor = System.Drawing.Color.White;
                                txtAmount.Enabled       = false;
                                lbDependsOn.Enabled     = false;
                                lbDependsOn.Items.Clear();
                            }
                            else
                            if (ddlPayItemType.SelectedItem.Text == "Dependent")
                            {
                                txtPercentage.Enabled   = true;
                                txtPercentage.BackColor = System.Drawing.Color.White;
                                txtAmount.Enabled       = false;
                                lbDependsOn.Enabled     = true;
                                BindListbox();
                            }
                            else
                            if (ddlPayItemType.SelectedItem.Text == "Independent")
                            {
                                txtAmount.Enabled     = true;
                                txtAmount.BackColor   = System.Drawing.Color.White;
                                txtPercentage.Enabled = false;
                                lbDependsOn.Enabled   = false;
                                lbDependsOn.Items.Clear();
                            }

                            ViewState["Mode"] = "Edit";
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "divHide();", true);
                        }
                    }
                }
                if (e.CommandName.ToString() == "Delete1")
                {
                    objResultsEdit = objTrustPayItemTemplateBl.TrustPayItemTemplate_Delete(Convert.ToInt32(e.CommandArgument.ToString()), Convert.ToInt32(Session[ApplicationSession.USERID]), DateTime.UtcNow.AddHours(5.5).ToString());
                    if (objResultsEdit != null)
                    {
                        if (objResultsEdit.status == ApplicationResult.CommonStatusType.SUCCESS)
                        {
                            ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('PayTemplate Deleted Successfully.');</script>");
                        }
                        else
                        {
                            ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('There are PayTemplate(s) associated with Payroll.');</script>");
                        }
                    }
                    GridDataBind();
                }
            }
            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>");
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                TrustPayItemTemplateTBl objTrustPayItemTemplateBl = new TrustPayItemTemplateTBl();
                ApplicationResult       objResults = new ApplicationResult();
                TrustPayItemTemplateTBo objTrustPayItemTemplateBo = new TrustPayItemTemplateTBo();

                objTrustPayItemTemplateBo.TemplateID = Convert.ToInt32(ddlSelectTemplateName.SelectedValue.ToString());


                if (lbDependsOn.Enabled == true)
                {
                    lblDependent.Text = "";
                    string dependsOn = "";
                    for (int i = 0; i < lbDependsOn.Items.Count; i++)
                    {
                        if (lbDependsOn.Items[i].Selected)
                        {
                            dependsOn = dependsOn + "," + lbDependsOn.Items[i].Value.ToString();
                        }
                    }

                    if (dependsOn == "")
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Please select the PayItem on which this PayItem depends.');</script>");
                        dependsOn = "";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "divHide();", true);
                        goto Break;
                    }
                    objTrustPayItemTemplateBo.PayItemDependsOn = dependsOn;
                }
                else
                {
                    objTrustPayItemTemplateBo.PayItemDependsOn = "0";
                }


                if (txtAmount.Enabled = true && ddlPayItemType.SelectedValue == "0")
                {
                    if (txtAmount.Text != "")
                    {
                        objTrustPayItemTemplateBo.Amount = Convert.ToDouble(txtAmount.Text.Trim());
                    }
                    else
                    {
                        objTrustPayItemTemplateBo.Amount = Convert.ToDouble(0.00);
                    }
                }
                else
                {
                    objTrustPayItemTemplateBo.Amount = 0;
                    txtAmount.Text = "";
                }

                objTrustPayItemTemplateBo.PayItemType = Convert.ToInt32(ddlPayItemType.SelectedValue);
                if (txtPercentage.Enabled == true)
                {
                    if (txtPercentage.Text != "")
                    {
                        objTrustPayItemTemplateBo.Percentage = Convert.ToDouble(txtPercentage.Text.Trim());
                    }
                    else
                    {
                        objTrustPayItemTemplateBo.Percentage = 0;
                    }
                }
                else
                {
                    objTrustPayItemTemplateBo.Percentage = 0;
                }
                objTrustPayItemTemplateBo.LastModifiedDate   = DateTime.UtcNow.AddHours(5.5).ToString();
                objTrustPayItemTemplateBo.LastModifiedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]);

                if (ViewState["Mode"].ToString() == "Save")
                {
                    for (int i = 0; i < gvPayTemplate.Rows.Count; i++)
                    {
                        if (Convert.ToInt32(ddlPayItemName.SelectedValue) == Convert.ToInt32(gvPayTemplate.Rows[i].Cells[0].Text))
                        {
                            ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('This PayItem is already inserted.');</script>");
                            txtAmount.Text = "";
                            ddlPayItemType.SelectedValue = "-1";
                            goto Break;
                        }
                    }
                    objTrustPayItemTemplateBo.PayItemID     = Convert.ToInt32(ddlPayItemName.SelectedValue.ToString());
                    objTrustPayItemTemplateBo.CreatedDate   = DateTime.UtcNow.AddHours(5.5).ToString();
                    objTrustPayItemTemplateBo.CreatedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]);
                    ddlSelectTemplateName.SelectedValue     = Convert.ToString(objTrustPayItemTemplateBo.TemplateID);
                    if (objTrustPayItemTemplateBo.PayItemID != -1 && objTrustPayItemTemplateBo.PayItemType != -1)
                    {
                        objResults = objTrustPayItemTemplateBl.TrustPayItemTemplateT_Insert(objTrustPayItemTemplateBo);

                        if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS)
                        {
                            GridNameConvertion();
                            BindTemplateName();
                            BindPayItem();

                            ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Record Successfully Inserted.');</script>");
                            GridDataBind();
                        }
                    }

                    else
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Please Select Any PayItem..');</script>");
                        ddlPayItemType.SelectedIndex = -1;
                    }
                }
                else
                {
                    objTrustPayItemTemplateBo.TrustTemplateID = Convert.ToInt32(ViewState["TrustTemplateID"].ToString());
                    objTrustPayItemTemplateBo.PayItemID       = Convert.ToInt32(ddlPayItemName.SelectedValue.ToString());

                    if (objTrustPayItemTemplateBo.PayItemID != -1 && objTrustPayItemTemplateBo.PayItemType != -1)
                    {
                        //for (int i = 0; i < gvPayTemplate.Rows.Count; i++)
                        //{
                        //    if (Convert.ToInt32(ddlPayItemName.SelectedValue) == Convert.ToInt32(gvPayTemplate.Rows[i].Cells[0].Text))
                        //    {
                        //        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('This PayItem is already inserted.');</script>");
                        //        txtAmount.Text = "";
                        //        ddlPayItemType.SelectedValue = "-1";
                        //        goto Break;
                        //    }
                        //}
                        objResults = objTrustPayItemTemplateBl.TrustPayItemTemplateT_Update(objTrustPayItemTemplateBo);
                        if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS)
                        {
                            ddlSelectTemplateName.SelectedValue = ViewState["TemplateNameID"].ToString();
                            ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Record Successfully Updated');</script>");
                            GridNameConvertion();
                            BindTemplateName();
                            BindPayItem();
                            //  int i = Convert.ToInt32(ddlSelectTemplateName.SelectedValue);
                            GridDataBind();
                        }
                    }
                }



                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "divHide();", true);
                lbDependsOn.SelectedValue    = (-1).ToString();
                ddlPayItemType.SelectedIndex = 0;
                txtAmount.Text                = "";
                txtPercentage.Text            = "";
                ddlSelectTemplateName.Enabled = true;
                ddlPayItemName.Enabled        = true;

                //objControls.DisableControls(Master.FindControl("ContentPlaceHolder1"));
                Break :;
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "divHide();", true);
Exit:
                ;
            }
            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>");
            }
        }
Beispiel #4
0
        protected void gvSelectedPayItem_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                UserPayItemTemplateTBl objUserPayItemtBL = new UserPayItemTemplateTBl();
                UserPayItemTemplateTBo objUserPayItemBO  = new UserPayItemTemplateTBo();
                TrustPayItemBl         objTrustPayItemBl = new TrustPayItemBl();
                ApplicationResult      objResultsPayItem = new ApplicationResult();
                string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ',' });
                ViewState["UserTemplateID"]        = commandArgs[0];
                ViewState["PayItemMID"]            = commandArgs[1];
                ViewState["UserPayItemTemplateID"] = commandArgs[2];
                if (e.CommandName.ToString() == "Edit1")
                {
                    PanelVisibility(false, true, true, true);
                    txtPayItemName.Enabled   = false;
                    ddlPayItemType.Enabled   = false;
                    ddlDependsOn.Enabled     = false;
                    btnApplyTemplate.Visible = false;
                    ddlTemplate.Enabled      = false;
                    txtAnnual.Enabled        = false;
                    txtMonthly.Enabled       = false;
                    txtGross.Enabled         = false;
                    String[] Depends;

                    //  PayItemType = gdSelectedPayItem.SelectedRow.Cells[3].Text;

                    TrustPayItemTemplateTBl objTrustPayItemTemplateBl = new TrustPayItemTemplateTBl();
                    ApplicationResult       objResults = new ApplicationResult();
                    Controls objControls = new Controls();
                    objResults = objTrustPayItemTemplateBl.TrustPayItemTemplate_Select_PayItemWise(Convert.ToInt32(ddlTemplate.SelectedValue));
                    objControls.BindDropDown_ListBox(objResults.resultDT, ddlDependsOn, "Name", "PayItemMID");
                    ddlDependsOn.Items.Insert(0, new ListItem("-Select-", "-1"));

                    objResultsPayItem = objTrustPayItemBl.PayItemTemplate_SelectAll_BothID(Convert.ToInt32(ViewState["UserTemplateID"].ToString()), Convert.ToInt32(ViewState["PayItemMID"].ToString()));
                    if (objResultsPayItem != null)
                    {
                        if (objResultsPayItem.resultDT.Rows.Count > 0)
                        {
                            txtAmount.Text     = Convert.ToString(Math.Round(Convert.ToDouble(objControls.ConvertToCurrancy(objResultsPayItem.resultDT.Rows[0]["Amount"].ToString())), 2));
                            txtPercentage.Text = objResultsPayItem.resultDT.Rows[0]["Percentage"].ToString();

                            Depends = objResultsPayItem.resultDT.Rows[0]["DependsOn"].ToString().Split(',');
                            int i   = 0;
                            int len = Depends.Length;
                            for (i = 0; i < len; i++)
                            {
                                if (i >= len)
                                {
                                    break;
                                }
                                else
                                {
                                    if (Depends[i] != "NULL" && Depends[i] != "&nbsp;" && Depends[i] != "" && Depends[i] != "0")
                                    {
                                        //cbDependsOn.SelectedValue = str[i];
                                        // cbDependsOn.Items.Add(Depends[i]);
                                        ddlDependsOn.SelectedValue = Depends[i];
                                    }
                                    else
                                    {
                                        ddlDependsOn.SelectedValue = null;
                                    }
                                }
                            }

                            txtPayItemName.Text = objResultsPayItem.resultDT.Rows[0]["Name"].ToString();

                            // ddlPayItemType.SelectedValue = gvSelectedPayItem.SelectedRow.Cells[3].Text;

                            if (objResultsPayItem.resultDT.Rows[0]["Type"].ToString() == "Dependent")
                            {
                                ddlPayItemType.SelectedValue = "1";
                                txtPercentage.Enabled        = true;
                                txtPercentage.BackColor      = System.Drawing.Color.White;
                                txtAmount.BackColor          = System.Drawing.Color.Gainsboro;
                            }
                            else
                            if (objResultsPayItem.resultDT.Rows[0]["Type"].ToString() == "Independent")
                            {
                                ddlPayItemType.SelectedValue = "0";
                                txtAmount.Enabled            = true;
                                txtAmount.BackColor          = System.Drawing.Color.White;
                                txtPercentage.BackColor      = System.Drawing.Color.Gainsboro;
                                txtPercentage.Enabled        = false;
                            }
                            else
                            if (objResultsPayItem.resultDT.Rows[0]["Type"].ToString() == "Depends On Gross")
                            {
                                ddlPayItemType.SelectedValue = "2";

                                txtPercentage.Enabled   = true;
                                txtPercentage.BackColor = System.Drawing.Color.White;
                                txtAmount.BackColor     = System.Drawing.Color.Gainsboro;
                                txtAmount.Enabled       = false;
                            }
                        }
                    }
                }
            }
            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>");
            }
        }