public void UpdateCustomerInTable(CustomerGet customer) { if (customer == null) { return; } var table = GetTable(); for (int i = 0; i < table.Rows.Count; ++i) { DataGridViewRow row = table.Rows[i]; int id = int.Parse(row.Cells["CustomerTable_ID"].Value.ToString()); if (customer.ID == id) { row.Cells["CustomerTable_ID"].Value = customer.ID; row.Cells["CustomerTable_Name"].Value = customer.Name; row.Cells["CustomerTable_EmailId"].Value = customer.Email; row.Cells["CustomerTable_MobileNumber"].Value = customer.MobileNumber; row.Cells["CustomerTable_PendingAmount"].Value = customer.PendingAmount; return; } } }
public static List <CustomerGet> GetNotInGroupByGroupID(int GroupID) { var list = new List <CustomerGet>(); var sql = @"SELECT l.ID, l.CustomerName, l.CustomerPhone FROM tbl_Customer l"; sql += " LEFT JOIN (Select UID, CustomerName from tbl_DiscountCustomer where DiscountGroupID = " + GroupID + " ) as r ON r.UID = l.ID"; sql += " WHERE r.UID IS NULL"; var reader = (IDataReader)SqlHelper.ExecuteDataReader(sql); while (reader.Read()) { var entity = new CustomerGet(); if (reader["ID"] != DBNull.Value) { entity.ID = reader["ID"].ToString().ToInt(0); } if (reader["CustomerName"] != DBNull.Value) { entity.CustomerName = reader["CustomerName"].ToString(); } if (reader["CustomerPhone"] != DBNull.Value) { entity.CustomerPhone = reader["CustomerPhone"].ToString(); } list.Add(entity); } reader.Close(); return(list); }
public void UpdateUILabels() { double actualPrice = 0; double subtotal = 0; double totalDiscount = 0; double totalTax = 0; double amountDue = 0; for (int i = 0; i < m_UIControl.Bill_ProductsDataView.Rows.Count; ++i) { var price = Convert.ToDouble(m_UIControl.Bill_ProductsDataView.Rows[i].Cells["BillTable_Price"].Value); var quantity = Convert.ToInt32(m_UIControl.Bill_ProductsDataView.Rows[i].Cells["BillTable_Quantity"].Value); actualPrice += price * quantity; totalDiscount += Convert.ToDouble(m_UIControl.Bill_ProductsDataView.Rows[i].Cells["BillTable_Discount"].Value); totalTax += Convert.ToDouble(m_UIControl.Bill_ProductsDataView.Rows[i].Cells["BillTable_Tax"].Value); subtotal += Convert.ToDouble(m_UIControl.Bill_ProductsDataView.Rows[i].Cells["BillTable_FinalPrice"].Value); } m_transactionSession.actualPrice = m_UIControl.tb_actualPrice.Text = actualPrice.ToString(); m_transactionSession.totalDiscount = m_UIControl.tb_totalDiscount.Text = totalDiscount.ToString(); m_transactionSession.totalTax = m_UIControl.tb_totalTax.Text = totalTax.ToString(); m_transactionSession.subtotal = m_UIControl.tb_subtotal.Text = subtotal.ToString(); amountDue = subtotal; CustomerGet customer = m_transactionSession.GetCustomer(); if (customer != null) { amountDue += customer.PendingAmount; } m_UIControl.tb_amountPaid.Text = m_UIControl.tb_amountDue.Text = amountDue.ToString(); m_transactionSession.amountDue = amountDue.ToString(); }
private bool ValidateCustomerDetails() { m_UIControl.lbl_customerErrorText.Text = string.Empty; var email = m_UIControl.tb_customerEmail.Text.Trim(); var name = m_UIControl.tb_CustomerName.Text.Trim(); var mobileNumber = m_UIControl.tb_customerMobile.Text.Trim(); if (string.IsNullOrEmpty(name)) { m_UIControl.lbl_customerErrorText.Text = "Name cannot be empty"; return(false); } if (string.IsNullOrEmpty(mobileNumber)) { m_UIControl.lbl_customerErrorText.Text = "Mobile number cannot be empty"; return(false); } if (!string.IsNullOrEmpty(email)) { if (!Validator.IsValidEmail(email)) { m_UIControl.lbl_customerErrorText.Text = "Email Id not valid"; return(false); } } if (!Validator.IsValidString(name)) { m_UIControl.lbl_customerErrorText.Text = "Name not valid"; return(false); } if (!Validator.IsValidMobileNumber(mobileNumber)) { m_UIControl.lbl_customerErrorText.Text = "Mobile Number not valid"; return(false); } // check if customer with same mobile number exists CustomerGet customer = DataService.GetCustomerDataController().GetByMobileNumber(mobileNumber); if (customer != null) { m_UIControl.lbl_customerErrorText.Text = "Customer with same Mobile Number already exists!"; return(false); } var customerWithSameName = DataService.GetCustomerDataController().GetByName(m_UIControl.tb_CustomerName.Text.Trim()); if (customerWithSameName != null) { m_UIControl.lbl_customerErrorText.Text = "Customer with same name already exists!"; return(false); } return(true); }
private void HandleEvent_EntryUpdated(Event_EntryUpdated e) { DBEntityType entityType = e.GetEntityType(); if (entityType == DBEntityType.CUSTOMER) { CustomerGet customer = DataService.GetCustomerDataController().Get(e.GetID()); m_Controller.UpdateCustomerInTable(customer); } }
private void UpdateCustomerDetails(CustomerGet customer) { m_UIControl.tb_customerName.Text = customer.Name; double PendingAmount = customer.PendingAmount; m_UIControl.lbl_CustomerAmount.Text = (PendingAmount < 0.0) ? "Balance Amount :" : "Pending Amount :"; m_UIControl.tb_pendingAmount.Text = Math.Abs(customer.PendingAmount).ToString(); }
public void AddCustomerToTable(CustomerGet customer) { var Table = GetTable(); int Index = Table.Rows.Add(); DataGridViewRow NewRow = Table.Rows[Index]; NewRow.Cells["CustomerTable_ID"].Value = customer.ID; NewRow.Cells["CustomerTable_Name"].Value = customer.Name; NewRow.Cells["CustomerTable_EmailId"].Value = customer.Email; NewRow.Cells["CustomerTable_MobileNumber"].Value = customer.MobileNumber; NewRow.Cells["CustomerTable_PendingAmount"].Value = customer.PendingAmount; }
private void InitializeLabels() { CustomerGet customer = m_TransactionSession.GetCustomer(); m_UIControl.lbl_CustomerName.Text = (customer == null) ? "--" : customer.Name; m_UIControl.lbl_Date.Text = DateTime.Now.ToString(); NumberFormatInfo indianCurrency = new CultureInfo("hi-IN", false).NumberFormat; indianCurrency.CurrencyPositivePattern = 2; m_UIControl.lbl_subtotal.Text = string.Format(indianCurrency, "{0:c}", double.Parse(m_TransactionSession.subtotal)); m_UIControl.lbl_amountDue.Text = string.Format(indianCurrency, "{0:c}", double.Parse(m_TransactionSession.amountDue)); m_UIControl.lbl_amountPaid.Text = string.Format(indianCurrency, "{0:c}", double.Parse(m_TransactionSession.amountPaid)); m_UIControl.lbl_pendingAmount.Text = string.Format(indianCurrency, "{0:c}", double.Parse(m_TransactionSession.pendingAmount)); }
private void HandleEvent_NewEntryAdded(Event_NewEntryAdded e) { DBEntityType entityType = e.GetEntityType(); int id = e.GetID(); if (entityType == DBEntityType.CUSTOMER) { CustomerGet customer = DataService.GetCustomerDataController().Get(id); m_Controller.AddCustomerToTable(customer); } else if (entityType == DBEntityType.TRANSACTION) { TransactionGet transaction = DataService.GetTransactionDataController().Get(id); m_Controller.UpdateCustomerInTable(transaction.Customer); } }
public void UpdateCustomer() { m_UIControl.lbl_customerErrorText.Text = string.Empty; if (!ValidateCustomerDetails()) { return; } string name = m_UIControl.tb_customerName.Text.Trim(); string mobileNumber = m_UIControl.tb_customerMobileNumber.Text.Trim(); if (CheckIfCustomerNameAlreadyExists(name)) { m_UIControl.lbl_customerErrorText.Text = "Customer with the same Name already exists!"; return; } if (CheckIfMobileNumberAlreadyExists(mobileNumber)) { m_UIControl.lbl_customerErrorText.Text = "Customer with the same Mobile Number already exists!"; return; } CustomerPost customerPost = new CustomerPost(); customerPost.ID = int.Parse(m_UIControl.tb_customerId.Text.Trim()); customerPost.Name = name; customerPost.MobileNumber = mobileNumber; customerPost.Email = m_UIControl.tb_customerEmail.Text.Trim();; customerPost.TotalAmount = double.Parse(m_UIControl.tb_customerTotalPurchaseAmount.Text.Trim()); customerPost.PendingAmount = double.Parse(m_UIControl.tb_customerPendingAmount.Text.Trim()); m_Customer = DataService.GetCustomerDataController().Put(customerPost); if (m_Customer == null) { m_UIControl.DialogResult = DialogResult.No; return; } m_UIControl.DialogResult = DialogResult.Yes; ResetTextBoxes(); // fire customer updated event Event_EntryUpdated e = new Event_EntryUpdated(DBEntityType.CUSTOMER, m_Customer.ID); EventBroadcaster.Get().BroadcastEvent(e); }
public CustomerGet DTOToProto(CustomerDTO customerDTO) { if (customerDTO != null) { CustomerGet customer = new CustomerGet { IdAddress = customerDTO.IdAddress.Value, Name = customerDTO.Name, Surname = customerDTO.Surname, Cpf = customerDTO.Cpf, Genre = customerDTO.Genre.ToString() }; return(customer); } return(null); }
public CustomerDTO ProtoToDTO(CustomerGet proto) { if (proto != null) { CustomerDTO customerDTO = new CustomerDTO { Id = proto.Id, IdAddress = proto.IdAddress, Name = proto.Name, Surname = proto.Surname, Cpf = proto.Cpf, Genre = proto.Genre.ToCharArray()[0] }; return(customerDTO); } return(null); }
public void AddNewCustomer() { m_UIControl.lbl_customerError.Text = string.Empty; Form_AddCustomer form = new Form_AddCustomer(); DialogResult result = form.ShowDialog(); if (result != DialogResult.Yes) { return; } MessageBox.Show("Customer Added Successfully!"); // fill the customer details CustomerGet customer = form.GetCustomer(); m_UIControl.tb_customerName.Text = customer.Name; m_UIControl.tb_mobileNumber.Text = customer.MobileNumber; m_UIControl.tb_pendingAmount.Text = customer.PendingAmount.ToString(); m_transactionSession.SetCustomer(customer); }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <param name="context"></param> /// <returns></returns> public override Task <CustomersGet> List(Empty request, ServerCallContext context) { CustomersGet protos = new CustomersGet(); var customers = _repositoryCustomer.List().ToList(); foreach (var customer in customers) { var proto = new CustomerGet { Id = customer.Id.Value, IdAddress = customer.IdAddress.Value, Name = customer.Name, Surname = customer.Surname, Cpf = customer.Cpf, Genre = customer.Genre.ToString() }; protos.Items.Add(proto); } return(Task.FromResult(protos)); }
public void SaveCustomer() { m_UIControl.lbl_customerErrorText.Text = string.Empty; if (!ValidateCustomerDetails()) { return; } CustomerPost customerPost = new CustomerPost(); customerPost.Email = m_UIControl.tb_customerEmail.Text.Trim(); customerPost.Name = m_UIControl.tb_CustomerName.Text.Trim(); customerPost.MobileNumber = m_UIControl.tb_customerMobile.Text.Trim(); customerPost.PendingAmount = 0; m_Customer = DataService.GetCustomerDataController().Post(customerPost); m_UIControl.DialogResult = (m_Customer == null) ? DialogResult.No : DialogResult.Yes; // fire customer added event Event_NewEntryAdded e = new Event_NewEntryAdded(DBEntityType.CUSTOMER, m_Customer.ID); EventBroadcaster.Get().BroadcastEvent(e); }
private bool CheckIfMobileNumberAlreadyExists(string mobileNumber) { CustomerGet customer = DataService.GetCustomerDataController().GetByMobileNumber(mobileNumber); return(customer != null && customer.ID != m_Customer.ID); }
private bool CheckIfCustomerNameAlreadyExists(string name) { CustomerGet customer = DataService.GetCustomerDataController().GetByName(name); return(customer != null && customer.ID != m_Customer.ID); }
private void Initialize(int customerID) { m_Customer = DataService.GetCustomerDataController().Get(customerID); InitializeProductDetails(customerID); }
public TransactionSession() { m_RowEntries = new List <BillProductDetails>(); m_Customer = new CustomerGet(); }
public void SetCustomer(CustomerGet customer) { m_Customer = customer; }