private void LedgerGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (Convert.ToInt32(LedgerGridView.Rows[e.RowIndex].Cells["BillNo"].Value) > -1) { return; } VoucherPaymentModification _VoucherPaymentModification = new VoucherPaymentModification(LedgerGridView.Rows[e.RowIndex].Cells["AMOUNT"].Value); _VoucherPaymentModification.StartPosition = FormStartPosition.CenterScreen; _VoucherPaymentModification.ShowDialog(); if (_VoucherPaymentModification.NewAmount != "" && LedgerGridView.Rows[e.RowIndex].Cells["AMOUNT"].Value != _VoucherPaymentModification.NewAmount) { decimal NewAmount = Convert.ToDecimal(_VoucherPaymentModification.NewAmount); decimal OldAmount = Convert.ToDecimal(LedgerGridView.Rows[e.RowIndex].Cells["AMOUNT"].Value); decimal UpdateAmount = NewAmount - OldAmount; DataSet CustomerDataSet1 = DatabaseCalls.GetCustomer(Convert.ToInt32(LedgerGridView.Rows[e.RowIndex].Cells["Customer_id"].Value)); if (CustomerDataSet1.Tables[0].Rows.Count == 0) { Variables.NotificationStatus = true; Variables.NotificationMessageTitle = this.Name; Variables.NotificationMessageText = "No Customer Found"; return; } decimal CustomerNewBalance = Convert.ToDecimal(CustomerDataSet1.Tables[0].Rows[0]["AMOUNT"]); CustomerNewBalance += UpdateAmount; //atif work here DatabaseCalls.ModifyCustomer(Convert.ToInt32(LedgerGridView.Rows[e.RowIndex].Cells["Customer_id"].Value), CustomerNewBalance); //CustomerDataSet1 = DatabaseCalls.GetCustomers();//.GetCustomer(Convert.ToInt32(LedgerGridView.Rows[e.RowIndex].Cells["Customer_id"].Value)); DatabaseCalls.ModifyVoucher(Convert.ToInt32(LedgerGridView.Rows[e.RowIndex].Cells["BillNo"].Value), NewAmount, CustomerNewBalance); LedgerGridView.Rows[e.RowIndex].Cells["Amount"].Value = NewAmount; RemainingBalance_txt.Text = CustomerBalance_txt.Text = CustomerNewBalance.ToString(); VoucherRemarks_txt.Focus(); //Bill Detail try { LedgerDataSet = DatabaseCalls.GetLedger("All"); LedgerDataSet.Tables[0].Columns["ID"].ColumnName = "BillNo"; LedgerDataSet.Tables[0].Columns.Add("Customer"); for (int loop = 0; loop < LedgerDataSet.Tables[0].Rows.Count; loop++) { if (Convert.ToInt16(LedgerDataSet.Tables[0].Rows[loop]["Customer_ID"].ToString()) > -1) { for (int loop1 = 0; loop1 < CustomerDataSet.Tables[0].Rows.Count; loop1++) { if (Convert.ToInt32(LedgerDataSet.Tables[0].Rows[loop]["Customer_ID"]) == Convert.ToInt32(CustomerDataSet.Tables[0].Rows[loop1]["ID"])) { if (LedgerDataSet.Tables[0].Rows[loop]["Customer"].ToString() != CustomerDataSet.Tables[0].Rows[loop1]["Name"].ToString()) { LedgerDataSet.Tables[0].Rows[loop]["Customer"] = CustomerDataSet.Tables[0].Rows[loop1]["Name"]; } } } } else if (Convert.ToInt16(LedgerDataSet.Tables[0].Rows[loop]["Customer_ID"].ToString()) == -1) { LedgerDataSet.Tables[0].Rows[loop]["Customer"] = "Admin"; } else { LedgerDataSet.Tables[0].Rows[loop]["Customer"] = "Error"; } } //for (int loop = 0; loop < LedgerDataSet.Tables[0].Rows.Count - 1; loop++) //{ // LedgerDataSet.Tables[0].Rows[loop]["Customer"] = DatabaseCalls.GetCustomerName(Convert.ToInt16(LedgerDataSet.Tables[0].Rows[loop]["Customer_ID"].ToString())); //} LedgerGridView.Columns.Clear(); LedgerGridView.DataSource = LedgerDataSet.Tables[0]; LedgerGridView.Columns["Customer_ID"].Visible = false; LedgerGridView.Columns["Customer"].DisplayIndex = 2; //.Visible LedgerGridView.Columns["TotalCtn"].DisplayIndex = 4; //.Visible LedgerGridView.Columns["DATED"].SortMode = DataGridViewColumnSortMode.Automatic; } catch (Exception ex) { Variables.NotificationStatus = true; Variables.NotificationMessageTitle = this.Name; Variables.NotificationMessageText = ex.Message; } } else { Variables.NotificationMessageTitle = this.Name; Variables.NotificationMessageText = "Same Amount Entered"; Variables.NotificationStatus = true; } }
private void LedgerGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (Convert.ToInt32( LedgerGridView.Rows[e.RowIndex].Cells["BillNo"].Value) > -1) return; VoucherPaymentModification _VoucherPaymentModification = new VoucherPaymentModification(LedgerGridView.Rows[e.RowIndex].Cells["AMOUNT"].Value); _VoucherPaymentModification.StartPosition = FormStartPosition.CenterScreen; _VoucherPaymentModification.ShowDialog(); if (_VoucherPaymentModification.NewAmount != "" && LedgerGridView.Rows[e.RowIndex].Cells["AMOUNT"].Value != _VoucherPaymentModification.NewAmount) { decimal NewAmount = Convert.ToDecimal(_VoucherPaymentModification.NewAmount); decimal OldAmount = Convert.ToDecimal(LedgerGridView.Rows[e.RowIndex].Cells["AMOUNT"].Value); decimal UpdateAmount = NewAmount - OldAmount; DataSet CustomerDataSet1 = DatabaseCalls.GetCustomer(Convert.ToInt32(LedgerGridView.Rows[e.RowIndex].Cells["Customer_id"].Value)); if (CustomerDataSet1.Tables[0].Rows.Count == 0) { Variables.NotificationStatus = true; Variables.NotificationMessageTitle = this.Name; Variables.NotificationMessageText = "No Customer Found"; return; } decimal CustomerNewBalance = Convert.ToDecimal(CustomerDataSet1.Tables[0].Rows[0]["AMOUNT"]); CustomerNewBalance += UpdateAmount; //atif work here DatabaseCalls.ModifyCustomer(Convert.ToInt32(LedgerGridView.Rows[e.RowIndex].Cells["Customer_id"].Value), CustomerNewBalance); //CustomerDataSet1 = DatabaseCalls.GetCustomers();//.GetCustomer(Convert.ToInt32(LedgerGridView.Rows[e.RowIndex].Cells["Customer_id"].Value)); DatabaseCalls.ModifyVoucher(Convert.ToInt32(LedgerGridView.Rows[e.RowIndex].Cells["BillNo"].Value), NewAmount, CustomerNewBalance); LedgerGridView.Rows[e.RowIndex].Cells["Amount"].Value = NewAmount; RemainingBalance_txt.Text = CustomerBalance_txt.Text = CustomerNewBalance.ToString(); VoucherRemarks_txt.Focus(); //Bill Detail try { LedgerDataSet = DatabaseCalls.GetLedger("All"); LedgerDataSet.Tables[0].Columns["ID"].ColumnName = "BillNo"; LedgerDataSet.Tables[0].Columns.Add("Customer"); for (int loop = 0; loop < LedgerDataSet.Tables[0].Rows.Count; loop++) { if (Convert.ToInt16(LedgerDataSet.Tables[0].Rows[loop]["Customer_ID"].ToString()) > -1) { for (int loop1 = 0; loop1 < CustomerDataSet.Tables[0].Rows.Count; loop1++) { if (Convert.ToInt32(LedgerDataSet.Tables[0].Rows[loop]["Customer_ID"]) == Convert.ToInt32(CustomerDataSet.Tables[0].Rows[loop1]["ID"])) { if (LedgerDataSet.Tables[0].Rows[loop]["Customer"].ToString() != CustomerDataSet.Tables[0].Rows[loop1]["Name"].ToString()) LedgerDataSet.Tables[0].Rows[loop]["Customer"] = CustomerDataSet.Tables[0].Rows[loop1]["Name"]; } } } else if (Convert.ToInt16(LedgerDataSet.Tables[0].Rows[loop]["Customer_ID"].ToString()) == -1) LedgerDataSet.Tables[0].Rows[loop]["Customer"] = "Admin"; else LedgerDataSet.Tables[0].Rows[loop]["Customer"] = "Error"; } //for (int loop = 0; loop < LedgerDataSet.Tables[0].Rows.Count - 1; loop++) //{ // LedgerDataSet.Tables[0].Rows[loop]["Customer"] = DatabaseCalls.GetCustomerName(Convert.ToInt16(LedgerDataSet.Tables[0].Rows[loop]["Customer_ID"].ToString())); //} LedgerGridView.Columns.Clear(); LedgerGridView.DataSource = LedgerDataSet.Tables[0]; LedgerGridView.Columns["Customer_ID"].Visible = false; LedgerGridView.Columns["Customer"].DisplayIndex = 2;//.Visible LedgerGridView.Columns["TotalCtn"].DisplayIndex = 4;//.Visible LedgerGridView.Columns["DATED"].SortMode = DataGridViewColumnSortMode.Automatic; } catch (Exception ex) { Variables.NotificationStatus = true; Variables.NotificationMessageTitle = this.Name; Variables.NotificationMessageText = ex.Message; } } else { Variables.NotificationMessageTitle = this.Name; Variables.NotificationMessageText = "Same Amount Entered"; Variables.NotificationStatus = true; } }