protected void grdReviewList_ItemCommand(object sender, GridCommandEventArgs e)
        {
            DataTable a = GetDataInfo();
            switch (e.CommandName)
            {
                case "DeleteRow":

                    a.Rows.RemoveAt((e.Item).ItemIndex);
                    rebindData();
                    break;
                case "EditRow":
                    var row  = a.Rows[(e.Item).ItemIndex];
                    if (CreditAccountForUpdate.Text != "" && CreditAccountForUpdate.Text == row["WorkingAccId"].ToString())
                    {
                        return;
                    }
                    var accopen = new SavingAccountDAO().GetAccountOpenByTypeAndCustomerID("P", row["WorkingAccId"].ToString());
                    if (accopen!=null){
                        rcbCreditAccount.Items.Add(new RadComboBoxItem(accopen.Title,accopen.AccountCode) );
                    }
                    rcbPaymentMethod.SelectedValue = row["PaymentMethod"].ToString();
                    tbCreditAmount.Value = Convert.ToDouble(row["CreditAmount"].ToString());
                    rcbCreditAccount.SelectedValue = row["WorkingAccId"].ToString();
                    CreditAccountForUpdate.Text = row["WorkingAccId"].ToString();
                    break;
                default:
                        grdReviewList.DataSource = a;
                        grdReviewList.Rebind();
                        break;
            }
        }
        private void LoadDataForDropdowns()
        {
            rcbAccountPayment.Items.Clear();
            rcbAccountPayment.Items.Add(new RadComboBoxItem(""));
            rcbAccountPayment.AppendDataBoundItems = true;
            rcbAccountPayment.DataValueField = "ID";
            rcbAccountPayment.DataTextField = "Title";
            var listAcc = new SavingAccountDAO().GetAccountOpenByType("C");
            foreach (AccountOpen acc in listAcc)
            {
                RadComboBoxItem item = new RadComboBoxItem(acc.AccountCode + " - "+ acc.CustomerName,acc.ID);
                item.Attributes.Add("CustomerName", acc.CustomerName);
                item.Attributes.Add("Currency", acc.Currency);
                item.Attributes.Add("CustomerID", acc.CustomerID);
                item.Attributes.Add("ActualBallance", acc.ActualBallance.ToString());
                rcbAccountPayment.Items.Add(item);
            }

            rcbTerm.Items.Clear();
            rcbTerm.Items.Add(new RadComboBoxItem(""));
            rcbTerm.AppendDataBoundItems = true;
            rcbTerm.DataValueField = "Code";
            rcbTerm.DataTextField = "Code";
            rcbTerm.DataSource = SavingAccountDAO.GetSalaryPaymentFrequencyTerm();
            rcbTerm.DataBind();

            rcbCreditAccount.Items.Clear();
            rcbCreditAccount.Items.Add(new RadComboBoxItem(""));
            rcbCreditAccount.AppendDataBoundItems = true;
            rcbCreditAccount.DataValueField = "AccountCode";
            rcbCreditAccount.DataTextField = "Title";
            rcbCreditAccount.DataSource = SavingAccountDAO.GetAccountOpenByType("P");
            rcbCreditAccount.DataBind();

            rcbPaymentMethod.Items.Clear();
            rcbPaymentMethod.Items.Add(new RadComboBoxItem(""));
            rcbPaymentMethod.AppendDataBoundItems = true;
            rcbPaymentMethod.DataValueField = "Code";
            rcbPaymentMethod.DataTextField = "Code";
            rcbPaymentMethod.DataSource = new SavingAccountDAO().GetSalaryPaymentMethod();
            rcbPaymentMethod.DataBind();

            //rcbAccountPayment.DataBind();
        }
 private void rebindData()
 {
     var tb = GetDataInfo();
     if (tb.Rows.Count > 0)
     {
         var cAcc = new SavingAccountDAO().GetAccountOpenByType("P");
         double sumAmount = 0;
         foreach(DataRow row in tb.Rows)
         {
             string workingAccId = row["WorkingAccId"].ToString();
             cAcc = cAcc.Where(r => r.AccountCode != workingAccId).ToList();
             sumAmount = sumAmount + Convert.ToDouble(row["CreditAmount"].ToString());
         }
         rcbCreditAccount.Items.Clear();
         rcbCreditAccount.Items.Add(new RadComboBoxItem(""));
         rcbCreditAccount.AppendDataBoundItems = true;
         rcbCreditAccount.DataValueField = "AccountCode";
         rcbCreditAccount.DataTextField = "Title";
         rcbCreditAccount.DataSource = cAcc;
         rcbCreditAccount.DataBind();
         tbTotalDebitAmtShow.Value = sumAmount;
         if (string.IsNullOrEmpty(rcbAccountPayment.SelectedItem.Attributes["ActualBallance"]))
         {
             tbTotalDebitAmt.Value = -1 * sumAmount;
         }
         else
         {
             tbTotalDebitAmt.Value = Convert.ToDouble(rcbAccountPayment.SelectedItem.Attributes["ActualBallance"]) - sumAmount;
         }
         CheckExistDpAccount();
         if (!tbTotalDebitAmt.Value.HasValue || tbTotalDebitAmt.Value <= 0)
             NotTotalDebitAmt.Text = string.Empty;
         else NotTotalDebitAmt.Text = "ok";
     }
 }
 private void CheckExistDpAccount()
 {
     CheckExist.Text = "ok";
     var tb = GetDataInfo();
     var cAcc = new SavingAccountDAO().GetAccountOpenByType("P");
     foreach (DataRow row in tb.Rows)
     {
         var test = cAcc.Where(r => r.AccountCode == row["WorkingAccId"].ToString()).FirstOrDefault();
         if (test == null)
         {
             row["Exist"] = "Not exist";
             CheckExist.Text = string.Empty;
         }
     }
     grdReviewList.DataSource = tb;
     grdReviewList.Rebind();
 }