private void btnXoaPhieu_Click(object sender, EventArgs e) { int currentRowIndex = this.dgvDanhSachPhieuThu.CurrentCellAddress.Y; //'current row selected //Verify that indexing OK if (-1 < currentRowIndex && currentRowIndex < dgvDanhSachPhieuThu.RowCount) { PhieuThuTienDTO obj = (PhieuThuTienDTO)dgvDanhSachPhieuThu.Rows[currentRowIndex].DataBoundItem; this.textBoxMaKH.Text = obj.MaKH; this.textBoxMaPhieuThu.Text = obj.MaPT; this.textBoxSoTienThu.Text = obj.STT.ToString(); this.dtpNgayThuTien.Text = obj.NgayThuTien; //this.textBoxEmail.Text = obj.Email; //this.textBoxSoTienNo.Text = obj.SoTienNo.ToString(); string result = this.bus.delete(obj); if (result == "0") { MessageBox.Show("Xóa phiếu thu thành công", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.buildDanhSach(); return; } else { MessageBox.Show("Xóa phiếu thu thất bại.\n" + result, "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { MessageBox.Show("Chưa chọn phiếu thu trên lưới.", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
public string insert(PhieuThuTienDTO obj) { string query = string.Empty; query += "INSERT INTO [PHIEUTHUTIEN] ([MaPhieuThu], [SoTienThu], [NgayThuTien], [MaKhachHang])"; query += "VALUES (@MaPhieuThu,@SoTienThu,@NgayThuTien,@MaKhachHang)"; using (SqlConnection conn = new SqlConnection(connectionString)) { using (SqlCommand comm = new SqlCommand()) { comm.Connection = conn; comm.CommandType = CommandType.Text; comm.CommandText = query; comm.Parameters.AddWithValue("@MaPhieuThu", obj.MaPT); comm.Parameters.AddWithValue("@SoTienThu", obj.STT); comm.Parameters.AddWithValue("@NgayThuTien", obj.NgayThuTien); comm.Parameters.AddWithValue("@MaKhachHang", obj.MaKH); //comm.Parameters.AddWithValue("@Email", obj.Email); //comm.Parameters.AddWithValue("@SoTienNo", obj.SoTienNo); try { conn.Open(); comm.ExecuteNonQuery(); } catch (Exception ex) { conn.Close(); // them that bai!!! return("Lập phiếu thu thất bại\n" + ex.Message + "\n" + ex.StackTrace); } } } return("0"); }
public string delete(PhieuThuTienDTO obj) { string query = string.Empty; query += " DELETE FROM [PHIEUTHUTIEN] "; query += " WHERE "; query += " [MaPhieuThu] = @MaPhieuThu "; using (SqlConnection conn = new SqlConnection(connectionString)) { using (SqlCommand comm = new SqlCommand()) { comm.Connection = conn; comm.CommandType = CommandType.Text; comm.CommandText = query; comm.Parameters.AddWithValue("@MaPhieuThu", obj.MaPT); try { conn.Open(); comm.ExecuteNonQuery(); } catch (Exception ex) { conn.Close(); //' xóa that bai!!! return("Xóa phiếu thu tiền thất bại\n" + ex.Message + "\n" + ex.StackTrace); } } } return("0"); }
private void btnLuu_Click(object sender, EventArgs e) { PhieuThuTienDTO obj = new PhieuThuTienDTO(); obj.MaPT = this.textBoxMaPhieuThu.Text; //obj.STT = this.textBoxHoTenKH.Text; obj.NgayThuTien = this.dtpNgayThuTien.Text; obj.MaKH = this.textBoxMaKH.Text; //obj.Email = this.textBoxEmail.Text; obj.STT = Convert.ToInt32(this.textBoxSoTienThu.Text); string result = this.bus.update(obj); if (result == "0") { MessageBox.Show("Cập nhật thông tin thành công", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); //this.isThemMoi = 0; //this.tcQLNH.SelectedIndex = 0; this.buildDanhSach(); return; } else { MessageBox.Show("Cập nhật thông tin thất bại.\n" + result, "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public string insert(PhieuThuTienDTO obj) { if (obj.MaPT == null || obj.STT == null || obj.NgayThuTien == string.Empty || obj.MaKH == string.Empty) { return("Thông tin nhập phiếu thu tiền không hợp lệ"); } return(dal.insert(obj)); }
private void btnLapPhieuThuTien_Click(object sender, EventArgs e) { PhieuThuTienDTO obj = new PhieuThuTienDTO(); obj.MaKH = this.textBoxMaKH.Text; ThamSoDTO ThamSo = new ThamSoDTO(); ThamSo = busThamSo.QuyDinh(); QuanLyKhachHangDTO KH = new QuanLyKhachHangDTO(); ktquydinh4 = ThamSo.SuDungQuyDinh4; // sẽ viết sau string result; KH.MaKH = this.textBoxMaKH.Text; soTienNo = KH.SoTienNo; tienThu = Convert.ToInt32(this.textBoxSoTienThu.Text); //Kiểm tra mã khách hàng không được để trống if (this.textBoxMaKH.Text == string.Empty) { MessageBox.Show("Mã khách hàng không được để trống", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { obj.MaKH = this.textBoxMaKH.Text; } obj.NgayThuTien = this.dtpNgayThuTien.Text; obj.MaPT = this.textBoxMaPhieuThu.Text; obj.STT = Convert.ToInt32(this.textBoxSoTienThu.Text); KH = this.busKH.searchKH(KH.MaKH, KH); //Quy Dinh 4; if (ktquydinh4 == 1) { if (soTienNo < tienThu) { MessageBox.Show("Số tiền thu lớn hơn số tiền khách hàng đang nợ", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } return; } tienNoMoi = soTienNo - tienThu; //obj.Email = this.textBoxEmail.Text; //obj.SoTienNo = Convert.ToInt32(this.textBoxSoTienNo.Text); result = this.bus.insert(obj); if (result == "0") { MessageBox.Show("Thêm phiếu thu thành công", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } else { MessageBox.Show("Thêm phiếu thu thất bại.\n" + result, "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public int Them(PhieuThuTienDTO pPhieuThuTien) { var config = new MapperConfiguration(cfg => cfg.CreateMap <PhieuThuTienDTO, PhieuThuTien>() ); var mapper = new Mapper(config); var empDTO = mapper.Map <PhieuThuTien>(pPhieuThuTien); return(_application.Them(empDTO)); }
public int Sua(PhieuThuTienDTO pPhieuThuTien, string idx) { var config = new MapperConfiguration(cfg => cfg.CreateMap <PhieuThuTienDTO, PhieuThuTien>() ); var mapper = new Mapper(config); var empDTO = mapper.Map <PhieuThuTien>(pPhieuThuTien); return(_application.Sua(empDTO, idx)); }
public List <PhieuThuTienDTO> GetListPhieuThuTien() { List <PhieuThuTienDTO> phieuthutienList = new List <PhieuThuTienDTO>(); DataTable data = DataProvider.Instance.ExecuteQuery("select * from dbo.phieuthutien"); foreach (DataRow item in data.Rows) { PhieuThuTienDTO phieuthutien = new PhieuThuTienDTO(item); phieuthutienList.Add(phieuthutien); } return(phieuthutienList); }
public List <PhieuThuTienDTO> GetBill(int idPTT) //SELECT* FROM account WHERE USERNAME = '******' { List <PhieuThuTienDTO> phieuthutienList = new List <PhieuThuTienDTO>(); DataTable data = DataProvider.Instance.ExecuteQuery("SELECT IDPTT, kh.CUSTOMERNAME , ptt.CARNUMBER , SOTIENTHU, ptt.CREATEDDATE FROM dbo.PHIEUTHUTIEN as ptt, dbo.HOSOKHACHHANG as kh WHERE kh.ID = ptt.IDKHACHHANG AND IDPTT = " + idPTT + ")"); foreach (DataRow item in data.Rows) { PhieuThuTienDTO phieuthutien = new PhieuThuTienDTO(item); phieuthutienList.Add(phieuthutien); } return(phieuthutienList); }
public List <PhieuThuTienDTO> GetDoanhThuByMonthYear(DateTime?createdDate) //SELECT* FROM account WHERE USERNAME = '******' { List <PhieuThuTienDTO> phieuthutienList = new List <PhieuThuTienDTO>(); DataTable data = DataProvider.Instance.ExecuteQuery("SELECT IDPTT, IDKHACHHANG, CARNUMBER, SOTIENTHU, CREATEDDATE FROM PHIEUTHUTIEN WHERE MONTH(CREATEDDATE) = MONTH('" + createdDate + "') AND YEAR(CREATEDDATE) = YEAR('" + createdDate + "')"); foreach (DataRow item in data.Rows) { PhieuThuTienDTO phieuthutien = new PhieuThuTienDTO(item); phieuthutienList.Add(phieuthutien); } return(phieuthutienList); }
public PhieuThuTienDTO searchKhachHang(string maKH, PhieuThuTienDTO obj) { string query = string.Empty; query += "SELECT *"; query += " FROM [PHIEUTHUTIEN]"; query += " WHERE "; query += " [MaKhachHang] like @MaKhachHang "; obj = new PhieuThuTienDTO(); using (SqlConnection conn = new SqlConnection(connectionString)) { using (SqlCommand comm = new SqlCommand()) { comm.Connection = conn; comm.CommandType = CommandType.Text; comm.CommandText = query; comm.Parameters.AddWithValue("@MaKhachHang", "%" + maKH.ToString() + "%"); try { conn.Open(); SqlDataReader reader = comm.ExecuteReader(); if (reader.HasRows == true) { //lsObj.Clear(); while (reader.Read()) { //PhieuThuTienDTO obj = new PhieuThuTienDTO(); obj.MaPT = reader["MaPhieuThu"].ToString(); //obj.STT = reader["HoTenKhachHang"].ToString(); obj.NgayThuTien = reader["NgayThuTien"].ToString(); obj.MaKH = reader["MaKhachHang"].ToString(); //obj.Email = reader["Email"].ToString(); obj.STT = Convert.ToInt32(reader["SoTienThu"].ToString()); //lsObj.Add(obj); } } } catch (Exception ex) { conn.Close(); //' lấy that bai!!! //return "Tìm khách hàng thất bại\n" + ex.Message + "\n" + ex.StackTrace; Console.WriteLine("Tìm khách hàng thất bại\n" + ex.Message + "\n" + ex.StackTrace); } } } return(obj); }
public string selectAll(List <PhieuThuTienDTO> lsObj) { string query = string.Empty; query += "SELECT *"; query += "FROM PHIEUTHUTIEN"; using (SqlConnection conn = new SqlConnection(connectionString)) { using (SqlCommand comm = new SqlCommand()) { comm.Connection = conn; comm.CommandType = CommandType.Text; comm.CommandText = query; try { conn.Open(); SqlDataReader reader = comm.ExecuteReader(); if (reader.HasRows == true) { lsObj.Clear(); while (reader.Read()) { PhieuThuTienDTO obj = new PhieuThuTienDTO(); obj.MaPT = reader["MaPhieuThu"].ToString(); //.STT = reader["SoTienThu"].ToString(); ////xem cách get ngày nhập trong c# .net nha bây //obj.DiaChi = reader["NgayThuTien"].ToString(); //obj.SDT = reader["DienThoai"].ToString(); //obj.Email = reader["Email"].ToString(); obj.STT = Convert.ToInt32(reader["SoTienThu"].ToString()); obj.NgayThuTien = reader["NgayThuTien"].ToString(); obj.MaKH = reader["MaKhachHang"].ToString(); lsObj.Add(obj); } } } catch (Exception ex) { conn.Close(); //' lấy that bai!!! return("Lấy thông tin khách hàng thất bại\n" + ex.Message + "\n" + ex.StackTrace); } } } return("0"); }
private void btnLapPhieu_Click(object sender, EventArgs e) { if (!fMainForm.cNullTB(cboBienSo.Text) && !fMainForm.cNullTB(cboTenChuXe.Text) && !fMainForm.cNullTB(txtDienThoai.Text) && !fMainForm.cNullTB(txtEmail.Text) && !fMainForm.cNullTB(txtSoTienNo.Text) && !fMainForm.cNullTB(txtSoTienNo.Text) && !fMainForm.cNullTB(txtTienKhachTra.Text)) { string BienSo = cboBienSo.Text; DateTime NgayThuTien = dtmNgayThuTien.Value; int SoTienKhachTra = int.Parse(txtTienKhachTra.Text); int SoTienTraKhach; int SoTienNo = int.Parse(txtSoTienNo.Text); if (SoTienNo > SoTienKhachTra) { SoTienTraKhach = 0; SoTienNo -= SoTienKhachTra; KhachSuaXeDAO.addTienNo(BienSo, SoTienNo); } else { SoTienTraKhach = SoTienKhachTra - SoTienNo; KhachSuaXeDAO.payTienNo(BienSo, SoTienNo); } int SoTienThu = SoTienNo; PhieuThuTienDTO PhieuThu = new PhieuThuTienDTO("", BienSo, NgayThuTien, SoTienThu, SoTienKhachTra, SoTienTraKhach); PhieuThuTienBUS.addPhieuThuTien(PhieuThu); dgvLichSuPTT.DataSource = PhieuThuTienBUS.selectAllPhieuThuTien(); #region Reset value of form after insertion cboBienSo.SelectedIndex = -1; dtmNgayThuTien.Value = DateTime.Today; cboTenChuXe.SelectedIndex = -1; txtDienThoai.Clear(); txtEmail.Clear(); txtSoTienNo.Clear(); txtTienKhachTra.Clear(); txtTienTraKhach.Clear(); #endregion } else { MessageBox.Show("Bạn chưa nhập vào đủ dữ liệu xin vui lòng nhập lại."); } }
private void btnSuaPhieu_Click(object sender, EventArgs e) { int currentRowIndex = this.dgvDanhSachPhieuThu.CurrentCellAddress.Y; //'current row selected //Verify that indexing OK if (-1 < currentRowIndex && currentRowIndex < dgvDanhSachPhieuThu.RowCount) { PhieuThuTienDTO obj = (PhieuThuTienDTO)dgvDanhSachPhieuThu.Rows[currentRowIndex].DataBoundItem; this.textBoxMaKH.Text = obj.MaKH; this.textBoxMaPhieuThu.Text = obj.MaPT; this.textBoxSoTienThu.Text = obj.STT.ToString(); this.dtpNgayThuTien.Text = obj.NgayThuTien; } else { MessageBox.Show("Chưa chọn phiếu thu trên lưới.", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
public string update(PhieuThuTienDTO obj) { string query = string.Empty; query += " UPDATE [PHIEUTHUTIEN] SET"; query += " [MaPhieuThu] = @MaPhieuThu, "; query += " [SoTienThu] = @SoTienThu, "; query += " [NgayThuTien] = @NgayThuTien, "; query += " [MaKhachHang] = @MaKhachHang "; //query += " [Email] = @Email, "; //query += "[SoTienNo] = @SoTienNo "; query += " WHERE "; query += " [MaPhieuThu] = @MaPhieuThu "; using (SqlConnection conn = new SqlConnection(connectionString)) { using (SqlCommand comm = new SqlCommand()) { comm.Connection = conn; comm.CommandType = CommandType.Text; comm.CommandText = query; comm.Parameters.AddWithValue("@MaPhieuThu", obj.MaPT); comm.Parameters.AddWithValue("@SoTienThu", obj.STT); comm.Parameters.AddWithValue("@NgayThuTien", obj.NgayThuTien); comm.Parameters.AddWithValue("@MaKhachHang", obj.MaKH); //comm.Parameters.AddWithValue("@Email", obj.Email); //comm.Parameters.AddWithValue("@SoTienNo", obj.SoTienNo); try { conn.Open(); comm.ExecuteNonQuery(); } catch (Exception ex) { conn.Close(); //' Cập nhật that bai!!! return("Sửa thông tin thất bại\n" + ex.Message + "\n" + ex.StackTrace); } } } return("0"); }
//Insert public static void insertPhieuThuTien(PhieuThuTienDTO PhieuThu) { MySqlConnection connect = DatabaseConnectionDAO.connectionDatabase(); MySqlCommand command = new MySqlCommand("InsertPHIEUTHUTIEN", connect); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@_BienSo", MySqlDbType.VarChar, 10); command.Parameters.Add("@_NgayThuTien", MySqlDbType.Date); command.Parameters.Add("@_SoTienThu", MySqlDbType.Decimal); command.Parameters.Add("@_SoTienKhachTra", MySqlDbType.Decimal); command.Parameters.Add("@_SoTienTraKhach", MySqlDbType.Decimal); command.Parameters["@_BienSo"].Value = PhieuThu.BienSo; command.Parameters["@_NgayThuTien"].Value = PhieuThu.NgayThuTien; command.Parameters["@_SoTienThu"].Value = PhieuThu.SoTienThu; command.Parameters["@_SoTienKhachTra"].Value = PhieuThu.SoTienKhachTra; command.Parameters["@_SoTienTraKhach"].Value = PhieuThu.SoTienTraKhach; connect.Open(); command.ExecuteNonQuery(); connect.Close(); }
public static void addPhieuThuTien(PhieuThuTienDTO PhieuThu) { PhieuThuTienDAO.insertPhieuThuTien(PhieuThu); }
public string update(PhieuThuTienDTO obj) { return(dal.update(obj)); }
public string delete(PhieuThuTienDTO obj) { return(dal.delete(obj)); }
public PhieuThuTienDTO searchKhachHang(string makh, PhieuThuTienDTO obj) { return(dal.searchKhachHang(makh, obj)); }