private void btnSave_Click(object sender, EventArgs e) { decimal decTongTienTra = 0; if (itemDonHang == null) { MessageBox.Show("Chưa tìm thấy đơn hàng cần trả"); return; } List <TraHangChiTiet> ListTraHang = new List <TraHangChiTiet>(); if ((tblDS == null) || (tblDS.Rows.Count == 0)) { MessageBox.Show("Chưa tìm thấy đơn hàng cần trả"); return; } else { foreach (DataRow item in tblDS.Rows) { TraHangChiTiet newitem = new TraHangChiTiet(); newitem.SanPhamID = item["SanPhamID"].ToString(); int intSoLuongBan = 0; int.TryParse(item["SoLuong"].ToString(), out intSoLuongBan); newitem.SoLuongBan = intSoLuongBan; int intSoLuongTra = 0; int.TryParse(item["SLTraLai"].ToString(), out intSoLuongTra); newitem.SoLuongTra = intSoLuongTra; newitem.TenSanPham = item["TenSanPham"].ToString(); decimal decDonGia = 0; decimal.TryParse(item["DonGia"].ToString(), out decDonGia); newitem.DonGia = decDonGia; decimal decDonGiaTra = 0; decimal.TryParse(item["DonGiaTra"].ToString(), out decDonGiaTra); newitem.DonGiaTra = decDonGiaTra; decTongTienTra += decDonGiaTra * intSoLuongTra; ListTraHang.Add(newitem); } } TraHangItem = new TraHang(); TraHangItem.DonHangID = txtDonHangID.Text; TraHangItem.NgayTra = DateTime.Now; TraHangItem.NgayBan = itemDonHang.NgayBan; TraHangItem.KhachHangID = itemDonHang.KhachHangID; TraHangItem.TenKhachHang = itemDonHang.TenKhachHang; TraHangItem.NhanVienID = Utility.NguoiSuDung.NguoiDungID; TraHangItem.TenNhanVien = Utility.NguoiSuDung.TenNguoiDung; TraHangItem.GhiChu = txtGhiChu.Text; TraHangItem.TongTienTra = decTongTienTra; using (TransactionScope TScope = new TransactionScope()) { TraHangController.Add(TraHangItem, ListTraHang); QuyTienMatController.XuatQuyTienMat(TraHangItem.TraHangID, TraHangItem.NgayTra, decTongTienTra, "RT", "Khách trả lại hàng"); btnSave.Enabled = false; MessageBox.Show("Đã ghi thành công"); TScope.Complete(); } }
private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { gridControl2.DataSource = null; int intSelectRow = gridView1.FocusedRowHandle; if ((intSelectRow >= 0) && (intSelectRow < gridView1.RowCount)) { string strDonHangID = gridView1.GetRowCellValue(intSelectRow, "TraHangID").ToString(); gridControl2.DataSource = TraHangController.GetDetails(strDonHangID); bandedGridView1.BestFitColumns(); } }
private void simpleButton4_Click(object sender, EventArgs e) { gridControl1.DataSource = TraHangController.GetListRangDate(dateEditStart.DateTime, dateEditEnd.DateTime); gridView1.BestFitColumns(); }