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 #2
0
        /// <summary>
        /// To Update details of TrustPayItemTemplateT in tbl_TrustPayItemTemplate_T table
        /// Created By : NafisaMulla, 10-04-2015
        /// Modified By :
        /// </summary>
        /// <param name="objTrustPayItemTemplateTBO"></param>
        /// <returns></returns>
        public ApplicationResult TrustPayItemTemplateT_Update(TrustPayItemTemplateTBo objTrustPayItemTemplateTBO)
        {
            try
            {
                pSqlParameter = new SqlParameter[9];


                pSqlParameter[0]           = new SqlParameter("@TrustTemplateID", SqlDbType.Int);
                pSqlParameter[0].Direction = ParameterDirection.Input;
                pSqlParameter[0].Value     = objTrustPayItemTemplateTBO.TrustTemplateID;

                pSqlParameter[1]           = new SqlParameter("@TemplateID", SqlDbType.Int);
                pSqlParameter[1].Direction = ParameterDirection.Input;
                pSqlParameter[1].Value     = objTrustPayItemTemplateTBO.TemplateID;

                pSqlParameter[2]           = new SqlParameter("@PayItemID", SqlDbType.Int);
                pSqlParameter[2].Direction = ParameterDirection.Input;
                pSqlParameter[2].Value     = objTrustPayItemTemplateTBO.PayItemID;

                pSqlParameter[3]           = new SqlParameter("@PayItemType", SqlDbType.Int);
                pSqlParameter[3].Direction = ParameterDirection.Input;
                pSqlParameter[3].Value     = objTrustPayItemTemplateTBO.PayItemType;

                pSqlParameter[4]           = new SqlParameter("@PayItemDependsOn", SqlDbType.NVarChar);
                pSqlParameter[4].Direction = ParameterDirection.Input;
                pSqlParameter[4].Value     = objTrustPayItemTemplateTBO.PayItemDependsOn;

                pSqlParameter[5]           = new SqlParameter("@Percentage", SqlDbType.Float);
                pSqlParameter[5].Direction = ParameterDirection.Input;
                pSqlParameter[5].Value     = objTrustPayItemTemplateTBO.Percentage;

                pSqlParameter[6]           = new SqlParameter("@Amount", SqlDbType.Float);
                pSqlParameter[6].Direction = ParameterDirection.Input;
                pSqlParameter[6].Value     = objTrustPayItemTemplateTBO.Amount;

                pSqlParameter[7]           = new SqlParameter("@LastModifiedUserID", SqlDbType.Int);
                pSqlParameter[7].Direction = ParameterDirection.Input;
                pSqlParameter[7].Value     = objTrustPayItemTemplateTBO.LastModifiedUserID;

                pSqlParameter[8]           = new SqlParameter("@LastModifiedDate", SqlDbType.VarChar);
                pSqlParameter[8].Direction = ParameterDirection.Input;
                pSqlParameter[8].Value     = objTrustPayItemTemplateTBO.LastModifiedDate;


                sSql = "usp_tbl_TrustPayItemTemplate_T_Update";
                int iResult = Database.ExecuteNonQuery(CommandType.StoredProcedure, sSql, pSqlParameter);

                if (iResult > 0)
                {
                    ApplicationResult objResults = new ApplicationResult();
                    objResults.status = ApplicationResult.CommonStatusType.SUCCESS;
                    return(objResults);
                }
                else
                {
                    ApplicationResult objResults = new ApplicationResult();
                    objResults.status = ApplicationResult.CommonStatusType.FAILURE;
                    return(objResults);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objTrustPayItemTemplateTBO = null;
            }
        }