Ejemplo n.º 1
0
        protected void gvCashSavingTransaction_ItemCommand(object source, GridCommandEventArgs e)
        {
            int accountId  = 0;
            int customerId = 0;

            if (e.CommandName == RadGrid.UpdateCommandName)
            {
                GridEditableItem gridEditableItem  = (GridEditableItem)e.Item;
                RadDatePicker    dpTransactionDate = (RadDatePicker)e.Item.FindControl("dpTransactionDate");
                TextBox          txtDescripton     = (TextBox)e.Item.FindControl("txtDescripton");
                TextBox          txtChequeNo       = (TextBox)e.Item.FindControl("txtChequeNo");
                DateTime         date                     = Convert.ToDateTime(dpTransactionDate.SelectedDate);
                DropDownList     ddlCFCCategory           = (DropDownList)e.Item.FindControl("ddlCFCCategory");
                TextBox          txtAmount                = (TextBox)e.Item.FindControl("txtAmount");
                TextBox          txtExternalTransactionId = (TextBox)e.Item.FindControl("txtExternalTransactionId");
                RadioButton      rbtnY                    = (RadioButton)e.Item.FindControl("rbtnYes");
                RadioButton      rbtnN                    = (RadioButton)e.Item.FindControl("rbtnNo");
                customeraccountVo = new CustomerAccountsVo();
                customeraccountVo.ExternalTransactionId = txtExternalTransactionId.Text.ToString();
                customeraccountVo.Transactiondate       = date;
                customeraccountVo.CCST_Desc             = txtDescripton.Text.ToString();
                customeraccountVo.ChequeNo        = txtChequeNo.Text.ToString();
                customeraccountVo.CFCCategoryCode = ddlCFCCategory.SelectedItem.Value.ToString();
                customeraccountVo.Amount          = double.Parse(txtAmount.Text.ToString());
                customeraccountVo.AccountId       = bankId;
                if (rbtnN.Checked)
                {
                    customeraccountVo.IsWithdrwal = 0;
                }
                if (rbtnY.Checked)
                {
                    customeraccountVo.IsWithdrwal = 1;
                }
                accountId = int.Parse(gvCashSavingTransaction.MasterTableView.DataKeyValues[e.Item.ItemIndex]["CCST_TransactionId"].ToString());
                customerAccountBo.UpdateCustomerBankTransaction(customeraccountVo, accountId);
            }
            if (e.CommandName == RadGrid.PerformInsertCommandName)
            {
                DataTable dtBankAccId = new DataTable();
                dtBankAccId = (DataTable)Session["BankAccId"];//string strBankAccountID = ViewState["BankId"].ToString();
                RadDatePicker dpTransactionDate        = (RadDatePicker)e.Item.FindControl("dpTransactionDate");
                TextBox       txtDescripton            = (TextBox)e.Item.FindControl("txtDescripton");
                TextBox       txtChequeNo              = (TextBox)e.Item.FindControl("txtChequeNo");
                TextBox       txtAmount                = (TextBox)e.Item.FindControl("txtAmount");
                TextBox       txtExternalTransactionId = (TextBox)e.Item.FindControl("txtExternalTransactionId");
                DateTime      date           = Convert.ToDateTime(dpTransactionDate.SelectedDate);
                DropDownList  ddlCFCCategory = (DropDownList)e.Item.FindControl("ddlCFCCategory");
                RadioButton   rbtnY          = (RadioButton)e.Item.FindControl("rbtnYes");
                RadioButton   rbtnN          = (RadioButton)e.Item.FindControl("rbtnNo");
                RMVo          rmVo           = new RMVo();
                int           userId;
                rmVo              = (RMVo)Session["RmVo"];
                userId            = rmVo.UserId;
                customerId        = customerVo.CustomerId;
                customeraccountVo = new CustomerAccountsVo();
                customeraccountVo.ExternalTransactionId = txtExternalTransactionId.Text.ToString();
                customeraccountVo.Transactiondate       = date;
                customeraccountVo.CCST_Desc             = txtDescripton.Text.ToString();
                customeraccountVo.ChequeNo        = txtChequeNo.Text.ToString();
                customeraccountVo.CFCCategoryCode = ddlCFCCategory.SelectedItem.Value.ToString();
                customeraccountVo.Amount          = double.Parse(txtAmount.Text.ToString());
                //int i;
                //dtBankAccId = (DataTable)Session["BankAccId"];
                //if (dtBankAccId.Rows.Count > 0)
                //{
                //    for (i = 0; i < dtBankAccId.Rows.Count; i++)
                //    {
                //        custBankAccId = Convert.ToInt32(dtBankAccId.Rows[i]["CB_CustBankAccId"].ToString());
                //    }
                //}
                customeraccountVo.AccountId = bankId;
                if (rbtnN.Checked)
                {
                    customeraccountVo.IsWithdrwal = 0;
                }
                if (rbtnY.Checked)
                {
                    customeraccountVo.IsWithdrwal = 1;
                }

                customerAccountBo.CreatecustomerBankTransaction(customeraccountVo, userId);
            }

            if (e.CommandName == "Delete")
            {
                bool isdeleted = false;
                accountId = int.Parse(gvCashSavingTransaction.MasterTableView.DataKeyValues[e.Item.ItemIndex]["CCST_TransactionId"].ToString());
                isdeleted = customerAccountBo.DeleteCustomerBankTransaction(accountId);
                //if (isdeleted == false)
                //    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('Cannot delete the bank is associate with a folio');", true);
            }
            BindTransactionGrid(bankId);
        }