Beispiel #1
0
        public static List <ChiTietBaoDuongDTO> SelectChiTietBaoDuongByMaHoaDon(String MaHoaDon)
        {
            List <ChiTietBaoDuongDTO> list = new List <ChiTietBaoDuongDTO>();

            try
            {
                List <MySqlParameter> parameters = new List <MySqlParameter>();
                parameters.Add(new MySqlParameter("@FK_MaHD", MaHoaDon));

                DataTable dt = DAO.MySqlDataAccessHelper.ExecuteQuery("SELECT * FROM chitietbaoduong WHERE FK_MaHD = @MaHD", parameters);
                foreach (DataRow dr in dt.Rows)
                {
                    ChiTietBaoDuongDTO chiTiet = new ChiTietBaoDuongDTO();
                    chiTiet.MaCTBD    = dr["MaCTBD"].ToString();
                    chiTiet.MaCV      = dr["FK_MaCV"].ToString();
                    chiTiet.MaDV      = dr["FK_MaDV_CTBD"].ToString();
                    chiTiet.MaPT      = dr["FK_MaPT"].ToString();
                    chiTiet.Phi       = int.Parse(dr["Phi"].ToString());
                    chiTiet.SoLuong   = int.Parse(dr["SoLuong"].ToString());
                    chiTiet.TrangThai = bool.Parse(dr["TrangThai"].ToString());
                    chiTiet.MaHD      = dr["FK_MaHD"].ToString();
                    chiTiet.DonGia    = int.Parse(dr["DonGia"].ToString());

                    list.Add(chiTiet);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(list);
        }
Beispiel #2
0
        public static bool InsertChiTietBaoDuong(ChiTietBaoDuongDTO chitietbaoduong)
        {
            bool result = false;

            try
            {
                //create a list parameter
                List <MySqlParameter> parameters = new List <MySqlParameter>();
                //parameters.Add(new MySqlParameter("@MaTK", taikhoan.MaTK));
                parameters.Add(new MySqlParameter("@MaCTBD", chitietbaoduong.MaCTBD));
                parameters.Add(new MySqlParameter("@TrangThai", chitietbaoduong.TrangThai));

                parameters.Add(new MySqlParameter("@Phi", chitietbaoduong.Phi));
                parameters.Add(new MySqlParameter("@FK_MaPT", chitietbaoduong.MaPT));
                parameters.Add(new MySqlParameter("@FK_MaDV_CTBD", chitietbaoduong.MaDV));
                parameters.Add(new MySqlParameter("@FK_MaHD", chitietbaoduong.MaHD));
                parameters.Add(new MySqlParameter("@FK_MaCV", chitietbaoduong.MaCV));
                parameters.Add(new MySqlParameter("@SoLuong", chitietbaoduong.SoLuong));
                parameters.Add(new MySqlParameter("@DonGia", chitietbaoduong.DonGia));

                //call store Procedure
                int n = MySqlDataAccessHelper.ExecuteNonQuery("INSERT INTO chitietbaoduong (MaCTBD, TrangThai,  Phi, FK_MaPT, FK_MaDV_CTBD, FK_MaHD, FK_MaCV,SoLuong, DonGia) VALUES(@MaCTBD, @TrangThai,  @Phi, @FK_MaPT, @FK_MaDV_CTBD, @FK_MaHD, @FK_MaCV, @SoLuong, @DonGia)", parameters);
                if (n == 1)
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Beispiel #3
0
 public bool InsertPhanCong()
 {
     //List<PhanCongDTO> listPhanCong = new List<PhanCongDTO>();
     foreach (DataGridViewRow row in congViecdataGridView.Rows)
     {
         if (bool.Parse(row.Cells["Chọn"].Value.ToString()) == true)
         {
             PhanCongDTO phancong = new PhanCongDTO();
             phancong.MaPC     = BUS.PhanCongBUS.GenerateMaPhanCong();
             phancong.MaDV     = txtMaDV.Text;
             phancong.MaNV     = BUS.NhanVienBUS.SelectNhanVienByTenNhanVien(row.Cells["Nhân viên"].Value.ToString())[0].MaNV;
             phancong.MaCV     = (row.Cells["Công việc"].Value.ToString());
             phancong.ThoiGian = dtbNgayLapHD.Value;
             phancong.GhiChu   = row.Cells["Ghi Chú"].Value.ToString();
             if (!BUS.PhanCongBUS.InsertPhanCong(phancong))
             {
                 return(false);
             }
             ;
         }
         else
         {
             ChiTietBaoDuongDTO chiTiet = new ChiTietBaoDuongDTO
             {
                 MaCTBD    = BUS.ChiTietBaoDuongBUS.GenerateMaChiTietBaoDuong(),
                 MaPT      = null,
                 SoLuong   = 0,
                 DonGia    = 0,
                 Phi       = 0,
                 TrangThai = false,
                 MaHD      = null,
                 MaCV      = row.Cells["Mã CV"].Value.ToString(),
                 MaDV      = txtMaDV.Text
             };
         }
     }
     return(true);
 }
Beispiel #4
0
 public bool InsertChiTietBaoDuong()
 {
     foreach (DataGridViewRow row in phuTungChiTietBDdataGridView.Rows)
     {
         ChiTietBaoDuongDTO chiTiet = new ChiTietBaoDuongDTO
         {
             MaCTBD    = BUS.ChiTietBaoDuongBUS.GenerateMaChiTietBaoDuong(),
             MaPT      = row.Cells["MãPT"].Value.ToString(),
             SoLuong   = int.Parse(row.Cells["Số lượng"].Value.ToString()),
             DonGia    = int.Parse(row.Cells["Giá"].Value.ToString()),
             Phi       = int.Parse(row.Cells["Thành tiền"].Value.ToString()),
             TrangThai = true,
             MaHD      = txtMaHD.Text,
             MaCV      = row.Cells["Mã CV"].Value.ToString(),
             MaDV      = txtMaDV.Text
         };
         if (!BUS.ChiTietBaoDuongBUS.InsertChiTietBaoDuong(chiTiet))
         {
             return(false);
         }
         ;
     }
     return(true);
 }
 public static bool InsertChiTietBaoDuong(ChiTietBaoDuongDTO chiTiet)
 {
     return(DAO.ChiTietBaoDuongDAO.InsertChiTietBaoDuong(chiTiet));
 }