public string LayMaHoaDonTuSinh() { string result = "AEON_HDTC" + 1.ToString().PadLeft(4, '0'); HoaDonTienCoc hd = db.HoaDonTienCocs.Where(x => x.MaHD.Contains($"AEON_HDTC")) .OrderByDescending(x => x.MaHD).FirstOrDefault(); if (hd != null && !string.IsNullOrWhiteSpace(hd.MaHD)) { int so = Convert.ToInt32(hd.MaHD.Replace("AEON_HDTC", "")) + 1; result = "AEON_HDTC" + so.ToString().PadLeft(4, '0'); } return(result); }
public bool XoaHoaDon(string maHD) { try { HoaDonTienCoc hd = db.HoaDonTienCocs.Where(t => t.MaHD.Equals(maHD)).FirstOrDefault(); db.HoaDonTienCocs.DeleteOnSubmit(hd); db.SubmitChanges(); return(true); } catch (Exception) { return(false); throw; } }
private void btnLuu_Click(object sender, EventArgs e) { HoaDonTienCoc hd = new HoaDonTienCoc(); hd.MaHD = txtMaHoaDon.Text; hd.NgayDong = (DateTime)txtNgayDong.EditValue; hd.NgayLap = (DateTime)txtNgayLap.EditValue; hd.SoTien = (int)thueMB.TinhTienCoc(txtMatBang.Text); hd.TrangThai = 1; hd.MaDK = maDK; if (thueMB.ThemHoaDon(hd)) { MessageBox.Show("Thêm hóa đơn thành công"); maHD = txtMaHoaDon.Text; this.Close(); } }
public bool ThemHoaDon(HoaDonTienCoc hd) { try { HoaDonTienCoc hoaDon = new HoaDonTienCoc(); hoaDon = hd; db.HoaDonTienCocs.InsertOnSubmit(hoaDon); db.SubmitChanges(); return(true); } catch (Exception) { return(false); throw; } }
public bool ThemHoaDon(HoaDonTienCoc hd) { return(dkThue.ThemHoaDon(hd)); }