private void Form1_Load(object sender, EventArgs e) { thuoc t = new thuoc(); s.insertSinhVien(t); // }
private void button2_Click(object sender, EventArgs e) { thuoc t = new thuoc(); t.Mathuoc = dg_thuoc.Rows[dg_thuoc.CurrentRow.Index].Cells[0].Value.ToString(); this.t.delete(t); load(); }
public int addQuantity(string id, int quantity) { thuoc d = db.thuocs.Where(x => x.maThuoc == id).FirstOrDefault(); d.slTon = d.slTon + quantity; db.SubmitChanges(); return(1); }
//Kiểm tra mã thuốc có tồn tại public bool checkIDExist(string id) { thuoc mttemp = db.thuocs.Where(x => x.maThuoc == id).FirstOrDefault(); if (mttemp != null) { return(true); } return(false); }
//Xóa thuốc khỏi database public bool deleteMedecine(string id) { thuoc med = db.thuocs.Where(x => x.maThuoc == id).FirstOrDefault(); if (med != null) { db.thuocs.DeleteOnSubmit(med); db.SubmitChanges(); //cập nhật việc xóa vào CSDL return(true); //xóa thành công } return(false); }
public DataTable insertSinhVien(thuoc t) { DataTable tb = new DataTable(); SqlCommand cmd = new SqlCommand("tênPro", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@dsd", t.Congdung)); return(tb); }
public void delete(thuoc t) { openC(); SqlCommand cmd = new SqlCommand("sp_delete_thuoc", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@mathuoc", t.Mathuoc)); cmd.ExecuteNonQuery(); closeC(); }
public int subtractQuantity(string id, int quantity) { thuoc d = db.thuocs.Where(x => x.maThuoc == id).FirstOrDefault(); if (quantity > d.slTon) { return(-1); } else { d.slTon = d.slTon - quantity; db.SubmitChanges(); return(1); } }
private void button2_Click(object sender, EventArgs e) { thuoc t = new thuoc(); t.Mathuoc = dg_thuoc.Rows[dg_thuoc.CurrentRow.Index].Cells[0].Value.ToString(); if (this.t.check(t.Mathuoc.Trim()) == 0) { this.t.delete(t); load(); } else { MessageBox.Show("Còn dữ liệu, không thể xóa"); } }
//Sửa thông tin thuốc public void updateMedecine(eMedicine med) { thuoc medUpdate = db.thuocs.Where(x => x.maThuoc.Equals(med.MedicineID)).FirstOrDefault(); // Cập nhật dữ liệu medUpdate.maThuoc = med.MedicineID; medUpdate.tenThuoc = med.MedicineName; //medUpdate.donViTinh = med.Quantity; medUpdate.giaGoc = (decimal)med.Price; medUpdate.slTon = med.UnitsInStock; medUpdate.maLoai = getIDCategory(med.CategoryName); // Lưu mã của loại thuốc medUpdate.maNCC = getIDSupplier(med.SupplierName); // Lưu mã của nhà cung cấp medUpdate.hanSuDung = med.Exp; medUpdate.moTa = med.Describe; db.SubmitChanges(); }
private void suadl() { thuoc t = new thuoc(); t.Mathuoc = txt_mathuoc.Text.ToString(); t.Tenthuoc = txt_tenthuoc.Text.ToString(); t.Loaithuoc = txt_loaithuoc.Text.ToString(); t.Congdung = txt_congdung.Text.ToString(); t.Tacdungphu = txt_tacdungphu.Text.ToString(); t.Chongchidinh = txt_chongchidinh.Text.ToString(); t.Ghichu = txt_ghichu.Text.ToString(); t.Dongia = txt_dongia.Text.ToString(); t.Donvitinh = cb_donvitinh.Text.ToString(); t.Thuocdacbiet = thuocdacbiet; t.HanSD = txt_hsd.Value.ToString() + " " + cb_hsd.Text.ToString(); thuoc.update(t); f.load(); this.Close(); }
public void update(thuoc t) { openC(); SqlCommand cmd = new SqlCommand("sp_update_thuoc", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@mathuoc", t.Mathuoc)); cmd.Parameters.Add(new SqlParameter("@tenthuoc", t.Tenthuoc)); cmd.Parameters.Add(new SqlParameter("@Loaithuoc", t.Loaithuoc)); cmd.Parameters.Add(new SqlParameter("@Congdung", t.Congdung)); cmd.Parameters.Add(new SqlParameter("@HanSD", t.HanSD)); cmd.Parameters.Add(new SqlParameter("@Thuocdacbiet", t.Thuocdacbiet)); cmd.Parameters.Add(new SqlParameter("@Tacdungphu", t.Tacdungphu)); cmd.Parameters.Add(new SqlParameter("@Chongchidinh", t.Chongchidinh)); cmd.Parameters.Add(new SqlParameter("@Dongia", t.Dongia)); cmd.Parameters.Add(new SqlParameter("@Donvitinh", t.Donvitinh)); cmd.Parameters.Add(new SqlParameter("@Ghichu", t.Ghichu)); cmd.ExecuteNonQuery(); closeC(); }
//Nhập thuốc mới vào database public int insertMedecine(eMedicine med) { if (checkIDExist(med.MedicineID)) { return(0); } thuoc medtemp = new thuoc(); medtemp.maThuoc = med.MedicineID; medtemp.tenThuoc = med.MedicineName; // medtemp.donViTinh = med.Quantity; medtemp.giaGoc = (decimal)med.Price; medtemp.slTon = med.UnitsInStock; medtemp.maLoai = getIDCategory(med.CategoryName); // Lưu mã của loại thuốc medtemp.maNCC = getIDSupplier(med.SupplierName); // Lưu mã của nhà cung cấp medtemp.hanSuDung = med.Exp; medtemp.moTa = med.Describe; db.thuocs.InsertOnSubmit(medtemp); db.SubmitChanges(); return(1); }
public void delete(thuoc t) { thuoc.delete(t); }
public void update(thuoc t) { thuoc.update(t); }
public void insert(thuoc t) { thuoc.insert(t); }