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); } }
//SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); #region Thêm Chi Tiết Hóa Đơn public void InsertBillDeTail(DTO_BillDetail ex) { sqlCm.Connection = connectionBill.OpenConnection(); sqlCm.CommandText = "INSERTDATABILLDETAIL"; sqlCm.CommandType = CommandType.StoredProcedure; sqlCm.Parameters.AddWithValue("@maSP", ex.MaSP); sqlCm.Parameters.AddWithValue("@soLuong", ex.SoLuong); sqlCm.Parameters.AddWithValue("@giaBan", ex.GiaBan); sqlCm.Parameters.AddWithValue("@khuyenMai", ex.KhuyenMai); sqlCm.Parameters.AddWithValue("@thanhTien", ex.ThanhTien); sqlCm.Parameters.AddWithValue("@maHD", ex.MaHD); sqlCm.ExecuteNonQuery(); sqlCm.Parameters.Clear(); }
public bool insertBillID(DTO_BillDetail billDetail) { bool success = false; String query = "INSERT INTO CHITIET_HD VALUES(@billID, @productID, @productAmount, @totalPrice)"; SqlCommand command = new SqlCommand(query, DAL_CDBConnect.myconn); command.Parameters.Add("@billID", SqlDbType.VarChar).Value = billDetail.BillID; command.Parameters.Add("@productID", SqlDbType.VarChar).Value = billDetail.ProductID; command.Parameters.Add("@productAmount", SqlDbType.VarChar).Value = billDetail.ProductAmount; command.Parameters.Add("@totalPrice", SqlDbType.VarChar).Value = billDetail.ProductTotalPrice; success = command.ExecuteNonQuery() >= 0; command.Dispose(); return(success); }
public bool insertBillDetail(DTO_BillDetail billDetail) { return(new DAL_BillDetail().insertBillID(billDetail)); }
public void InsertBillDetail(DTO_BillDetail dt) { db.InsertBillDeTail(dt); }