예제 #1
0
        private CongViecDTO checkData()
        {
            string ma  = txtMaCongViec.Text;
            string ten = txtTenCongViec.Text;
            string z   = string.Join("", txtMaCongViec.Text.Where(char.IsDigit));

            if (txtMaCongViec.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn Chưa Nhập Mã Công Việc", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtMaCongViec.Focus();
                return(null);
            }
            else if (txtTenCongViec.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn Chưa Nhập Tên Công Việc", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtTenCongViec.Focus();
                txtTenCongViec.Focus();
                return(null);
            }
            else if (txtMaCongViec.Text.Contains("CV") == false)
            {
                MessageBox.Show("Nhập Theo Định Dạng Là \"CV\"", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); 
 txtMaCongViec.Focus(); 
                return(null);
            }
            
            else if (z == "")
            {
                MessageBox.Show("Nhập Theo Định Dạng Là \"CV\" và Thêm Số Đằng Sau", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); 
 txtMaCongViec.Focus(); 
                return(null);
            }
            CongViecDTO dto = new CongViecDTO(ma, Handling.FormHandling.formatString(ten));

            return(dto);
        }
        public static List <CongViecDTO> SelectCongViecByTenCongViec(String tenCV)
        {
            List <CongViecDTO> list = new List <CongViecDTO>();

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

                DataTable dt = MySqlDataAccessHelper.ExecuteQuery("SELECT * FROM congviec where TenCV = @TenCV", parameters);
                foreach (DataRow dr in dt.Rows)
                {
                    CongViecDTO congviec = new CongViecDTO();
                    congviec.MaCV  = dr["MaCV"].ToString();
                    congviec.TenCV = dr["TenCV"].ToString();
                    congviec.MoTa  = dr["MoTa"].ToString();
                    list.Add(congviec);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(list);
        }
예제 #3
0
        public List <CongViecDTO> GetAllCongViec()
        {
            List <CongViecDTO> list             = new List <CongViecDTO>();
            string             connectionString = DataAccess.Internal.DataAccess.GetConnectionString("TodoListDb");

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();

                // Set up a command with the given query and associate
                // this with the current connection.
                string query = @"select * from CongViec";
                using (SqlCommand cmd = new SqlCommand(query, con))
                {
                    using (IDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            CongViecDTO cv = new CongViecDTO();
                            cv.Id          = Convert.ToInt32(dr[0].ToString());
                            cv.NgayBatDau  = dr[3].ToString();
                            cv.NgayKetThuc = dr[4].ToString();
                            cv.PhamVi      = (bool)dr["IsPublic"];
                            cv.Status      = Convert.ToInt32(dr["Status"].ToString());
                            cv.TenCongViec = dr[1].ToString();
                            cv.BinhLuan    = dr[6].ToString();
                            cv.FileDinhKem = dr[5].ToString();
                            list.Add(cv);
                        }
                    }
                }
            }
            return(list);
        }
예제 #4
0
        public List <CongViecDTO> GetAllCongViecNVcv(string idCv, string idNv)
        {
            List <CongViecDTO> list             = new List <CongViecDTO>();
            string             connectionString = DataAccess.Internal.DataAccess.GetConnectionString("TodoListDb");

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();

                // Set up a command with the given query and associate
                // this with the current connection.
                string query = @"select cv.StartDate,cv.EndDate,pc.comment from CongViec cv,PhanCong pc , NhanVien nv"
                               + "where nv.id = pc.idnhanvien"
                               + "and cv.id = pc.idcongviec"
                               + "and nv.id = " + idNv + ""
                               + "and cv.id = " + idCv;
                using (SqlCommand cmd = new SqlCommand(query, con))
                {
                    using (IDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            CongViecDTO cv = new CongViecDTO();
                            cv.NgayBatDau  = dr[0].ToString();
                            cv.NgayKetThuc = dr[1].ToString();
                            cv.BinhLuan    = dr[2].ToString();
                            list.Add(cv);
                        }
                    }
                }
            }
            return(list);
        }
예제 #5
0
        internal List <CongViecDTO> getCongViecById(string v)
        {
            List <CongViecDTO> list             = new List <CongViecDTO>();
            string             connectionString = DataAccess.Internal.DataAccess.GetConnectionString("TodoListDb");

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();

                // Set up a command with the given query and associate
                // this with the current connection.
                string query = @"SELECT cv.id,cv.NameCongViec from CongViec cv 
                WHERE cv.id not in (SELECT idcongviec from PhanCong WHERE IdNhanVien = " + v + ") ";
                using (SqlCommand cmd = new SqlCommand(query, con))
                {
                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            CongViecDTO cv = new CongViecDTO();
                            cv.Id          = Convert.ToInt32(dr["Id"].ToString());
                            cv.TenCongViec = dr["NameCongViec"].ToString();
                            list.Add(cv);
                        }
                    }
                }
            }
            return(list);
        }
