Example #1
0
 public bool TaoHoaDonNhap(HoaDonNhap HDN, ArrayList arrCTHDN)
 {
     SystemLog systemLog = new SystemLog(QuanLy.IDUser, DateTime.Now.ToString(), "Thêm hóa đơn nhập");
     busUser.SetSystemLog(systemLog);
     int i = hdnQ.InsertHDN(HDN);
     if (i > 0)
     {
         int MaHDN = hdnQ.SelectLastMaHoaDonNhap();                
             int j = 0;
             foreach (ChiTietHoaDonNhap ctHDN in arrCTHDN)
             {
                 ctHDN.MaDHN = MaHDN;
                 j += hdnQ.InsertChiTietHDN(ctHDN);
             }
             if (j == arrCTHDN.Count)
             {
                 foreach (ChiTietHoaDonNhap ctHDN in arrCTHDN)
                 {
                     hdnQ.UpdateSoLuongThuoc(ctHDN.IDThuoc, ctHDN.SoLuong);
                 }
                 return true;
             }
             else{
                 hdnQ.DelHoaDonNhapByMaHDN(MaHDN);
                 return false;
             }
     }
     else {
         return false;
     }
 }
Example #2
0
        public int InsertHDN(HoaDonNhap HDN)
        {
            List<SqlParameter> paramList = new List<SqlParameter>();
            SqlParameter param = new SqlParameter();
            param = new SqlParameter("@MaNPP", SqlDbType.Int);
            param.Value = HDN.MaNPP;
            paramList.Add(param);
            param = new SqlParameter("@NguoiGiao", SqlDbType.NVarChar);
            param.Value = HDN.NguoiGiao.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@NguoiNhan", SqlDbType.NVarChar);
            param.Value = HDN.NguoiNhan.Replace("'", "''");
            paramList.Add(param);
            param = new SqlParameter("@TongTienThuoc", SqlDbType.Decimal);
            param.Value = HDN.TongTienThuoc;
            paramList.Add(param);
            param = new SqlParameter("@TongThue", SqlDbType.Float);
            param.Value = HDN.TongThue;
            paramList.Add(param);
            param = new SqlParameter("@TongTienHD", SqlDbType.Decimal);
            param.Value = HDN.TongTienHD;
            paramList.Add(param);
            param = new SqlParameter("@NgayViet", SqlDbType.DateTime);
            param.Value = HDN.NgayViet;
            paramList.Add(param);
            param = new SqlParameter("@NgayNhap", SqlDbType.DateTime);
            param.Value = HDN.NgayNhap;
            paramList.Add(param);

            int i = dbHelper.ExecuteNonQuery("HoaDonNhap_Insert", paramList);
            return i;
        }
 public ViewChiTietHoaDonNhap(HoaDonNhap HDN)
 {
     this.HDN = HDN;
     busHDN = new BusHDN();
     InitializeComponent();
     ViewForm();
 }
Example #4
0
 private void btn_LuuHDN_Click(object sender, EventArgs e)
 {
     if (arrCTHDN.Count == 0)
     {
         MessageBox.Show(this, "Chưa có thuốc trong hóa đơn", "Thông báo");
         txt_MaThuocHDN.Focus();
     }
     else if (cbb_NPP.SelectedIndex<0)
     {
         MessageBox.Show(this, "Chưa chọn nhà phân phối", "Thông báo");                
     }            
     else
     {
         NhaPhanPhoi NPP = (NhaPhanPhoi)arrNPP.ToArray()[cbb_NPP.SelectedIndex];
         String NguoiGiao = txt_NguoiGiao.Text;
         String NguoiNhan = txt_NguoiNhan.Text;
         Decimal TongTienThuoc = Convert.ToDecimal(lbl_TienHang.Text);
         Double Thue = Convert.ToDouble(txt_ThueHDN.Text);
         Decimal TongTien = Convert.ToDecimal(lbl_TongTien.Text);
         HoaDonNhap HDN = new HoaDonNhap(0, NPP.MaNPP, NguoiGiao, NguoiNhan, TongTienThuoc, Thue, TongTien, dtp_NgayViet.Value.Date, dtp_NgayNhap.Value.Date);
         bool flag = busHDN.TaoHoaDonNhap(HDN, arrCTHDN);
         if (flag)
         {
             MessageBox.Show(this, "Tạo hóa đơn thành công!", "Thông báo");
             DanhSachHDN();
         }
         else
         {
             MessageBox.Show(this, "Không tạo được hóa đơn!", "Thông báo");
         }
         ResetFormHDN();
     }
 }
Example #5
0
 public ArrayList SelectAllHDN(string TenNPP,string MaThuoc, string FromDate, string ToDate)
 {
     SqlDataReader rd = dbHelper.ExecuteQuery(" getAllHDN N'%" + TenNPP.Replace("'", "''") + "%',N'%" + MaThuoc.Replace("'", "''") + "%','" + FromDate + "','" + ToDate + "'");
     ArrayList arrHDN = new ArrayList();
     try
     {
         while (rd.Read())
         {
             HoaDonNhap HDN = new HoaDonNhap(rd.GetInt32(0), rd.GetInt32(1),rd.GetString(2),rd.GetString(3),rd.GetString(4),rd.GetDecimal(5),rd.GetDouble(6),rd.GetDecimal(7),rd.GetDateTime(8),rd.GetDateTime(9));
             arrHDN.Add(HDN);
         }
     }
     catch (SqlException e)
     {
         Console.Write(e.ToString());
     }
     rd.Close();
     return arrHDN;
 }