private void btn_Create_Click(object sender, EventArgs e) { if (date_In.DateTime.Year == 0001) { MessageBox.Show("Chọn ngày nhập", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ReceiptNote dn = new ReceiptNote(); dn.StorageID = Convert.ToInt64(cb_Storage.SelectedValue); dn.ReceiptDate = date_In.DateTime; dn.EmployeeID = MainForm.UserID; dn.Status = 0; var res = new ReceiptNoteDAO().Insert(dn); if (res != 0) { MessageBox.Show("Thêm thành công phiếu nhập ! Mời thêm chi tiết phiếu", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); gridControl1.Enabled = true; btn_ThemChiTietNhap.Enabled = true; btn_Finish.Enabled = true; Itemdetail.ReceiptNoteID = res; } }
private void ThemChiTietNhap_Closed(object sender, FormClosedEventArgs e) { var dao = new ReceiptNoteDAO(); dao.InsertDetail(Itemdetail); gridControl1.DataSource = dao.GetDetail(Itemdetail.ReceiptNoteID); new ReceiptNoteDAO().Amount(Itemdetail.ReceiptNoteID); }
private void btn_XoaChiTietNhap_Click(object sender, EventArgs e) { DialogResult rs = MessageBox.Show("Bạn muốn xóa chi tiết phiếu ?", "Xóa", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (rs == DialogResult.OK) { var dao = new ReceiptNoteDAO(); dao.DeleteDetail(Convert.ToInt32(gridView1.GetFocusedRowCellValue("ID").ToString())); gridControl1.DataSource = dao.GetDetail(Itemdetail.ReceiptNoteID); if (dao.GetDetail(Itemdetail.ReceiptNoteID).Count == 0) { btn_XoaChiTietNhap.Enabled = false; } } }
void LoadData() { var item = new ReceiptNoteDAO().GetNote().SingleOrDefault(x => x.ID == YeuCauNhap.Itemdetail.ReceiptNoteID); ReportParameter ID = new ReportParameter("IDP", item.ID.ToString()); ReportParameter StorageName = new ReportParameter("StorageName", item.StorageName.ToString()); ReportParameter EmployeeName = new ReportParameter("EmployeeName", item.EmployeeName.ToString()); ReportParameter ReceiptDate = new ReportParameter("ReceiptDate", item.ReceiptDate.Value.ToString("dd/MM/yyyy")); ReportParameter Amount = new ReportParameter("Amount", item.Amount.ToString() + "đ"); ReportDataSource rds = new ReportDataSource("DS_YCNhap", new ReceiptNoteDAO().GetDetail(YeuCauNhap.Itemdetail.ReceiptNoteID)); this.reportViewer1.LocalReport.DataSources.Add(rds); this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { ID, StorageName, EmployeeName, ReceiptDate, Amount }); this.reportViewer1.LocalReport.Refresh(); this.reportViewer1.RefreshReport(); }