Beispiel #1
0
        private void btnThongKe_Click(object sender, EventArgs e)
        {
            HoSoDTO hs = hoSoBUL.LayNhanVienTheoMa(Convert.ToInt32(cbbMaNhanVien.SelectedValue.ToString()));

            SetParameter(Convert.ToInt32(cbbMaNhanVien.SelectedValue.ToString()), hs.MaPhongBan);
            reportViewer1.RefreshReport();
        }
Beispiel #2
0
        //Xoa Thong Tin Dai Ly
        public bool Xoa(HoSoDTO hs)
        {
            string query = string.Empty;

            query += "delete from [PhieuXuathang] where [PhieuXuathang].[maDaiLy] = @maDaiLy ";
            query += "delete from [DaiLy] where [DaiLy].[maDaiLy] = @maDaiLy";
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@maDaiLy", hs.ma);
                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(false);
                    }
                }
            }
            return(true);
        }
Beispiel #3
0
        //Sua tien no toi da cua 1 loai dai ly
        public bool suaTienNoToiDa(HoSoDTO hs)
        {
            string query = string.Empty;

            query += "Update [LoaiDaiLy] set [LoaiDaiLy].[noToiDa] = @noToiDa where [LoaiDaiLy].[maLoaiDaiLy] = @maLoaiDaiLy";
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = query;

                    cmd.Parameters.AddWithValue("@maLoaiDaiLy", hs.loai);
                    cmd.Parameters.AddWithValue("@noToiDa", hs.noToiDa);

                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(false);
                    }
                }
            }
            return(true);
        }
Beispiel #4
0
        public HoSoDTO LayNhanVienTheoMa(int maNhanVien)
        {
            HoSoDTO hs = null;

            KetNoiCSDL.MoKetNoi();
            string     sqlSelect = "Select * from hoso where manhanvien=@ma";
            SqlCommand cmd       = new SqlCommand(sqlSelect, KetNoiCSDL.KetNoi);

            cmd.Parameters.AddWithValue("ma", maNhanVien);

            SqlDataReader dr = cmd.ExecuteReader();

            dr.Read();

            hs = new HoSoDTO(
                Convert.ToInt32(dr["manhanvien"]),
                dr["hodem"].ToString(),
                dr["tendem"].ToString(),
                dr["ngaysinh"].ToString(),
                dr["gioitinh"].ToString(),
                dr["sodienthoai"].ToString(),
                dr["email"].ToString(),
                dr["ngaytuyendung"].ToString(),
                Convert.ToInt32(dr["maphongban"])
                );
            KetNoiCSDL.DongKetNoi();
            return(hs);
        }
Beispiel #5
0
        public List <HoSoDTO> LayBangHoSo()
        {
            List <HoSoDTO> ds = new List <HoSoDTO>();

            KetNoiCSDL.MoKetNoi();
            string        sqlSelect = "select * from hoso";
            SqlCommand    cmd       = new SqlCommand(sqlSelect, KetNoiCSDL.KetNoi);
            SqlDataReader dr        = cmd.ExecuteReader();

            while (dr.Read())
            {
                DateTime date2 = DateTime.Parse(dr["ngaytuyendung"].ToString());
                DateTime date3 = DateTime.Parse(dr["ngaysinh"].ToString());
                HoSoDTO  hs    = new HoSoDTO(
                    Convert.ToInt32(dr["manhanvien"]),
                    dr["hodem"].ToString(),
                    dr["tendem"].ToString(),
                    date3.ToString("dd/MM/yyyy"),
                    dr["gioitinh"].ToString(),
                    dr["sodienthoai"].ToString(),
                    dr["email"].ToString(),
                    date2.ToString("dd/MM/yyyy"),
                    Convert.ToInt32(dr["maphongban"])
                    );
                ds.Add(hs);
            }
            KetNoiCSDL.DongKetNoi();
            return(ds);
        }