예제 #6
0
        public async Task <IActionResult> UpdateCongViec(int id, [FromBody] CongViecDTO congViecDTO)
        {
            var congViec = congViecDTO.ToEntity();
            await _congViecService.UpdateCongViec(congViec);

            return(Ok(congViec));
        }
예제 #7
0
        public async Task <IActionResult> CreateCongViec(CongViecDTO congViecDTO)
        {
            var congViec = congViecDTO.ToEntity();
            await _congViecService.CreateCongViec(congViec);

            return(Ok(congViec));
        }
예제 #8
0
 public static CongViec ToCongViec(this CongViecDTO congViecDTO)
 {
     return(new CongViec()
     {
         CongViecId = congViecDTO.CongViecId,
         TenCongViec = congViecDTO.TenCongViec
     });
 }
예제 #9
0
        public async Task <IActionResult> GetCongViecById(int id)
        {
            var congViec = await _congViecService.GetCongViecById(id);

            var result = CongViecDTO.FromEntity(congViec);

            return(Ok(result));
        }
예제 #10
0
 public static void saveCV(CongViecDTO hs, string method)
 {
     SqlParameter[] sqlP = new SqlParameter[2];
     sqlP[0] = new SqlParameter("@MaCV", hs.MaCV1);
     sqlP[1] = new SqlParameter("@TenCV", hs.TenCV1);
     if (method == sys.INSERT)
     {
         GenericDAL.execNonQuery("sp_InsertCongViec", sqlP, Conn);
     }
     else if (method == sys.UPDATE)
     {
         GenericDAL.execNonQuery("sp_UpdateCongViec", sqlP, Conn);
     }
 }
예제 #11
0
 /// <summary>
 /// tìm theo công viec nhan vien
 /// </summary>
 /// <param name="cv"></param>
 /// <returns></returns>
 public static DataTable Search_Congviec_NV(CongViecDTO cv)
 {
     try
     {
         DataTable dt         = new DataTable();
         string    search_ten = string.Format("SELECT ma_nv,ten_nv,ngay_sinh,gioi_tinh,sdt_nv,dia_chi_nv,email,db_chucvu.ten_cv FROM db_nhanvien,db_chucvu WHERE db_nhanvien.ma_cv = db_chucvu.ma_cv and db_chucvu.ten_cv='{0}'", cv.ten_cv);
         cnn = DataProvider.ConnectData();
         MySqlDataAdapter dta = new MySqlDataAdapter(search_ten, cnn);
         dta.Fill(dt);
         cnn.Close();
         return(dt);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #12
0
 private void btnSua_Click(object sender, EventArgs e)
 {
     if (checkDuplicate() == 2)
     {
         MessageBox.Show("Không Có Mã Đó Để Thay Đổi Liên Quan", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         txtMaCongViec.Text = "";
         return;
     }
     else
     {
         CongViecDTO ob = checkData();
         if (ob != null)
         {
             B_CongViec.saveCV(ob, sys.UPDATE);
             MessageBox.Show("Sửa Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             dt = B_CongViec.GetAllCV();
             dgvCongViec.DataSource = dt;
             clearTxt();
         }
     }
 }
        public static List <CongViecDTO> SelectCongViecAll()
        {
            List <CongViecDTO> list = new List <CongViecDTO>();

            try
            {
                DataTable dt = MySqlDataAccessHelper.ExecuteQuery("SELECT * FROM congviec");
                foreach (DataRow dr in dt.Rows)
                {
                    CongViecDTO congviec = new CongViecDTO();
                    congviec.MaCV  = dr["MaCV"].ToString();
                    congviec.TenCV = dr["TenCV"].ToString();
                    congviec.MoTa  = dr["MoTa"].ToString();
                    list.Add(congviec);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(list);
        }
예제 #14
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            CongViecDTO ob = checkData();

            if (ob != null)
            {
                if (checkDuplicate() == 1)
                {
                    MessageBox.Show("Mã Công Việc Trùng", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtMaCongViec.Focus();
                    return;
                }
                else
                {
                    B_CongViec.saveCV(ob, sys.INSERT);
                    MessageBox.Show("Thêm Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dt = B_CongViec.GetAllCV();
                    dgvCongViec.DataSource = dt;
                    clearTxt();
                }
            }
        }
예제 #15
0
 public static void saveCV(CongViecDTO hs, string method)
 {
     D_CongViec.saveCV(hs, method);
 }
예제 #16
0
 public string Add(CongViecDTO obj)
 {
     return(congViecAc.Add(obj.ToCongViec()));
 }
예제 #17
0
 public static DataTable Search_tenCV(CongViecDTO cv)
 {
     return(NhanVienDAO.Search_Congviec_NV(cv));
 }
예제 #18
0
 public string Remove(CongViecDTO obj)
 {
     return(congViecAc.Remove(obj.ToCongViec()));
 }
예제 #19
0
 public string Update(CongViecDTO obj)
 {
     return(congViecAc.Update(obj.ToCongViec()));
 }