private void btnLuu_Click(object sender, EventArgs e) { try { CheckError(); if (isThem == true) { eLoThuoc newLT = new eLoThuoc(); newLT.MaLoThuoc = txtMaLoThuoc.Text; newLT.MaThuoc = cboLoaiThuoc.SelectedValue.ToString(); newLT.MaNCC = cbbNCC.SelectedValue.ToString(); newLT.DVT = cbbDVT.Text; newLT.SoLuong = Convert.ToInt32(nmrSL.Value); newLT.DonGia = Convert.ToDecimal(txtGiaBan.Text); newLT.NgayNhap = dtpNgayNhap.Value; newLT.NgayHetHan = dtpNgayHetHan.Value; newLT.TrangThai = 0; lothuocBLL.ThemThongTinLoThuoc(newLT); MessageBox.Show("Them thanh cong"); ClearTXT(); EnableControl(false); isThem = false; btnThem.Text = "Them"; btnSua.Enabled = true; btnLuu.Enabled = false; btnThem.BackColor = Color.DodgerBlue; UCQuanLiLoThuoc_Load(sender, e); dgvDanhSachThuoc.Enabled = true; } else { string mlt = txtMaLoThuoc.Text; string mncc = cboLoaiThuoc.SelectedValue.ToString(); string mt = cboLoaiThuoc.SelectedValue.ToString(); string dvt = cbbDVT.Text; int sl = Convert.ToInt32(nmrSL.Value); decimal dg = Convert.ToDecimal(txtGiaBan.Text); DateTime nn = dtpNgayNhap.Value; DateTime nhh = dtpNgayHetHan.Value; int tt = 0; lothuocBLL.CapNhatThongTinLoThuoc(mlt, mncc, mt, sl, dvt, dg, nn, nhh, tt); isSua = false; btnSua.Text = "Sua"; btnThem.Enabled = true; btnLuu.Enabled = false; btnSua.BackColor = Color.LimeGreen; UCQuanLiLoThuoc_Load(sender, e); dgvDanhSachThuoc.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void ThemThongTinLoThuoc(eLoThuoc newLoThuoc) { LoThuocs temp = new LoThuocs(); temp.MaLoThuoc = newLoThuoc.MaLoThuoc; temp.MaNCC = newLoThuoc.MaNCC; temp.MaThuoc = newLoThuoc.MaThuoc; temp.SoLuong = newLoThuoc.SoLuong; temp.DVT = newLoThuoc.DVT; temp.DonGia = newLoThuoc.DonGia; temp.NgayNhap = newLoThuoc.NgayNhap; temp.NgayHetHan = newLoThuoc.NgayHetHan; temp.TrangThai = newLoThuoc.TrangThai; qt.LoThuocs.InsertOnSubmit(temp); qt.SubmitChanges(); }
public List <eLoThuoc> LayThongTinLoThuoc() { var dsLoThuoc = qt.LoThuocs.ToList(); List <eLoThuoc> dslt = new List <eLoThuoc>(); foreach (LoThuocs lt in dsLoThuoc) { eLoThuoc l = new eLoThuoc(); l.MaLoThuoc = lt.MaLoThuoc; l.MaThuoc = lt.MaThuoc; l.MaNCC = lt.MaNCC; l.SoLuong = lt.SoLuong; l.DVT = lt.DVT; l.DonGia = lt.DonGia; l.NgayNhap = lt.NgayNhap; l.NgayHetHan = lt.NgayHetHan; l.TrangThai = lt.TrangThai; dslt.Add(l); } return(dslt); }