Beispiel #6
0
        private void bt_xoa_Click(object sender, EventArgs e)
        {
            int currentRowIndex = data_tiepnhan.CurrentCellAddress.Y;// 'current row selected

            //'Verify that indexing OK
            if (-1 < currentRowIndex && currentRowIndex < data_tiepnhan.RowCount)
            {
                HoSoDTO hs = new HoSoDTO();
                hs.Mahs = int.Parse(tb_ma.Text);

                //2. Kiểm tra data hợp lệ or not

                //3. Thêm vào DB
                bool kq = hsBus.xoa(hs);
                if (kq == false)
                {
                    MessageBox.Show("Xóa hồ sơ thất bại. Vui lòng kiểm tra lại dũ liệu");
                }
                else
                {
                    MessageBox.Show("Xóa hồ sơ thành công");
                    this.loadData_Vao_GridView();
                }
            }
            CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[data_tiepnhan.DataSource];

            myCurrencyManager.Refresh();
        }
Beispiel #7
0
        private void bt_luu_Click(object sender, EventArgs e)
        {
            if (check_null())
            {
                HoSoDTO hs = new HoSoDTO();
                hs.Mahs         = int.Parse(tb_ma.Text);
                hs.Ten          = tb_tenchuxe.Text;
                hs.Diachi       = tb_diachi.Text;
                hs.Bienso       = tb_bienso.Text;
                hs.Dienthoai    = int.Parse(tb_dienthoai.Text);
                hs.Hieuxe       = int.Parse(cb_hieuxe.SelectedValue.ToString());
                hs.Ngaytiepnhan = time_ngaytiepnhan.Value;

                //2. Kiểm tra data hợp lệ or not

                //3. Thêm vào DB
                bool kq = hsBus.them(hs);
                if (kq == false)
                {
                    MessageBox.Show("Thêm hồ sơ thất bại. Vui lòng kiểm tra lại dữ liệu");
                }
                else
                {
                    MessageBox.Show("Thêm hồ sơ thành công");
                    this.loadData_Vao_GridView();
                }
                CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[data_tiepnhan.DataSource];
                myCurrencyManager.Refresh();
            }
        }
Beispiel #8
0
        public bool sua(HoSoDTO hs)
        {
            string query = string.Empty;

            query += "UPDATE HOSO SET [TenChuXe] = @TenChuXe, [DiaChi] = @DiaChi,[BienSo] = @BienSo,[DienThoai] = @DienThoai,[MaHieuXe] = @MaHieuXe,[NgayTiepNhan] = @NgayTiepNhan WHERE [MaHoSo] = @MaHoSo";
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@MaHoSo", hs.Mahs);
                    cmd.Parameters.AddWithValue("@TenChuXe", hs.Ten);
                    cmd.Parameters.AddWithValue("@DiaChi", hs.Diachi);
                    cmd.Parameters.AddWithValue("@BienSo", hs.Bienso);
                    cmd.Parameters.AddWithValue("@DienThoai", hs.Dienthoai);
                    cmd.Parameters.AddWithValue("@MaHieuXe", hs.Hieuxe);
                    cmd.Parameters.AddWithValue("@NgayTiepNhan", hs.Ngaytiepnhan);
                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(false);
                    }
                }
            }
            return(true);
        }
Beispiel #9
0
        //So quan toi da
        public bool sua_quanToiDa(HoSoDTO hs)
        {
            string query = string.Empty;

            query += "Update [QuyDinh] set [QuyDinh].[quanToiDa] = @quanToiDa";

            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = query;

                    cmd.Parameters.AddWithValue("@quanToiDa", hs.quanToida);

                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }

                    catch (Exception ex)
                    {
                        con.Close();
                        return(false);
                    }
                }
            }

            return(true);
        }
Beispiel #10
0
        public bool xoaQuan(HoSoDTO hs)
        {
            string query = string.Empty;

            query += "Delete from [QuanDaiLy] where [QuanDaiLy].[tenQuan] = @tenQuan";
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = query;

                    cmd.Parameters.AddWithValue("@tenQuan", hs.tenQuan);

                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }

                    catch (Exception ex)
                    {
                        con.Close();
                        return(false);
                    }
                }
            }

            return(true);
        }
Beispiel #11
0
        public bool xoa(HoSoDTO hs)
        {
            string query = string.Empty;

            query += "DELETE FROM HOSO WHERE [MaHoSo] = @MaHoSo";
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@MaHoSo", hs.Mahs);
                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(false);
                    }
                }
            }
            return(true);
        }
