Пример #1
0
 private void btn_submit_Click(object sender, EventArgs e)
 {
     if (int.Parse(this.lb_cus_cash.Text.ToString().Replace(",", "").Trim()) >= int.Parse(this.lb_total_price.Text.ToString().Replace(",", "").Trim()))
     {
         try
         {
             bool     success = false;
             DTO_Bill bill    = new DTO_Bill(this.billID, this.currentUserLogin.MaNV, DateTime.Now, int.Parse(this.lb_total_price.Text.ToString().Replace(",", "").Trim()));
             success = new BUS_Bill().insertBill(bill);
             foreach (DataRow row in this.tableProduct.Rows)
             {
                 DTO_BillDetail billDetail = new DTO_BillDetail(this.billID, row["MSMH"].ToString(), int.Parse(row["SOLUONG"].ToString()), int.Parse(row["THANHTIEN"].ToString()));
                 new BUS_BillDetail().insertBillDetail(billDetail);
             }
             DTO_Money.Sales = DTO_Money.Sales + int.Parse(this.lb_total_price.Text.ToString().Replace(",", "").Trim());
             new frm_InHoaDon(this.billID).ShowDialog();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message.ToString());
         }
     }
     else
     {
         MessageBox.Show("Nhận thiếu tiền", "Không thể thanh toán", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #2
0
        public DTO_Bill GetIdBill()
        {
            DTO_Bill dt = new DTO_Bill();

            dt = db.GetIdBill();
            return(dt);
        }
Пример #3
0
 public void dropItem(DTO_Bill info)
 {
     string[] value =
     {
         info.Id.ToString()
     };
     dataBill.Delete(value);
 }
Пример #4
0
        public DataTable GetBill(string id)
        {
            DataTable dt = new DataTable();
            DTO_Bill  k  = new DTO_Bill();

            sqlCm.Connection  = connectionBill.OpenConnection();
            sqlCm.CommandText = "SELECT * FROM PAYMENT WHERE maHD='" + id + "'";
            sqlCm.CommandType = CommandType.Text;
            SqlDataAdapter adapter = new SqlDataAdapter(sqlCm);

            adapter.Fill(dt);
            connectionBill.CloseConnection();
            return(dt);
        }
Пример #5
0
 public void Insert(DTO_Bill ex)
 {
     sqlCm.Connection  = connectionBill.OpenConnection();
     sqlCm.CommandText = "INSERTDATABILL";
     sqlCm.CommandType = CommandType.StoredProcedure;
     sqlCm.Parameters.AddWithValue("@NVLap", ex.NVLap);
     sqlCm.Parameters.AddWithValue("@thongTinKH", ex.ThongTinKH);
     sqlCm.Parameters.AddWithValue("@ngayLap", ex.NgayLap);
     sqlCm.Parameters.AddWithValue("@tongTien", ex.TongTien);
     sqlCm.Parameters.AddWithValue("@daThanhToan", ex.DaThanhToan);
     sqlCm.Parameters.AddWithValue("@soTienTra", ex.SoTienTra);
     sqlCm.Parameters.AddWithValue("@soTienThua", ex.SoTienThua);
     sqlCm.ExecuteNonQuery();
     sqlCm.Parameters.Clear();
 }
Пример #6
0
        public bool insertBill(DTO_Bill bill)
        {
            bool       success = false;
            String     query   = "INSERT INTO HOADON VALUES(@billID, @userID, @dateCreated, @totalPrice)";
            SqlCommand command = new SqlCommand(query, DAL_CDBConnect.myconn);

            command.Parameters.Add("@billID", SqlDbType.VarChar).Value      = bill.BillID;
            command.Parameters.Add("@userID", SqlDbType.VarChar).Value      = bill.UserID;
            command.Parameters.Add("@dateCreated", SqlDbType.VarChar).Value = bill.DateCreated;
            command.Parameters.Add("@totalPrice", SqlDbType.VarChar).Value  = bill.TotalPrice;

            success = command.ExecuteNonQuery() >= 0;

            command.Dispose();
            return(success);
        }
Пример #7
0
        private void btnPayment_Click(object sender, EventArgs e)
        {
            // thêm hóa đơn
            bilDTO.NVLap       = Convert.ToInt32(cmbAddbyStaff.SelectedValue);
            cusDTO             = blCus.GetIdCus(txtNameCustomer.Text);
            bilDTO.ThongTinKH  = cusDTO.MaKH;
            bilDTO.NgayLap     = DateTime.Now;
            bilDTO.TongTien    = Convert.ToDecimal(txtTotalBill.Text);
            bilDTO.DaThanhToan = true;
            decimal val;
            bool    result = decimal.TryParse(txtPayAmout.Text, out val);

            if (!result)
            {
                return;
            }
            bilDTO.SoTienTra  = Convert.ToDecimal(val);
            bilDTO.SoTienThua = Convert.ToDecimal(txtReturnPay.Text);
            Bldtb.InsertBill(bilDTO);

            // thêm chi tiết hóa đơn
            try
            {
                for (int i = 0; i < Bill.Rows.Count; i++)
                {
                    masp              = blProd.GetIDProductBill(Convert.ToString(Bill.Rows[i][0].ToString()));
                    billDTO.MaSP      = masp;
                    billDTO.SoLuong   = Convert.ToInt32(Bill.Rows[i][1].ToString());
                    billDTO.GiaBan    = decimal.Parse(Bill.Rows[i][2].ToString());
                    billDTO.ThanhTien = decimal.Parse(Bill.Rows[i][3].ToString());
                    billDTO.KhuyenMai = int.Parse(txtSaleProduct.Text);
                    bilDTO            = Bldtb.GetIdBill();
                    billDTO.MaHD      = bilDTO.MaHD;
                    blProd.DecreaseProd(billDTO.MaSP, billDTO.SoLuong);
                    bldldt.InsertBillDetail(billDTO);
                }
                MessageBox.Show("Thanh toán thành công");
                ReportB rp = new ReportB(Convert.ToString(billDTO.MaHD));
                rp.Show();
                clearform();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #8
0
 private void btnDrop_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc là muốn xóa hóa đơn này không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
     {
         foreach (DataGridViewRow row in dataGridView.SelectedRows)
         {
             this.index = row.Index;
         }
         if (this.index >= 0)
         {
             int      id   = Convert.ToInt32(dataGridView.Rows[this.index].Cells["colId"].Value);
             DTO_Bill info = new DTO_Bill();
             info.Id = id;
             bus.dropItem(info);
             GUI_Bill_Load(sender, e);
         }
     }
 }
Пример #9
0
        public DTO_Bill GetIdBill()
        {
            DataTable dataTable = new DataTable();
            DTO_Bill  k         = new DTO_Bill();

            sqlCm.Connection  = connectionBill.OpenConnection();
            sqlCm.CommandText = "SELECT MAX(maHD) as maHD FROM HOADON";
            sqlCm.CommandType = CommandType.Text;
            SqlDataAdapter adapter = new SqlDataAdapter(sqlCm);

            adapter.Fill(dataTable);
            if (dataTable.Rows.Count > 0)
            {
                k.MaHD = int.Parse(dataTable.Rows[0]["maHD"].ToString());
            }
            connectionBill.CloseConnection();
            return(k);
        }
Пример #10
0
 public void InsertBill(DTO_Bill bil)
 {
     db.Insert(bil);
 }
Пример #11
0
 public bool insertBill(DTO_Bill bill)
 {
     return(new DAL_Bill().insertBill(bill));
 }