private void loadCourierCombo(DirectSalesModel directSales) { conDB = new ConnectionDB(); CourierModel courier = new CourierModel(); string queryString = "SELECT ID, couriername, description FROM dbfh.tblcourier WHERE isDeleted = 0"; MySqlDataReader reader = conDB.getSelectConnection(queryString, null); cmbCourier.Items.Clear(); while (reader.Read()) { courier.ID = reader["ID"].ToString(); courier.CourierName = reader["couriername"].ToString(); courier.Description = reader["description"].ToString(); cmbCourier.Items.Add(courier); if (directSales.CourierID.Equals(courier.ID)) { cmbCourier.SelectedItem = courier; } courier = new CourierModel(); } conDB.closeConnection(); }
private void btnEdit_Click(object sender, RoutedEventArgs e) { selected = dgvDirectSales.SelectedItem as DirectSalesModel; if (selected != null) { //DirectSalesDetails ds = new DirectSalesDetails(this, selected); // ds.ShowDialog(); btnSave.Visibility = Visibility.Hidden; btnUpdate.Visibility = Visibility.Visible; deliveryDateDS.Text = selected.DeliveryDate; txtClientName.Text = selected.ClientName; txtQuantity.Text = selected.Quantity; txtExpenses.Text = selected.Expenses.ToString(); txtTotalPrice.Text = selected.TotalPrice.ToString(); foreach (BankModel bnk in cmbCashBank.Items) { if (bnk.ID.Equals(selected.CashBankID)) { cmbCashBank.SelectedItem = bnk; } } foreach (CourierModel cour in cmbCourier.Items) { if (cour.ID.Equals(selected.CourierID)) { cmbCourier.SelectedItem = cour; } } } }
private void loadCashBankonCombo(DirectSalesModel directSales) { conDB = new ConnectionDB(); BankModel bankCash = new BankModel(); string queryString = "SELECT ID, bankname, description FROM dbfh.tblbank WHERE isDeleted = 0"; MySqlDataReader reader = conDB.getSelectConnection(queryString, null); cmbCashBank.Items.Clear(); while (reader.Read()) { bankCash.ID = reader["ID"].ToString(); bankCash.BankName = reader["bankname"].ToString(); bankCash.Description = reader["description"].ToString(); cmbCashBank.Items.Add(bankCash); if (directSales.CashBankID.Equals(bankCash.ID)) { cmbCashBank.SelectedItem = bankCash; } bankCash = new BankModel(); } conDB.closeConnection(); }
private void loadCourierCombo(DirectSalesModel directSales) { try { conDB = new ConnectionDB(); CourierModel courier = new CourierModel(); string queryString = "SELECT ID, couriername, description FROM dbfh.tblcourier WHERE isDeleted = 0"; MySqlDataReader reader = conDB.getSelectConnection(queryString, null); cmbCourier.Items.Clear(); while (reader.Read()) { courier.ID = reader["ID"].ToString(); courier.CourierName = reader["couriername"].ToString(); courier.Description = reader["description"].ToString(); cmbCourier.Items.Add(courier); if (directSales.CourierID.Equals(courier.ID)) { cmbCourier.SelectedItem = courier; } courier = new CourierModel(); } conDB.closeConnection(); } catch (Exception ex) { conDB.writeLogFile("LOAD COURIER ON COMBO" + "-" + ex.Message.ToString() + "||" + ex.StackTrace); } }
private void btnEditDirectSales_Click(object sender, RoutedEventArgs e) { conDB = new ConnectionDB(); selected = dgvDirectSales.SelectedItem as DirectSalesModel; lstProductModel = new List <ProductModel>(); try { if (selected != null) { //DirectSalesDetails ds = new DirectSalesDetails(this, selected); // ds.ShowDialog(); btnSave.Visibility = Visibility.Hidden; btnUpdate.Visibility = Visibility.Visible; deliveryDateDS.Text = selected.DeliveryDate; txtClientName.Text = selected.ClientName; txtExpenses.Text = selected.Expenses.ToString(); txtTotalPrice.Text = selected.TotalPrice.ToString(); ifEdit = true; txtRemarks.Text = selected.Remarks; loadCashBankonCombo(selected); loadCourierCombo(selected); loadProductsOnList(selected.ID); loadOfficeSalesCombo(selected); chkPaid.IsChecked = selected.Paid; dgvDirectSales.IsEnabled = false; } } catch (Exception ex) { conDB.writeLogFile(ex.Message.ToString() + "-" + "Edit Direct sales clicked!" + "-" + ex.StackTrace); } }
private void loadCashBankonCombo(DirectSalesModel directSales) { try { conDB = new ConnectionDB(); BankModel bankCash = new BankModel(); string queryString = "SELECT ID, bankname, description FROM dbfh.tblbank WHERE isDeleted = 0"; MySqlDataReader reader = conDB.getSelectConnection(queryString, null); cmbCashBank.Items.Clear(); while (reader.Read()) { bankCash.ID = reader["ID"].ToString(); bankCash.BankName = reader["bankname"].ToString(); bankCash.Description = reader["description"].ToString(); cmbCashBank.Items.Add(bankCash); if (directSales.CashBankID.Equals(bankCash.ID)) { cmbCashBank.SelectedItem = bankCash; } bankCash = new BankModel(); } conDB.closeConnection(); } catch (Exception ex) { conDB.writeLogFile("LOAD CASH BANK ON COMBO" + "-" + ex.Message + "||" + ex.StackTrace); } }
private List <DirectSalesModel> search() { conDB = new ConnectionDB(); List <DirectSalesModel> lstDirectSales = new List <DirectSalesModel>(); DirectSalesModel directSales = new DirectSalesModel(); string queryString = "SELECT dbfh.tbldirectsales.ID, clientname, quantity, cashbankID, bankname, courierID, " + "couriername, totalprice, deliverydate, expenses FROM((dbfh.tbldirectsales INNER JOIN dbfh.tblbank ON " + "dbfh.tbldirectsales.cashbankID = dbfh.tblbank.ID) INNER JOIN dbfh.tblcourier ON " + "dbfh.tbldirectsales.courierID = dbfh.tblcourier.ID) WHERE dbfh.tbldirectsales.isDeleted = 0 AND dbfh.tbldirectsales.salestypeID = 2"; List <string> parameters = new List <string>(); if (checkDate.IsChecked == true) { queryString += " AND (deliverydate BETWEEN ? AND ?)"; DateTime sdate = DateTime.Parse(searchDateFrom.Text); parameters.Add(sdate.Year + "/" + sdate.Month + "/" + sdate.Day); sdate = DateTime.Parse(searchDateTo.Text); parameters.Add(sdate.Year + "/" + sdate.Month + "/" + sdate.Day); } if (checkClient.IsChecked == true) { queryString += " AND (clientname LIKE '%" + searchClient.Text + "%')"; } if (checkBank.IsChecked == true) { queryString += " AND (dbfh.tbldirectsales.cashbankID = ?)"; parameters.Add(searchBank.SelectedValue.ToString()); } MySqlDataReader reader = conDB.getSelectConnection(queryString, parameters); while (reader.Read()) { directSales.ID = reader["ID"].ToString(); directSales.ClientName = reader["clientname"].ToString(); directSales.Quantity = reader["quantity"].ToString(); directSales.CashBankID = reader["cashbankID"].ToString(); directSales.CashBankName = reader["bankname"].ToString(); directSales.CourierID = reader["courierID"].ToString(); directSales.CourierName = reader["couriername"].ToString(); directSales.TotalPrice = Convert.ToInt32(reader["totalprice"].ToString()); DateTime dte = DateTime.Parse(reader["deliveryDate"].ToString()); directSales.DeliveryDate = dte.ToShortDateString(); directSales.Expenses = Convert.ToInt32(reader["expenses"].ToString()); lstDirectSales.Add(directSales); directSales = new DirectSalesModel(); } conDB.closeConnection(); lblRecords.Content = lstDirectSales.Count + " RECORDS FOUND."; return(lstDirectSales); }
private List <DirectSalesModel> loadDataGridDetailsDirectSales() { conDB = new ConnectionDB(); List <DirectSalesModel> lstDirectSales = new List <DirectSalesModel>(); DirectSalesModel directSales = new DirectSalesModel(); string queryString = "SELECT dbfh.tbldirectsales.ID, clientname, quantity, cashbankID, bankname, courierID, " + "couriername, totalprice, deliverydate, expenses, officeID, remarks, isPaid FROM ((dbfh.tbldirectsales INNER JOIN dbfh.tblbank ON " + "dbfh.tbldirectsales.cashbankID = dbfh.tblbank.ID) INNER JOIN dbfh.tblcourier ON " + "dbfh.tbldirectsales.courierID = dbfh.tblcourier.ID) WHERE dbfh.tbldirectsales.salestypeID = 1 AND dbfh.tbldirectsales.isDeleted = 0 ORDER BY deliverydate DESC"; MySqlDataReader reader = conDB.getSelectConnection(queryString, null); while (reader.Read()) { directSales.ID = reader["ID"].ToString(); directSales.ClientName = reader["clientname"].ToString(); directSales.Quantity = reader["quantity"].ToString(); directSales.CashBankID = reader["cashbankID"].ToString(); directSales.CashBankName = reader["bankname"].ToString(); directSales.CourierID = reader["courierID"].ToString(); directSales.CourierName = reader["couriername"].ToString(); directSales.TotalPrice = Convert.ToInt32(reader["totalprice"].ToString()); directSales.OfficeSalesID = reader["officeID"].ToString(); DateTime dte = DateTime.Parse(reader["deliveryDate"].ToString()); directSales.DeliveryDate = dte.ToShortDateString(); directSales.Expenses = Convert.ToInt32(reader["expenses"].ToString()); directSales.Remarks = reader["remarks"].ToString(); directSales.isPaid = reader["isPaid"].ToString(); if (directSales.isPaid.Equals("1")) { directSales.Paid = true; } else { directSales.Paid = false; } lstDirectSales.Add(directSales); directSales = new DirectSalesModel(); } conDB.closeConnection(); lblRecords.Content = lstDirectSales.Count + " RECORDS FOUND."; return(lstDirectSales); }
private async void btnDelete_Click(object sender, RoutedEventArgs e) { MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow; MessageDialogResult result = await window.ShowMessageAsync("Delete Record", "Are you sure you want to delete record?", MessageDialogStyle.AffirmativeAndNegative); if (result == MessageDialogResult.Affirmative) { DirectSalesModel dsm = dgvDirectSales.SelectedItem as DirectSalesModel; if (dsm != null) { //deleteRecord(dsm.ID); //dgvDirectSales.ItemsSource = loadDataGridDetailsDirectSales(); dgvDirectSales.Items.Refresh(); } } }
private void btnEditDirectSales_Click(object sender, RoutedEventArgs e) { selected = dgvDirectSales.SelectedItem as DirectSalesModel; if (selected != null) { //DirectSalesDetails ds = new DirectSalesDetails(this, selected); // ds.ShowDialog(); btnSave.Visibility = Visibility.Hidden; btnUpdate.Visibility = Visibility.Visible; deliveryDateDS.Text = selected.DeliveryDate; txtClientName.Text = selected.ClientName; txtQuantity.Text = selected.Quantity; txtExpenses.Text = selected.Expenses.ToString(); txtTotalPrice.Text = selected.TotalPrice.ToString(); loadCashBankonCombo(selected); loadCourierCombo(selected); } }
private void updateDirectSalesRecord(DirectSalesModel directSalesModel) { conDB = new ConnectionDB(); string queryString = "UPDATE dbfh.tbldirectsales SET deliverydate = ?, clientname = ?, quantity = ?, cashbankID = ?, " + "courierID = ?, expenses = ?, totalprice = ? WHERE ID = ?"; List <string> parameters = new List <string>(); DateTime date = DateTime.Parse(deliveryDateDS.Text); parameters.Add(date.Year + "/" + date.Month + "/" + date.Day); parameters.Add(txtClientName.Text); parameters.Add(txtQuantity.Text); parameters.Add(cmbCashBank.SelectedValue.ToString()); parameters.Add(cmbCourier.SelectedValue.ToString()); parameters.Add(txtExpenses.Text); parameters.Add(txtTotalPrice.Text); parameters.Add(directSalesModel.ID); conDB.AddRecordToDatabase(queryString, parameters); conDB.closeConnection(); }
private void updateDirectSalesRecord(DirectSalesModel directSalesModel) { conDB = new ConnectionDB(); BankModel bb = cmbCashBank.SelectedItem as BankModel; CourierModel cc = cmbCourier.SelectedItem as CourierModel; string queryString = "UPDATE dbfh.tbldirectsales SET deliverydate = ?, clientname = ?, cashbankID = ?, " + "courierID = ?, expenses = ?, totalprice = ?, officeID = ?, remarks = ?, isPaid = ? WHERE ID = ?"; List <string> parameters = new List <string>(); DateTime date = DateTime.Parse(deliveryDateDS.Text); parameters.Add(date.Year + "/" + date.Month + "/" + date.Day); parameters.Add(txtClientName.Text); parameters.Add(bb.ID); parameters.Add(cc.ID); parameters.Add(txtExpenses.Text); parameters.Add(txtTotalPrice.Text); parameters.Add(cmbSalesOffice.SelectedValue.ToString()); parameters.Add(txtRemarks.Text); if (chkPaid.IsChecked.Value) { parameters.Add("1"); } else { parameters.Add("0"); } parameters.Add(directSalesModel.ID); conDB.AddRecordToDatabase(queryString, parameters); conDB.closeConnection(); }
private void loadOfficeSalesCombo(DirectSalesModel dsm) { try { conDB = new ConnectionDB(); SalesOfficeModel office = new SalesOfficeModel(); string queryString = "SELECT ID, officename, description FROM dbfh.tblsalesoffice WHERE isDeleted = 0"; MySqlDataReader reader = conDB.getSelectConnection(queryString, null); cmbSalesOffice.Items.Clear(); while (reader.Read()) { office.ID = reader["ID"].ToString(); office.OfficeName = reader["officename"].ToString(); office.Description = reader["description"].ToString(); cmbSalesOffice.Items.Add(office); office = new SalesOfficeModel(); } foreach (SalesOfficeModel so in cmbSalesOffice.Items) { if (dsm.OfficeSalesID.Equals(so.ID)) { cmbSalesOffice.SelectedItem = so; } } conDB.closeConnection(); } catch (Exception ex) { conDB.writeLogFile("LOAD SALES OFFICE COMBO" + "-" + ex.StackTrace + " || " + ex.Message); } }
private List <DirectSalesModel> loadDataGridDetailsDirectSales() { conDB = new ConnectionDB(); List <DirectSalesModel> lstDirectSales = new List <DirectSalesModel>(); DirectSalesModel directSales = new DirectSalesModel(); string queryString = "SELECT dbfh.tbldirectsales.ID, clientname, quantity, cashbankID, bankname, courierID, " + "couriername, totalprice, deliverydate, expenses FROM((dbfh.tbldirectsales INNER JOIN dbfh.tblbank ON " + "dbfh.tbldirectsales.cashbankID = dbfh.tblbank.ID) INNER JOIN dbfh.tblcourier ON " + "dbfh.tbldirectsales.courierID = dbfh.tblcourier.ID) WHERE dbfh.tbldirectsales.isDeleted = 0"; MySqlDataReader reader = conDB.getSelectConnection(queryString, null); while (reader.Read()) { directSales.ID = reader["ID"].ToString(); directSales.ClientName = reader["clientname"].ToString(); directSales.Quantity = reader["quantity"].ToString(); directSales.CashBankID = reader["cashbankID"].ToString(); directSales.CashBankName = reader["bankname"].ToString(); directSales.CourierID = reader["courierID"].ToString(); directSales.CourierName = reader["couriername"].ToString(); directSales.TotalPrice = Convert.ToInt32(reader["totalprice"].ToString()); DateTime dte = DateTime.Parse(reader["deliveryDate"].ToString()); directSales.DeliveryDate = dte.ToShortDateString(); directSales.Expenses = Convert.ToInt32(reader["expenses"].ToString()); lstDirectSales.Add(directSales); directSales = new DirectSalesModel(); } conDB.closeConnection(); return(lstDirectSales); }
public DirectSalesDetails(FHSales.views.FHBoxes f, DirectSalesModel dm) { fhBoxes = f; directSalesModel = dm; InitializeComponent(); }