Beispiel #12
0
        public List <HoSoDTO> selectByKeyWord(string sKwBienSo, string sKwHieuXe, string sKwChuXe, string sKwMaHoSo, string sKwDienThoai)
        {
            string query = string.Empty;

            query += "SELECT[MaHoSo],[TenChuXe],[DiaChi],[BienSo],[DienThoai],[dbo].[HOSO].MaHieuXe,[NgayTiepNhan],[dbo].HIEUXE.HieuXe";
            query += " FROM [HOSO]";
            query += " join [dbo].HIEUXE on [dbo].[HOSO].MaHieuXe = [dbo].HIEUXE.MaHieuXe";
            query += " WHERE ([BienSo] LIKE CONCAT('%',@sKwBienSo,'%'))";
            query += " AND ([HieuXe] LIKE CONCAT('%',@sKwHieuXe,'%'))";
            query += " AND ([TenChuXe] LIKE CONCAT('%',@sKwChuXe,'%'))";
            query += " AND ([MaHoSo] LIKE CONCAT('%',@sKwMaHoSo,'%'))";
            query += " AND ([DienThoai] LIKE CONCAT('%',@sKwDienThoai,'%'))";
            List <HoSoDTO> lsHoso = new List <HoSoDTO>();

            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@sKwBienSo", sKwBienSo);
                    cmd.Parameters.AddWithValue("@sKwHieuXe", sKwHieuXe);
                    cmd.Parameters.AddWithValue("@sKwChuXe", sKwChuXe);
                    cmd.Parameters.AddWithValue("@sKwMaHoSo", sKwMaHoSo);
                    cmd.Parameters.AddWithValue("@sKwDienThoai", sKwDienThoai);
                    try
                    {
                        con.Open();
                        SqlDataReader reader = null;
                        reader = cmd.ExecuteReader();
                        if (reader.HasRows == true)
                        {
                            while (reader.Read())
                            {
                                HoSoDTO hs = new HoSoDTO();
                                hs.Mahs         = int.Parse(reader["MaHoSo"].ToString());
                                hs.Ten          = reader["TenChuXe"].ToString();
                                hs.Diachi       = reader["DiaChi"].ToString();
                                hs.Bienso       = reader["BienSo"].ToString();
                                hs.Dienthoai    = int.Parse(reader["DienThoai"].ToString());
                                hs.Hieuxe       = int.Parse(reader["Mahieuxe"].ToString());
                                hs.Tenhieuxe    = reader["HieuXe"].ToString();
                                hs.Ngaytiepnhan = DateTime.Parse(reader["NgayTiepNhan"].ToString());
                                lsHoso.Add(hs);
                            }
                        }

                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(null);
                    }
                }
            }
            return(lsHoso);
        }
Beispiel #13
0
        private void xoa_btn_Click(object sender, EventArgs e)
        {
            HoSoDTO hs = new HoSoDTO();

            hs.tenQuan = tenQuan_txt.Text;
            hsBus.xoa_Quan(hs);
            quanGrid.DataSource = hsBus.loadQuan();
        }
