Exemplo n.º 1
0
        /// <summary>
        /// To save details to database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string AlertMessage = string.Empty;
            string message      = string.Empty;

            ModeofPaymentBLL ModeofPaymentBLLOBJ = new ModeofPaymentBLL();
            ModeofPaymentBO  ModeofPaymentBOObj  = new ModeofPaymentBO();

            int uID = Convert.ToInt32(Session["USER_ID"].ToString());

            if (txtModeofPaymentID.Text.ToString().Trim() == "0")
            {
                try
                {
                    if (rdoTypeInKind.Checked)
                    {
                        ModeofPaymentBOObj.PaymentType = rdoTypeInKind.Text;
                    }
                    else
                    {
                        ModeofPaymentBOObj.PaymentType = rdoTypeCash.Text;
                    }

                    ModeofPaymentBOObj.ModeofPayment = txtModeofPayment.Text.ToString().Trim();
                    ModeofPaymentBOObj.UserID        = uID;
                    message = ModeofPaymentBLLOBJ.InsertModeofPayment(ModeofPaymentBOObj);

                    AlertMessage = "alert('" + message + "');";

                    if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                    {
                        message = "Data saved successfully";
                    }

                    if (message != "")
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
                        Clear();
                        BindGrid();
                        txtModeofPaymentID.Text = "0";
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    ModeofPaymentBLLOBJ = null;
                }
            }
            else
            {
                try
                {
                    if (rdoTypeInKind.Checked)
                    {
                        ModeofPaymentBOObj.PaymentType = rdoTypeInKind.Text;
                    }
                    else
                    {
                        ModeofPaymentBOObj.PaymentType = rdoTypeCash.Text;
                    }

                    ModeofPaymentBOObj.ModeofPayment   = txtModeofPayment.Text.ToString().Trim();
                    ModeofPaymentBOObj.ModeofPaymentID = Convert.ToInt32(txtModeofPaymentID.Text.ToString().Trim());
                    ModeofPaymentBOObj.UserID          = Convert.ToInt32(uID);

                    message = ModeofPaymentBLLOBJ.EDITMODEOFPAYMENT(ModeofPaymentBOObj);

                    if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                    {
                        message = "Data updated successfully";
                        // ClearDetails();
                        Clear();
                        SetUpdateMode(false);
                        BindGrid();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                finally
                {
                    ModeofPaymentBLLOBJ = null;
                }
            }
            AlertMessage = "alert('" + message + "');";
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
        }