private void btnLuu_Click(object sender, EventArgs e) { if (dpNgayLap.EditValue == null) { CheckLoi(lbNgayLap.Text); dpNgayLap.Focus(); } if (lkNhanVien.EditValue == null) { CheckLoi(lkNhanVien.Text); lkNhanVien.Focus(); } if (lkKhachHang.EditValue == null) { CheckLoi(lkKhachHang.Text); lkKhachHang.Focus(); } bill bl = new bill(); bl.created = (DateTime)dpNgayLap.EditValue; bl.id = txtMaHoaDon.Text; bl.type = "bg"; customer c = (customer)lkKhachHang.GetSelectedDataRow(); staff s = (staff)lkNhanVien.GetSelectedDataRow(); bl.customer = c; bl.staff = s; if (busHoaDon.Save()) { XtraMessageBox.Show("Lưu thành công", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); btnDanhMucLamMoi.PerformClick(); txtMaHoaDon.Text = txtTongTien.Text = txtThue.Text = txtThanhToan.Text = null; dpNgayLap.EditValue = DateTime.Now; lkKhachHang.EditValue = lkNhanVien.EditValue = null; panelControl4.Enabled = false; } else { XtraMessageBox.Show("Lưu thất bại", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } }
public object GetProduct(bill b) { try { var bd = from d in b.bill_details select d; return bd; } catch(Exception ex) { throw ex; } }
private void gvPhieuBaoGia_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { if (gvPhieuBaoGia.SelectedRowsCount != 1) return; b = (bill)gvPhieuBaoGia.GetFocusedRow(); txtMaHoaDon.Text = b.id; dpNgayLap.EditValue = b.created; lkKhachHang.EditValue = b.customer_id; lkNhanVien.EditValue = b.staff_id; btnLuu.Enabled = btnHuy.Enabled = btnThemKhachHang.Enabled = false; }
public bool KiemTraTonTai(bill bl, product sp) { try { var p = from b in bl.bill_details where b.product_id.Equals(sp.id) select b; return p.Count() == 1; } catch (Exception ex) { throw ex; } }
public bool Update(bill pbill) { try { pbill.modified = DateTime.Now; db.SubmitChanges(); return true; } catch(Exception ex) { throw ex; } }
partial void Deletebill(bill instance);
public bool Insert(bill pbill) { try { db.bills.InsertOnSubmit(pbill); db.SubmitChanges(); return true; } catch(Exception ex) { throw ex; //return false; } }
partial void Updatebill(bill instance);
partial void Insertbill(bill instance);
private void detach_bills(bill entity) { this.SendPropertyChanging(); entity.customer = null; }
private void attach_bills(bill entity) { this.SendPropertyChanging(); entity.customer = this; }
private void attach_bills(bill entity) { this.SendPropertyChanging(); entity.staff = this; }