Beispiel #14
0
 //Create
 public object insertHoSo(HoSoDTO dtoHoSo)
 {
     dalHoSo = new HoSoDAL();
     try
     {
         return dalHoSo.insertHoSo(dtoHoSo);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #15
0
        private void bt_lapphieuthutien_Click(object sender, EventArgs e)
        {
            int currentRowIndex = data_tracuu.CurrentCellAddress.Y;// 'current row selected


            //'Verify that indexing OK
            if (-1 < currentRowIndex && currentRowIndex < data_tracuu.RowCount)
            {
                HoSoDTO hs = (HoSoDTO)data_tracuu.Rows[currentRowIndex].DataBoundItem;
                if (hs != null)
                {
                    frmPhieuThuTien frm = new frmPhieuThuTien(hs);
                    frm.ShowDialog();
                }
            }
        }
Beispiel #16
0
 //Create
 public object insertHoSo(HoSoDTO dtoHoSo)
 {
     db = new DBLib();
     try
     {
         db.AddParameter("@MaPT", dtoHoSo.MaPT);
         db.AddParameter("@MaChuPT", dtoHoSo.MaChuPT);
         db.AddParameter("@MaChuCuPT", dtoHoSo.MaChuCuPT);
         db.AddParameter("@GhiChu", dtoHoSo.GhiChu);
         return db.ExecuteScalar("sp_InsertHoSo", CommandType.StoredProcedure);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #17
0
        private void frmXoaHoSo_Load(object sender, EventArgs e)
        {
            lblMaNV.Text = this.Tag.ToString();
            HoSoDTO ds = hoSoBUL.LayDSHoSoTheoMa(Convert.ToInt32(this.Tag.ToString()))[0];

            txtHo.Text       = ds.HoDem;
            txtTen.Text      = ds.TenDem;
            txtNgaySInh.Text = ds.NgaySinh;
            txtGT.Text       = ds.GioiTinh;
            txtSoDT.Text     = ds.SoDienThoai;
            txtEmail.Text    = ds.Email;
            txtNgayTD.Text   = ds.NgayTuyenDung;
            PhongBanDTO pb = phongBanBUL.LayPhongBanTheoMaNV(Convert.ToInt32(this.Tag.ToString()));

            txtMaPhongBan.Text = pb.TenPhongBan;
        }
Beispiel #18
0
        private void xoa_btn_Click(object sender, EventArgs e)
        {
            HoSoDTO hs = new HoSoDTO();

            hs.loai = int.Parse(maLoai_txt.Text);
            bool kq = hsBus.xoaLoai(hs);

            if (kq == true)
            {
                MessageBox.Show("Xóa thành công");
            }
            else
            {
                MessageBox.Show("Xóa thất bại");
            }
        }
Beispiel #19
0
        private void them_btn_Click(object sender, EventArgs e)
        {
            HoSoDTO hs = new HoSoDTO();

            hs.tenQuan = tenQuan_txt.Text;
            bool kq = hsBus.them_Quan(hs);

            if (kq == true)
            {
                MessageBox.Show("Thêm Thành Công");
            }
            else
            {
                MessageBox.Show("Thêm Thất Bại");
            }
            quanGrid.DataSource = hsBus.loadQuan();
        }
Beispiel #20
0
        private void UCInHoSo_Load(object sender, EventArgs e)
        {
            this.V_HOSONVTableAdapter.Fill(this.QUANLYNHANSUDataSet.V_HOSONV);
            this.reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.PageWidth;
            this.reportViewer1.RefreshReport();

            cbbMaNhanVien.DataSource    = hoSoBUL.LayDSHoSo();
            cbbMaNhanVien.DisplayMember = "manhanvien";
            cbbMaNhanVien.ValueMember   = "manhanvien";
            lbTen.Text = hoSoBUL.LayTenTheoMaNhanVien(Convert.ToInt32(cbbMaNhanVien.SelectedValue.ToString()));

            HoSoDTO hs = hoSoBUL.LayNhanVienTheoMa(Convert.ToInt32(cbbMaNhanVien.SelectedValue.ToString()));

            SetParameter(Convert.ToInt32(cbbMaNhanVien.SelectedValue.ToString()), hs.MaPhongBan);
            reportViewer1.RefreshReport();
        }
Beispiel #21
0
        private void Sua_btn_Click(object sender, EventArgs e)
        {
            HoSoDTO hs = new HoSoDTO();

            hs.noToiDa = int.Parse(tienNo_txt.Text);
            hs.loai    = int.Parse(maLoaiDaiLy_txt.Text);
            bool kq = hsBus.suaTienNoToiDa(hs);

            if (kq == true)
            {
                MessageBox.Show("Sửa Thành Công");
            }
            else
            {
                MessageBox.Show("Sửa Thất Bại");
            }
            loaiDaiLyGrid.DataSource = hsBus.LoadLoaidaiLy();
        }
Beispiel #22
0
        //Sua thong tin dai ly
        public bool Sua(HoSoDTO hs)
        {
            string query = string.Empty;

            query += "Update [DaiLy] ";
            query += "set [tenDaiLy] = @tenDaiLy ,";
            query += "[maLoaiDaiLy] = @maLoaiDaiLy , ";
            query += "[dienThoai] = @dienThoai, ";
            query += "[tenQuan] = @tenQuan, ";
            query += "[email] = @email, ";
            query += "[ngayTiepNhan] = @ngayTiepNhan, ";
            query += "[diaChi] = @diaChi";
            query += " where [maDaiLy] = @maDaiLy";
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@maDaiLy", hs.ma);
                    cmd.Parameters.AddWithValue("@tenDaiLy", hs.tenHoSo);
                    cmd.Parameters.AddWithValue("@maLoaiDaiLy", hs.loai);
                    cmd.Parameters.AddWithValue("@tenQuan", hs.tenQuan);
                    cmd.Parameters.AddWithValue("@dienThoai", hs.dienThoai);
                    cmd.Parameters.AddWithValue("@diaChi", hs.diaChi);
                    cmd.Parameters.AddWithValue("@ngayTiepNhan", hs.day);
                    cmd.Parameters.AddWithValue("@email", hs.email);
                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(false);
                    }
                }
            }
            return(true);
        }
Beispiel #23
0
        private void bt_lapphieusuachua_Click(object sender, EventArgs e)
        {
            //frmPhieuSuaChua frm = new frmPhieuSuaChua();
            //frm.MdiParent = this;
            //frm.Show();//
            int currentRowIndex = data_tiepnhan.CurrentCellAddress.Y;// 'current row selected


            //'Verify that indexing OK
            if (-1 < currentRowIndex && currentRowIndex < data_tiepnhan.RowCount)
            {
                HoSoDTO hs = (HoSoDTO)data_tiepnhan.Rows[currentRowIndex].DataBoundItem;
                if (hs != null)
                {
                    frmPhieuSuaChua frm = new frmPhieuSuaChua(hs);
                    frm.ShowDialog();
                }
            }
        }
Beispiel #24
0
        //Them vao thong tin dai ly
        public bool Them(HoSoDTO hs)
        {
            string query = string.Empty;

            query += "Insert into DaiLy([maDaiLy], [tenDaiLy],[maLoaiDaiLy],[tenQuan],[dienThoai],[diaChi],[ngayTiepNhan],[email]) ";
            query += "values(@maDaiLy , @tenDaiLy , @maLoaiDaiLy , @tenQuan , @dienThoai , @diaChi , @ngayTiepNhan , @email)";

            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;

                    cmd.Parameters.AddWithValue("@maDaiLy", hs.ma);
                    cmd.Parameters.AddWithValue("@tenDaiLy", hs.tenHoSo);
                    cmd.Parameters.AddWithValue("@maLoaiDaiLy", hs.loai);
                    cmd.Parameters.AddWithValue("@tenQuan", hs.tenQuan);
                    cmd.Parameters.AddWithValue("@dienThoai", hs.dienThoai);
                    cmd.Parameters.AddWithValue("@diaChi", hs.diaChi);
                    cmd.Parameters.AddWithValue("@ngayTiepNhan", hs.day);
                    cmd.Parameters.AddWithValue("@email", hs.email);

                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        return(false);
                    }
                }
            }

            return(true);
        }
