public bool themphieuthanhtoan(DTO_Thanhtoan _dtt)
        {
            try
            {
                // Ket noi
                _conn.Open();

                // Query string - vì mình để TV_ID là identity (giá trị tự tăng dần) nên ko cần fải insert ID
                string SQL = string.Format("INSERT INTO THANHTOAN (Madonhang , Ngayxuat) VALUES ('{0}', '{1}')", _dtt.MADONHANG, _dtt.NGAYXUAT);

                // Command (mặc định command type = text nên chúng ta khỏi fải làm gì nhiều).
                SqlCommand cmd = new SqlCommand(SQL, _conn);

                // Query và kiểm tra
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
            }
            finally
            {
                // Dong ket noi
                _conn.Close();
            }

            return(false);
        }
Esempio n. 2
0
 private void BtnThanhToan_Click(object sender, EventArgs e)
 {
     if (getCMNDKhachhang() == "")
     {
         MessageBox.Show("Vui lòng chọn khách hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (getHieuxe() == "")
     {
         MessageBox.Show("Vui lòng chọn hiệu xe", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (getBienso() == "")
     {
         MessageBox.Show("Vui lòng chọn biển số", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (dtpkNgayThanhToan.Value.ToShortDateString() == "")
     {
         MessageBox.Show("Vui lòng chọn ngày thanh toán", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         DTO_Thanhtoan tt = new DTO_Thanhtoan(0, Int32.Parse(thanhtoan.getMadonhang(getBienso())), DateTime.Parse(dtpkNgayThanhToan.Value.ToShortDateString()));
         DialogResult  result;
         if (thanhtoan.thanhtoanhoadon(tt))
         {
             result = MessageBox.Show("Thanh toán thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             result = MessageBox.Show("Thanh toán thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         if (result == DialogResult.OK)
         {
             XoaDuLieu();
             UC_ThanhToan_Load(sender, e);
         }
         //   return;
     }
 }
Esempio n. 3
0
 public bool thanhtoanhoadon(DTO_Thanhtoan _tt)
 {
     return(thanhtoan.themphieuthanhtoan(_tt));
 }