private void frmAddPharmacyOrder_Load(object sender, EventArgs e)
        {
            lblTitle.Text = string.Format("Phiếu nhập kho: {0}", orderid);
            dtPharmacy    = new Drug().Select();
            sleDrug.Properties.DataSource    = dtPharmacy;
            sleDrug.Properties.DisplayMember = "name";
            sleDrug.Properties.ValueMember   = "id";
            var dt = new PharmacyOrderLine().Select(orderid);

            if (dt.Rows.Count > 0)
            {
                lstPharmacy = new List <Pharmacy>();
                foreach (DataRow r in dt.Rows)
                {
                    lstPharmacy.Add(new Pharmacy()
                    {
                        id               = r["id"].ToString(),
                        name             = r["name"].ToString(),
                        unit             = r["unit"].ToString(),
                        price            = int.Parse(r["price"].ToString()),
                        quantity         = int.Parse(r["quantity"].ToString()),
                        manufactureddate = r["manufactureddate"].ToString(),
                        expireddate      = r["expireddate"].ToString()
                    });
                }
                LoadPharmacy();
            }
        }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(itemid) && Common.ConfirmMessage("XÁC NHẬN XÓA THUỐC", "Bạn muốn xóa thuốc " + itemname + " ra khỏi danh sách?") == DialogResult.Yes)
     {
         var rs = new PharmacyOrderLine().Delete(orderid, itemid);
         if (rs == 1)
         {
             lstPharmacy.RemoveAt(rowIndex);
             Common.SuccessMessageBox("Xóa thuốc thành công");
             LoadPharmacy();
         }
         else
         {
             Common.ErrorMessageBox("Lỗi xóa thuốc: " + rs);
         }
     }
 }
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     if (lstPharmacy != null && lstPharmacy.Count > 0)
     {
         var isSuccess = true;
         var rpol      = new PharmacyOrderLine();
         foreach (var item in lstPharmacy)
         {
             if (rpol.Insert(orderid, item.id, item.quantity, item.manufactureddate, item.expireddate) != 1)
             {
                 Common.ErrorMessageBox("Thêm thuốc " + item.name + " thất bại");
                 isSuccess = false;
                 break;
             }
         }
         if (isSuccess)
         {
             this.Dispose();
         }
     }
 }