Beispiel #25
0
        private void OK_btn_Click(object sender, EventArgs e)
        {
            HoSoDTO hs = new HoSoDTO();
            bool    kq = false;

            if (checkDaiLyMax.Checked == true)
            {
                hs.daiLyToiDa = int.Parse(DaiLyMax_txt.Text);
                kq            = hsBus.suaDaiLyToiDa(hs);
            }

            if (checkLoai.Checked == true)
            {
                if (int.Parse(LoaiDaiLyMax_txt.Text) < hsBus.getSoLoaiDaiLy())
                {
                    MessageBox.Show("Hiện đang có nhiều hơn loại đại lý định sửa làm ơn xóa bớt !!");
                }
                else
                {
                    hs.max_LoaiDaiLy = int.Parse(LoaiDaiLyMax_txt.Text);
                    kq = hsBus.suaLoaiDaiLyToiDa(hs);
                }
            }

            if (quanToiDaCheck.Checked == true)
            {
                hs.quanToida = int.Parse(quanToiDa_txt.Text);
                kq           = hsBus.sua_quanToiDa(hs);
            }

            if (kq == false)
            {
                MessageBox.Show("Sửa Thất Bại");
            }
            else
            {
                MessageBox.Show("Sửa Thành Công");
            }
        }
Beispiel #26
0
        //Them loai dai ly
        public bool them_loaiDaiLy(HoSoDTO hs)
        {
            string query = string.Empty;

            query += "Insert into [LoaiDaiLy]([maLoaiDaiLy], [noToiDa]) ";
            query += "values(@maLoaiDaiLy , @noToiDa)";

            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = query;

                    cmd.Parameters.AddWithValue("@maLoaiDaiLy", hs.loai);
                    cmd.Parameters.AddWithValue("@noToiDa", hs.noToiDa);

                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }

                    catch (Exception ex)
                    {
                        con.Close();
                        return(false);
                    }
                }
            }

            return(true);
        }
