public void Delete(String id) { BUS_InventoryImportDetail importDetail = new BUS_InventoryImportDetail(); BUS_InventoryImport import = new BUS_InventoryImport(); importDetail.Delete(id); import.Delete(id); LoadData(); }
public Dictionary <String, int> loadAllMaterialName(String importID) { Dictionary <String, int> result = new Dictionary <string, int>(); BUS_InventoryImport import = new BUS_InventoryImport(); DataTable temp = import.SelectAllMaterialNameFromDetail(importID); foreach (DataRow row in temp.Rows) { String name = row["MaterialName"].ToString(); String amount = row["Amount"].ToString(); result[name] = int.Parse(amount); } return(result); }
private void btSave_Click(object sender, RoutedEventArgs e) { dataGridMaterialImport.Items.Refresh(); BUS_InventoryImport import = new BUS_InventoryImport(); String newImportID = import.Create(tbEmployeeName.Text, tbDate.Text); if (newImportID == null) { return; } List <String> sqlString = new List <string>(); if (list.Count.Equals(0)) { MessageBox.Show($"Danh sách nguyên vật liệu, thiết bị không được để trống!"); return; } foreach (InventoryImportDetailObject obj in list) { int temp1 = -1, temp2 = -1; if (!int.TryParse(obj.unitPrice, out temp1) || temp1 <= 0 || obj.unitPrice == "" || obj.unitPrice == null) { MessageBox.Show($"Đơn giá của {obj.name} không hợp lệ!"); import.Delete(newImportID); return; } else if (!int.TryParse(obj.amount, out temp2) || temp2 <= 0) { MessageBox.Show($"Số lượng của {obj.name} không hợp lệ!"); import.Delete(newImportID); return; } string temp = $"insert into InventoryImportDetail values ('{newImportID}','{obj.id}','{obj.amount}','{obj.unitPrice}')"; sqlString.Add(temp); } BUS_InventoryImportDetail detail = new BUS_InventoryImportDetail(); detail.ImportList(sqlString); var screen = new InventoryImport(_context); if (screen != null) { this._context.StackPanelMain.Children.Clear(); this._context.StackPanelMain.Children.Add(screen); } }
public void LoadData() { btBack.IsEnabled = false; username = _context.GetCurrentEmpName(); mainList.Clear(); BUS_InventoryImport import = new BUS_InventoryImport(); DataTable temp = import.selectAll(); foreach (DataRow row in temp.Rows) { string employid = row["EmployeeName"].ToString(); string id = row["importID"].ToString(); string date = row["importDate"].ToString(); mainList.Add(new InventoryImportObject() { ID = id, EmployName = employid, InventoryDate = date }); } BUS_Parameter busParameter = new BUS_Parameter(); int rowPerSheet = busParameter.GetValue("RowInList"); if (mainList.Count % rowPerSheet == 0) { lblMaxPage.Content = mainList.Count / rowPerSheet; } else { lblMaxPage.Content = mainList.Count / rowPerSheet + 1; } if (int.Parse(lblMaxPage.Content.ToString()) == 0) { this.tbNumPage.Text = "0"; } if (int.Parse(lblMaxPage.Content.ToString()) < 2) { btNext.IsEnabled = false; } splitDataGrid(page); }
public void LoadData() { var list = new ObservableCollection <InventoryImportDetailObject>(); BUS_InventoryImport import = new BUS_InventoryImport(); DataTable temp = import.selectDetail(selectionID); Console.WriteLine(temp.Rows.Count); foreach (DataRow row in temp.Rows) { string name = row["Tên"].ToString(); string amount = row["Số lượng"].ToString(); string unitprice = row["Đơn giá"].ToString(); string unit = row["Đơn vị tính"].ToString(); int tongtien = int.Parse(amount) * int.Parse(unitprice); list.Add(new InventoryImportDetailObject() { amount = amount, name = name, unit = unit, totalCost = tongtien.ToString(), unitPrice = unitprice }); } this.dataGridMaterialImport.ItemsSource = list; this.tbTotalImportCost.Text = import.TotalCost(selectionID).ToString(); }
private void LoadGeneralChartYear() { GeneralChart = new SeriesCollection(); LabelGeneralCharts = new List <string>(); ChartValues <int> Income = new ChartValues <int>(); ChartValues <int> Outcome = new ChartValues <int>(); ChartValues <int> Profit = new ChartValues <int>(); for (int i = 0; i < months; i++) { LabelGeneralCharts.Add("Tháng " + (i + 1)); Income.Add(0); Outcome.Add(0); Profit.Add(0); } BUS_Receipt busRec = new BUS_Receipt(); DataTable RecData = busRec.GetTotalIncomeByYear(dpMonthYear.SelectedDate.GetValueOrDefault().Year); foreach (DataRow row in RecData.Rows) { Income[Int32.Parse(row["Month"].ToString()) - 1] = Int32.Parse(row["TotalAfterDis"].ToString()); Profit[Int32.Parse(row["Month"].ToString()) - 1] += Int32.Parse(row["TotalAfterDis"].ToString()); } BUS_InventoryImport busInvImp = new BUS_InventoryImport(); DataTable InvImpData = busInvImp.GetTotalAmountByYear(dpMonthYear.SelectedDate.GetValueOrDefault().Year); foreach (DataRow row in InvImpData.Rows) { Outcome[Int32.Parse(row["Month"].ToString()) - 1] = Int32.Parse(row["TotalAmount"].ToString()); Profit[Int32.Parse(row["Month"].ToString()) - 1] -= Int32.Parse(row["TotalAmount"].ToString()); } BUS_Payment busPay = new BUS_Payment(); DataTable PayData = busPay.GetTotalAmountByYear(dpMonthYear.SelectedDate.GetValueOrDefault().Year); foreach (DataRow row in PayData.Rows) { Outcome[Int32.Parse(row["Month"].ToString()) - 1] += Int32.Parse(row["Total"].ToString()); Profit[Int32.Parse(row["Month"].ToString()) - 1] -= Int32.Parse(row["Total"].ToString()); } GeneralChart.Add(new ColumnSeries { Title = "Doanh thu ", Values = Income, MaxColumnWidth = 16 }); GeneralChart.Add(new ColumnSeries { Title = "Chi phí", Values = Outcome, MaxColumnWidth = 16 }); GeneralChart.Add(new ColumnSeries { Title = "Lợi nhuận", Values = Profit, MaxColumnWidth = 16 }); //FormatterGeneralCharts = value => value.ToString("N"); generalChart.AxisX.Clear(); generalChart.AxisX.Add(new Axis { Title = "", LabelFormatter = value => "Tháng " + (value + 1).ToString(), FontSize = 15, Foreground = (SolidColorBrush) new BrushConverter().ConvertFromString("#6B6158") }); generalChart.Series = GeneralChart; generalChart.Width = LabelGeneralCharts.Count * 80; generalChartTitle.Text = $"Biểu đồ thống kê tổng quát năm {dpMonthYear.SelectedDate.GetValueOrDefault().Year}"; }