private void btn_nhapthuoc_Click(object sender, EventArgs e) { if (thuoc.Check_Exist(txt_mathuoc.Text) == 1) { int t = int.Parse(thuoc.Get_GiaTriThuoc(txt_mathuoc.Text).Rows[0]["Vien"].ToString()); Thuoc X = new Thuoc(t); X.setSTT(th.Count() + 1); X.setMaSanPham(txt_mathuoc.Text); X.setTenThuoc(thuoc.Get_GiaTriThuoc(txt_mathuoc.Text).Rows[0]["TenThuoc"].ToString()); X.setGiaSauThue(thuoc.Get_GiaTriThuoc(txt_mathuoc.Text).Rows[0]["GiaSauThue"].ToString()); if (cbb_tencty.SelectedIndex == 0) { X.setGiaNhap(thuoc.Get_GiaTriThuoc(txt_mathuoc.Text).Rows[0]["GiaNhap"].ToString()); } else if (cbb_tencty.SelectedIndex == 1) { X.setGiaSauThue(thuoc.Get_GiaTriThuoc(txt_mathuoc.Text).Rows[0]["GiaBan"].ToString()); X.setGiaNhap(""); } X.Location = new System.Drawing.Point(0, X._stt * 30); X.ButtonClick += new EventHandler(this.thuoc_ButtonClick); X.ButtonClick_more += new EventHandler(this.thuoc_ButtonClick_more); int tt; foreach (Thuoc A in th) { if (A.getMaSanPham() == txt_mathuoc.Text) { A.setsl(); tt = tongtien(th); alltien.Text = tt.ToString(); return; } } th.Add(X); panel1.Controls.Add(X); tt = tongtien(th); alltien.Text = tt.ToString(); setlist(th); //X.setNTN(thuoc.Get_ThoiHanSuDung(txt_mathuoc.Text)); } }
private void btn_nhapthuoc_Click(object sender, EventArgs e, int _slThuoc = 1) { Stopwatch timer = new Stopwatch(); timer.Start(); int sl = 0; if (a == 0) { foreach (Thuoc A in th) { if (string.Equals(txt_mathuoc.Text, A.getMaSanPham())) { sl += A.getsl(); } } } if (kho.Check_Exist(txt_mathuoc.Text) > sl) { a = 0; int t = int.Parse(thuoc.Get_GiaTriThuoc(txt_mathuoc.Text).Rows[0]["Vien"].ToString()); Thuoc X = new Thuoc(t); X.setSTT(th.Count() + 1); X.setMaSanPham(txt_mathuoc.Text); X.setTenThuoc(thuoc.Get_GiaTriThuoc(txt_mathuoc.Text).Rows[0]["TenThuoc"].ToString()); X.setGiaSauThue(thuoc.Get_GiaTriThuoc(txt_mathuoc.Text).Rows[0]["GiaBan"].ToString()); string hsd = kho.Get_GiaTriThuocTrongKho(txt_mathuoc.Text).Rows[0]["NgayHetHan"].ToString(); string[] tokens = hsd.Split(' '); hsd = tokens[0]; X.Location = new System.Drawing.Point(0, X._stt * 30); X.ButtonClick += new EventHandler(this.thuoc_ButtonClick); X.ButtonClick_more += new EventHandler(this.thuoc_ButtonClick_more); int tt; foreach (Thuoc A in th) { A.getsl(); if (A.getMaSanPham() == txt_mathuoc.Text) { A.setsl(); tt = tongtien(th); alltien.Text = tt.ToString(); return; } } th.Add(X); panel1.Controls.Add(X); tt = tongtien(th); alltien.Text = tt.ToString(); setlist(th); X.setNTN(hsd); } else { int t = int.Parse(thuoc.Get_GiaTriThuoc(txt_mathuoc.Text).Rows[0]["Vien"].ToString()); a = 1; Thuoc X = new Thuoc(t); X.setSTT(th.Count() + 1); X.setMaSanPham(txt_mathuoc.Text); X.setTenThuoc(kho.Add_ThemLoaiThuocKhac(txt_mathuoc.Text).Rows[0]["TenThuoc"].ToString()); X.setGiaSauThue(thuoc.Get_GiaTriThuoc(txt_mathuoc.Text).Rows[0]["GiaBan"].ToString()); string hsd = kho.Add_ThemLoaiThuocKhac(txt_mathuoc.Text).Rows[0]["NgayHetHan"].ToString(); string[] tokens = hsd.Split(' '); hsd = tokens[0]; X.Location = new System.Drawing.Point(0, X._stt * 30); X.ButtonClick += new EventHandler(this.thuoc_ButtonClick); X.ButtonClick_more += new EventHandler(this.thuoc_ButtonClick_more); int tt; foreach (Thuoc A in th) { A.getsl(); if (A.getMaSanPham() == txt_mathuoc.Text && string.Equals(A.getNTN(), hsd)) { A.setsl(); tt = tongtien(th); alltien.Text = tt.ToString(); return; } } th.Add(X); panel1.Controls.Add(X); tt = tongtien(th); alltien.Text = tt.ToString(); setlist(th); X.setsl(_slThuoc); X.setNTN(hsd); } txt_mathuoc.Text = ""; timer.Stop(); string k = "Time Taken: " + timer.Elapsed.TotalMilliseconds.ToString("#,##0.00 'milliseconds'"); int l = 0; }