public int InsertChiTietHDN(ChiTietHoaDonNhap ctHDN) { List<SqlParameter> paramList = new List<SqlParameter>(); SqlParameter param = new SqlParameter(); param = new SqlParameter("@MaHDN", SqlDbType.Int); param.Value = ctHDN.MaDHN; paramList.Add(param); param = new SqlParameter("@IDThuoc", SqlDbType.Int); param.Value = ctHDN.IDThuoc; paramList.Add(param); param = new SqlParameter("@SoLuong", SqlDbType.Int); param.Value = ctHDN.SoLuong; paramList.Add(param); param = new SqlParameter("@GiaNhap", SqlDbType.Decimal); param.Value = ctHDN.GiaNhap; paramList.Add(param); int i = dbHelper.ExecuteNonQuery("ChiTietHoaDonNhap_Insert", paramList); return i; }
private void btn_ThemThuocHDN_Click(object sender, EventArgs e) { if (KiemTraMaThuocHDN() == true) MessageBox.Show(this, "Thuốc này đã có trong danh sách !", "Thông Báo ...", MessageBoxButtons.OK, MessageBoxIcon.Error); else { int SoLuong = Convert.ToInt32(numUD_SoLuongThuocNhap.Value); decimal GiaNhap = 0; if (SoLuong == 0) { MessageBox.Show(this, "Chưa nhập số lượng !", "Thông Báo ...", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!ValidateFrom.CheckNumber(txt_GiaNhap.Text)) { MessageBox.Show(this, "Giá nhập không đúng !", "Thông Báo ...", MessageBoxButtons.OK, MessageBoxIcon.Error); txt_GiaNhap.Text = ""; txt_GiaNhap.Focus(); } else { Thuoc thuoc = (Thuoc)arrThuoc.ToArray()[lv_DanhSachThuocHDN.FocusedItem.Index]; try { GiaNhap = Convert.ToDecimal(txt_GiaNhap.Text); ChiTietHoaDonNhap ctHDN = new ChiTietHoaDonNhap(); ctHDN.IDThuoc = thuoc.IDThuoc; ctHDN.MaThuoc = thuoc.MaThuoc; ctHDN.SoLuong = SoLuong; ctHDN.GiaNhap = GiaNhap; arrCTHDN.Add(ctHDN); ViewCTHDN(); txt_MaThuocHDN.Text = ""; numUD_SoLuongThuocNhap.Value = 0; txt_GiaNhap.Text = ""; btn_ThemThuocHDN.Enabled = false; } catch (FormatException evt) { Console.WriteLine(evt.Message); MessageBox.Show(this, "Giá nhập không đúng !", "Thông Báo ...", MessageBoxButtons.OK, MessageBoxIcon.Error); txt_GiaNhap.Text = ""; txt_GiaNhap.Focus(); } } } }
//public HoaDonXuat SelectHoaDonXuat(int _MaHDX) //{ // SqlDataReader rd = null; // rd = dbHelper.ExecuteQuery("GetHoaDonXuat_MaHDX "+_MaHDX+""); // if (rd.Read()) // { // HoaDonXuat hdx = new HoaDonXuat(rd.GetInt32(0), rd.GetString(1), rd.GetDateTime(2), rd.GetDecimal(3), rd.GetDouble(4), rd.GetDecimal(5)); // rd.Close(); // return hdx; // } // else // { // rd.Close(); // return null; // } //} public ArrayList SelectAllChiTietHDN(int MaHDN) { SqlDataReader rd = dbHelper.ExecuteQuery(" GetChiTietHDN_MaHDN " + MaHDN + " "); ArrayList arrCTHDN = new ArrayList(); while (rd.Read()) { ChiTietHoaDonNhap CTHDN = new ChiTietHoaDonNhap(rd.GetInt32(0),rd.GetInt32(1),rd.GetInt32(2),rd.GetString(3),rd.GetInt32(4),rd.GetDecimal(5)); arrCTHDN.Add(CTHDN); } rd.Close(); return arrCTHDN; }