private void AddCustomer_Shown(object sender, EventArgs e) { try { CustomerDataSet = DatabaseCalls.GetCustomers(); CustomersDataGridView.DataSource = CustomerDataSet.Tables[0]; CustomersDataGridView.Columns["ID"].Visible = false; foreach (DataRow GridViewColumn in CustomerDataSet.Tables[0].Rows) { CustomerNameSearch_txt.Items.Add(GridViewColumn.ItemArray[1]); } CustomersDataGridView.Columns["NAME"].DisplayIndex = 0; CustomersDataGridView.Columns["ADDRESS"].DisplayIndex = 1; CustomersDataGridView.Columns["PHONE"].DisplayIndex = 2; CustomersDataGridView.Columns["EMAIL"].DisplayIndex = 3; CustomersDataGridView.Columns["OPENING_BALANCE"].DisplayIndex = 4; CustomersDataGridView.Columns["AMOUNT"].Visible = false; CustomersDataGridView.Columns["BALANCE_LIMIT"].Visible = false; } catch (Exception ex) { Variables.NotificationStatus = true; Variables.NotificationMessageTitle = this.Name; Variables.NotificationMessageText = ex.Message; } FormLoading = false; CustomerName_txt.Focus(); }
private void CustomerNameDataGridView_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Enter) { //if (Convert.ToInt32(CustomerNameDataGridView.Rows[SelectedRowIndex].Cells["Quantity"].Value.ToString()) > 0) { CustomerNameDataGridView.Visible = false; CustomerName_txt.Text = CustomerNameDataGridView.Rows[SelectedRowIndex].Cells["Name"].Value.ToString().Trim(); CustomerID_txt.Text = CustomerNameDataGridView.Rows[SelectedRowIndex].Cells["ID"].Value.ToString().Trim(); CustomerBalance_txt.Text = CustomerNameDataGridView.Rows[SelectedRowIndex].Cells["AMOUNT"].Value.ToString().Trim(); Voucher_DTPicker.Focus(); } } else if (e.KeyCode == Keys.Escape) { CustomerName_txt.Focus(); } } catch (Exception ex) { Variables.NotificationStatus = true; Variables.NotificationMessageTitle = this.Name; Variables.NotificationMessageText = ex.Message; } }
private void button2_Click(object sender, EventArgs e) { try { VoucherAmount_txt_TextChanged(sender, e); if (VoucherAmount_txt.Text == "0" || VoucherAmount_txt.Text == "") { Variables.NotificationMessageTitle = this.Name; Variables.NotificationMessageText = "add amount."; Variables.NotificationStatus = true; return; } int CustomerID = Convert.ToInt32(CustomerID_txt.Text); //foreach (DataRow GridViewColumn in CustomerDataSet.Tables[0].Rows) //{ // if (GridViewColumn.ItemArray[1].ToString() == CustomerName_txt.Text) // { // CustomerID = Convert.ToInt32(GridViewColumn.ItemArray[0]); // break; // } //} decimal VoucherAmount = Convert.ToDecimal(VoucherAmount_txt.Text) * (-1); //Add Bill Number String Result1 = DatabaseCalls.AddVoucherPayment(CustomerID, Voucher_DTPicker.Value, VoucherAmount, VoucherRemarks_txt.Text, Convert.ToDecimal(RemainingBalance_txt.Text)); if (Result1.StartsWith("Voucher Added with") != true) { Variables.NotificationStatus = true; Variables.NotificationMessageTitle = this.Name; Variables.NotificationMessageText = Result1; return; } //LedgerStatement_Load(sender, e); //Variables.FormRefresh = "AddBill/Leadger"; RemainingBalance_txt.Text = "0"; CustomerBalance_txt.Text = "0"; VoucherAmount_txt.Text = "0"; VoucherRemarks_txt.Text = "0"; // CustomerName_txt.Text = ""; // CustomerName_txt_Enter(sender, e); // CustomerID_txt.Text = ""; //get customers RefreshCustomerData(); CustomerName_txt.Focus(); } catch (Exception ex) { Variables.NotificationMessageTitle = this.Name; Variables.NotificationMessageText = ex.Message; Variables.NotificationStatus = true; } }
/// <summary> /// Checks mandatory fields /// </summary> /// <returns></returns> private bool CheckMandatory() { if (CustomerCode_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, CustomerCode_lbl.Text); popUpMessage.Warning(messageData, Text); CustomerCode_txt.Focus(); return(false); } if (CustomerName_txt.Text == string.Empty) { messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, CustomerName_lbl.Text); popUpMessage.Warning(messageData, Text); CustomerName_txt.Focus(); return(false); } return(true); }
/// <summary> /// update data to db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Ok_btn_Click(object sender, EventArgs e) { var sch = StringCheckHelper.GetInstance(); if (CheckMandatory()) { if (!sch.IsASCII(CustomerCode_txt.Text) || !sch.IsASCII(CustomerName_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); if (!sch.IsASCII(CustomerCode_txt.Text)) { CustomerCode_txt.Focus(); } else { CustomerName_txt.Focus(); } return; } CustomerVo inVo = new CustomerVo { CustomerCode = CustomerCode_txt.Text.Trim(), CustomerName = CustomerName_txt.Text.Trim(), Address1 = Address1_txt.Text.Trim(), Address2 = Address2_txt.Text.Trim(), EmailId = EmailId_txt.Text.Trim(), Remarks = Remarks_txt.Text.Trim(), PhoneNo = PhoneNo_txt.Text.Trim(), }; if (string.Equals(mode, CommonConstants.MODE_ADD)) { CustomerVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, CustomerCode_lbl.Text + " : " + CustomerCode_txt.Text); popUpMessage.ConfirmationOkCancel(messageData, Text); return; } } try { if (string.Equals(mode, CommonConstants.MODE_ADD)) { CustomerVo outVo = (CustomerVo)base.InvokeCbm(new AddCustomerMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } else if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { inVo.CustomerId = updateData.CustomerId; CustomerVo outVo = (CustomerVo)base.InvokeCbm(new UpdateCustomerMasterMntCbm(), inVo, false); IntSuccess = outVo.AffectedCount; } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } if ((IntSuccess > 0) || (IntSuccess == 0)) { this.Close(); } } }