Beispiel #27
0
        //Load danh sach dai ly theo tim kiem
        public DataTable search(HoSoDTO hs, bool ngay)
        {
            DataTable searchdt = new DataTable();
            string    query    = string.Empty;

            query += "select [maDaiLy] as N'Mã Đại Lý' , [tenDaiLy] as 'Tên Đại Lý' , [maLoaiDaiLy] as N'Mã Loại Đại Lý', [dienThoai] as N'Điện Thoại', [diaChi] as N'Địa Chỉ', [tenQuan] as N'Tên Quận', [ngayTiepNhan] as N'Ngày Tiếp Nhận', [email] from [DaiLy] where ";
            bool multiSearch = false;

            if (hs.ma.ToString().Trim().Length != 0 && hs.ma != 0)
            {
                multiSearch = true;
                query      += "[maDaiLy] like N'" + hs.ma + "'";
            }

            if (hs.tenHoSo.Trim().Length != 0 && hs.tenHoSo.Length > 0)
            {
                if (multiSearch == true)
                {
                    query += " and ";
                }
                query      += "[tenDaiLy] like N'%" + hs.tenHoSo + "%'";
                multiSearch = true;
            }

            if (hs.loai.ToString().Trim().Length != 0 && hs.loai.ToString().Length > 0 && hs.loai != 0)
            {
                if (multiSearch == true)
                {
                    query += " and ";
                }
                query      += "[maLoaiDaiLy] like N'%" + hs.loai + "%'";
                multiSearch = true;
            }

            if (hs.dienThoai.ToString().Trim().Length != 0 && hs.dienThoai.ToString().Length > 0 && hs.dienThoai != 0)
            {
                if (multiSearch == true)
                {
                    query += " and ";
                }
                query      += "[dienThoai] like N'%" + hs.dienThoai + "%'";
                multiSearch = true;
            }

            if (hs.diaChi.Trim().Length != 0 && hs.diaChi.Length > 0)
            {
                if (multiSearch == true)
                {
                    query += " and ";
                }
                query      += "[diaChi] like N'%" + hs.diaChi + "%'";
                multiSearch = true;
            }

            if (hs.tenQuan.Trim().Length != 0 && hs.tenQuan.Length > 0)
            {
                if (multiSearch == true)
                {
                    query += " and ";
                }
                query      += "[tenQuan] like N%'" + hs.tenQuan + "%'";
                multiSearch = true;
            }

            if (hs.email.Trim().Length != 0 && hs.email.Length > 0)
            {
                if (multiSearch == true)
                {
                    query += " and ";
                }
                query      += "[email] like N'%" + hs.email + "%'";
                multiSearch = true;
            }

            if (ngay == true)
            {
                if (multiSearch == true)
                {
                    query += " and ";
                }
                query += "(convert(varchar, [DaiLy].[ngayTiepNhan], 103) = @ngayTiepNhan)";
            }


            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = query;

                    cmd.Parameters.AddWithValue("@ngayTiepNhan", hs.day.ToShortDateString());


                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    searchdt.Load(reader);
                    con.Close();
                }
            }
            return(searchdt);
        }
Beispiel #28
0
        public bool sua_quanToiDa(HoSoDTO hs)
        {
            bool re = hsDAL.sua_quanToiDa(hs);

            return(re);
        }
Beispiel #29
0
        public bool xoa_Quan(HoSoDTO hs)
        {
            bool re = hsDAL.xoaQuan(hs);

            return(re);
        }
Beispiel #30
0
        public bool them_Quan(HoSoDTO hs)
        {
            bool re = hsDAL.themQuan(hs);

            return(re);
        }
Beispiel #31
0
        public bool them_loaiDaiLy(HoSoDTO hs)
        {
            bool re = hsDAL.them_loaiDaiLy(hs);

            return(re);
        }
Beispiel #32
0
        public bool suaTienNoToiDa(HoSoDTO hs)
        {
            bool re = hsDAL.suaTienNoToiDa(hs);

            return(re);
        }