private void buttonExport_Click(object sender, EventArgs e) { DateTime dateTime = dateTimePickerDate.Value.Date; DataTable dataTable = new Controllers.ProductDAO().GetReportOutputByDate(dateTime); if (dataTable != null && dataTable.Rows.Count > 0) { try { var newFile = new FileInfo("Output_" + dateTime.ToString("yyyyMMdd") + ".xlsx"); using (ExcelPackage pck = new ExcelPackage(newFile)) { ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Accounts"); ws.Cells["A1"].LoadFromDataTable(dataTable, true); pck.Save(); } MessageBox.Show("Xuất file thành công"); } catch { } } else { MessageBox.Show("Không có dữ liệu để xuất file."); } }
private void buttonCustomerRepaid_Click(object sender, EventArgs e) { DataTable dt = Utils.Utils.GetDataTableFromDGV(dgvProductList); if (dt != null && dt.Rows.Count > 0) { ProductDAO productDAO = new Controllers.ProductDAO(); long inputvoucherid = productDAO.InputVoucherAdd(1, 2); if (inputvoucherid < 0) { MessageBox.Show("Có lỗi trong quá kết nối dữ liệu để tạo phiếu nhập. Vui lòng tắt app mở lại hoặc liên hệ it."); return; } bool result = productDAO.InputVoucherDetailAdd(dt, inputvoucherid); if (!result) { MessageBox.Show("Không thể tạo phiếu xuất. Liên hệ it để biết chi tiết"); return; } else { MessageBox.Show("Tạo phiếu xuất thành công"); } dgvProductList.Rows.Clear(); intStep = 1; } }
private void btnSua_Click(object sender, EventArgs e) { if (curProductBO == null) { MessageBox.Show("Mã sản phẩm hiện tại không hợp lệ"); return; } double dbSellPrice = -1; if (string.IsNullOrEmpty(textBoxRetailPriceEdit.Text) || !double.TryParse(textBoxRetailPriceEdit.Text, out dbSellPrice)) { MessageBox.Show("Giá bán không hợp lệ"); return; } bool result = new Controllers.ProductDAO().UpdateProductSellPrice(curProductBO.ProductID, dbSellPrice); if (!result) { MessageBox.Show("Có lỗi trong quá trình thêm dữ liệu"); return; } else { MessageBox.Show("Cập nhật thành công"); } textBoxProductIDEditPrice.Text = ""; labelProductNameEdit.Text = ""; textBoxRetailPriceEdit.Text = "-1"; }
private void InventoryToolStripMenuItem_Click(object sender, EventArgs e) { DataTable dataTable = new Controllers.ProductDAO().GetInventory(); if (dataTable != null && dataTable.Rows.Count > 0) { try { var newFile = new FileInfo("Inventory_" + DateTime.Now.ToString("yyyyMMdd") + ".xlsx"); if (newFile.Exists) { newFile.Delete(); } using (ExcelPackage pck = new ExcelPackage(newFile)) { ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Accounts"); ws.Cells["A1"].LoadFromDataTable(dataTable, true); pck.Save(); } MessageBox.Show("Xuất file thành công"); } catch (Exception objEx) { } } else { MessageBox.Show("Không có dữ liệu để xuất file."); } }
private void btnThemMoi_Click(object sender, EventArgs e) { long outputvoucherid = new Controllers.ProductDAO().OutputVoucherAdd(1, 2); //Xuất huỷ tại siêu thị if (outputvoucherid < 0) { MessageBox.Show("Có lỗi trong quá kết nối dữ liệu để tạo phiếu nhập. Vui lòng tắt app mở lại hoặc liên hệ it."); } string productid = ""; double quantity = 0; double retailprice = 0; if (string.IsNullOrEmpty(textBoxBarCode.Text)) { MessageBox.Show("Mã sản phẩm không đúng"); return; } productid = textBoxBarCode.Text.Trim(); if (!double.TryParse(textBoxQuantity.Text, out quantity)) { MessageBox.Show("Số lượng nhập không hợp lệ"); return; } long inputvoucerdetailid = new Controllers.ProductDAO().OutputVoucherDetailAdd(productid, outputvoucherid, quantity, retailprice); if (inputvoucerdetailid < 0) { MessageBox.Show("Có lỗi trong quá kết nối dữ liệu để tạo phiếu nhập. Vui lòng tắt app mở lại hoặc liên hệ it."); return; } else { MessageBox.Show("Xuất huỷ thành công."); } textBoxBarCode.Text = ""; textBoxQuantity.Text = "0"; }
private void btnThemMoi_Click(object sender, EventArgs e) { string strBarcode = txtbarcode.Text; string strproductname = txproductname.Text; double dbSellPrice = -1; if (string.IsNullOrEmpty(strBarcode)) { MessageBox.Show("Mã barcode không hợp lệ"); return; } if (string.IsNullOrEmpty(textBoxSellPrice.Text) || !double.TryParse(textBoxSellPrice.Text, out dbSellPrice)) { MessageBox.Show("Giá bán không hợp lệ"); return; } if (string.IsNullOrEmpty(strproductname)) { MessageBox.Show("Tên sản phẩm không hợp lệ"); return; } int result = new Controllers.ProductDAO().AddProduct(strBarcode, strproductname, dbSellPrice); if (result != 0) { MessageBox.Show("Có lỗi trong quá trình thêm dữ liệu"); return; } MessageBox.Show("Thêm sản phẩm thành công"); txtbarcode.Text = ""; txproductname.Text = ""; textBoxSellPrice.Text = "-1"; }