public static int Insert(TongHopDanhGiaCaNhanThangInfo _tongHopDanhGiaCaNhanThangInfo)
        {
            SqlConnection dbConn = new SqlConnection(AppEnv.ConnectionString);
            SqlCommand    dbCmd  = new SqlCommand("TongHopDanhGiaCaNhanThang_Insert", dbConn);

            dbCmd.CommandType = CommandType.StoredProcedure;
            dbCmd.Parameters.Add("@BoPhan", _tongHopDanhGiaCaNhanThangInfo.BoPhan);
            dbCmd.Parameters.Add("@HoTen", _tongHopDanhGiaCaNhanThangInfo.HoTen);
            dbCmd.Parameters.Add("@KPI", _tongHopDanhGiaCaNhanThangInfo.KPI);
            dbCmd.Parameters.Add("@DiemDanhGiaDonVi", _tongHopDanhGiaCaNhanThangInfo.DiemDanhGiaDonVi);
            dbCmd.Parameters.Add("@LoiNhuanCongTy", _tongHopDanhGiaCaNhanThangInfo.LoiNhuanCongTy);
            dbCmd.Parameters.Add("@LoiNhuanBoPhan", _tongHopDanhGiaCaNhanThangInfo.LoiNhuanBoPhan);
            dbCmd.Parameters.Add("@QuanLyCongViecVaPhoiHop", _tongHopDanhGiaCaNhanThangInfo.QuanLyCongViecVaPhoiHop);
            dbCmd.Parameters.Add("@KyLuatCaNhan", _tongHopDanhGiaCaNhanThangInfo.KyLuatCaNhan);
            dbCmd.Parameters.Add("@DiemThuong", _tongHopDanhGiaCaNhanThangInfo.DiemThuong);
            dbCmd.Parameters.Add("@MucDoHoanThanh", _tongHopDanhGiaCaNhanThangInfo.MucDoHoanThanh);
            dbCmd.Parameters.Add("@XepLoai", _tongHopDanhGiaCaNhanThangInfo.XepLoai);
            dbCmd.Parameters.Add("@HeSoLuongMem", _tongHopDanhGiaCaNhanThangInfo.HeSoLuongMem);
            dbCmd.Parameters.Add("@Thang", _tongHopDanhGiaCaNhanThangInfo.Thang);
            dbCmd.Parameters.Add("@Nam", _tongHopDanhGiaCaNhanThangInfo.Nam);
            dbCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;
            try
            {
                dbConn.Open();
                dbCmd.ExecuteNonQuery();
                return((int)dbCmd.Parameters["@RETURN_VALUE"].Value);
            }
            finally
            {
                dbConn.Close();
            }
        }
        public static void Update(TongHopDanhGiaCaNhanThangInfo _tongHopDanhGiaCaNhanThangInfo)
        {
            SqlConnection dbConn = new SqlConnection(AppEnv.ConnectionString);
            SqlCommand    dbCmd  = new SqlCommand("TongHopDanhGiaCaNhanThang_Update", dbConn);

            dbCmd.CommandType = CommandType.StoredProcedure;
            dbCmd.Parameters.Add("@ID", _tongHopDanhGiaCaNhanThangInfo.ID);
            dbCmd.Parameters.Add("@BoPhan", _tongHopDanhGiaCaNhanThangInfo.BoPhan);
            dbCmd.Parameters.Add("@HoTen", _tongHopDanhGiaCaNhanThangInfo.HoTen);
            dbCmd.Parameters.Add("@KPI", _tongHopDanhGiaCaNhanThangInfo.KPI);
            dbCmd.Parameters.Add("@DiemDanhGiaDonVi", _tongHopDanhGiaCaNhanThangInfo.DiemDanhGiaDonVi);
            dbCmd.Parameters.Add("@LoiNhuanCongTy", _tongHopDanhGiaCaNhanThangInfo.LoiNhuanCongTy);
            dbCmd.Parameters.Add("@LoiNhuanBoPhan", _tongHopDanhGiaCaNhanThangInfo.LoiNhuanBoPhan);
            dbCmd.Parameters.Add("@QuanLyCongViecVaPhoiHop", _tongHopDanhGiaCaNhanThangInfo.QuanLyCongViecVaPhoiHop);
            dbCmd.Parameters.Add("@KyLuatCaNhan", _tongHopDanhGiaCaNhanThangInfo.KyLuatCaNhan);
            dbCmd.Parameters.Add("@DiemThuong", _tongHopDanhGiaCaNhanThangInfo.DiemThuong);
            dbCmd.Parameters.Add("@MucDoHoanThanh", _tongHopDanhGiaCaNhanThangInfo.MucDoHoanThanh);
            dbCmd.Parameters.Add("@XepLoai", _tongHopDanhGiaCaNhanThangInfo.XepLoai);
            dbCmd.Parameters.Add("@HeSoLuongMem", _tongHopDanhGiaCaNhanThangInfo.HeSoLuongMem);
            dbCmd.Parameters.Add("@Thang", _tongHopDanhGiaCaNhanThangInfo.Thang);
            dbCmd.Parameters.Add("@Year", _tongHopDanhGiaCaNhanThangInfo.Nam);
            try
            {
                dbConn.Open();
                dbCmd.ExecuteNonQuery();
            }
            finally
            {
                dbConn.Close();
            }
        }
        public static TongHopDanhGiaCaNhanThangInfo GetInfo(int _iD)
        {
            TongHopDanhGiaCaNhanThangInfo retVal = null;
            SqlConnection dbConn = new SqlConnection(AppEnv.ConnectionString);
            SqlCommand    dbCmd  = new SqlCommand("TongHopDanhGiaCaNhanThang_GetInfo", dbConn);

            dbCmd.CommandType = CommandType.StoredProcedure;
            dbCmd.Parameters.Add("@ID", _iD);
            try
            {
                dbConn.Open();
                SqlDataReader dr = dbCmd.ExecuteReader();
                if (dr.Read())
                {
                    retVal                         = new TongHopDanhGiaCaNhanThangInfo();
                    retVal.ID                      = Convert.ToInt32(dr["ID"]);
                    retVal.BoPhan                  = Convert.ToString(dr["BoPhan"]);
                    retVal.HoTen                   = Convert.ToString(dr["HoTen"]);
                    retVal.KPI                     = Convert.ToDouble(dr["KPI"]);
                    retVal.DiemDanhGiaDonVi        = Convert.ToDouble(dr["DiemDanhGiaDonVi"]);
                    retVal.LoiNhuanCongTy          = Convert.ToDouble(dr["LoiNhuanCongTy"]);
                    retVal.LoiNhuanBoPhan          = Convert.ToDouble(dr["LoiNhuanBoPhan"]);
                    retVal.QuanLyCongViecVaPhoiHop = Convert.ToDouble(dr["QuanLyCongViecVaPhoiHop"]);
                    retVal.KyLuatCaNhan            = Convert.ToDouble(dr["KyLuatCaNhan"]);
                    retVal.DiemThuong              = Convert.ToDouble(dr["DiemThuong"]);
                    retVal.MucDoHoanThanh          = Convert.ToDouble(dr["MucDoHoanThanh"]);
                    retVal.XepLoai                 = Convert.ToString(dr["XepLoai"]);
                    retVal.HeSoLuongMem            = Convert.ToDouble(dr["HeSoLuongMem"]);
                    retVal.Thang                   = Convert.ToInt32(dr["Thang"]);
                    retVal.Nam                     = Convert.ToInt32(dr["Nam"]);
                }
                if (dr != null)
                {
                    dr.Close();
                }
            }
            finally
            {
                dbConn.Close();
            }
            return(retVal);
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (fileImport.HasFile)
            {
                if (!Directory.Exists(Server.MapPath("/UpLoad/Temp/" + CurrentUser.UserID + "/")))
                {
                    Directory.CreateDirectory(Server.MapPath("/UpLoad/Temp/" + CurrentUser.UserID + "/"));
                }
                string date = DateTime.Now.ToString("yyyyMMddHHmmss");

                string path = Server.MapPath("/UpLoad/Temp/" + CurrentUser.UserID + "/") + fileImport.FileName.Replace(".csv", "") + "_Temp_" + date + ".csv";

                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                fileImport.PostedFile.SaveAs(Server.MapPath("/UpLoad/Temp/" + CurrentUser.UserID + "/") + fileImport.FileName.Replace(".csv", "") + "_Temp_" + date + ".csv");

                if (File.Exists(path))
                {
                    DataTable returnTable = ImportExcelToDataTable.ConvertCSVtoDataTable(path);

                    if (returnTable != null && returnTable.Rows.Count > 0)
                    {
                        for (int i = 0; i < returnTable.Rows.Count; i++)
                        {
                            try
                            {
                                DataRow row = returnTable.Rows[i];

                                #region Import

                                TongHopDanhGiaCaNhanThangInfo info = new TongHopDanhGiaCaNhanThangInfo();

                                info.BoPhan = row[0].ToString();
                                info.HoTen = row[1].ToString();
                                info.KPI = ConvertUtility.ToDouble(row[2].ToString().Replace(".", ",")) * 100;
                                info.DiemDanhGiaDonVi = ConvertUtility.ToDouble(row[3].ToString().Replace(".", ",")) * 100;
                                info.LoiNhuanCongTy = ConvertUtility.ToDouble(row[4].ToString().Replace(".", ",")) * 100;
                                info.LoiNhuanBoPhan = ConvertUtility.ToDouble(row[5].ToString().Replace(".", ",")) * 100;
                                info.QuanLyCongViecVaPhoiHop = ConvertUtility.ToDouble(row[6].ToString().Replace(".", ",")) * 100;
                                info.KyLuatCaNhan = ConvertUtility.ToDouble(row[7].ToString().Replace(".", ",")) * 100;
                                info.DiemThuong = ConvertUtility.ToDouble(row[8].ToString().Replace(".", ","));
                                info.MucDoHoanThanh = ConvertUtility.ToDouble(row[9].ToString().Replace(".", ",")) * 100;
                                info.XepLoai = row[10].ToString();
                                info.HeSoLuongMem = ConvertUtility.ToDouble(row[11].ToString().Replace(".", ",")) * 100;
                                info.Nam = ConvertUtility.ToInt32(dropNam.SelectedValue);
                                info.Thang = ConvertUtility.ToInt32(dropThang.SelectedValue);

                                TongHopDanhGiaCaNhanThangController.Insert(info);

                                #endregion
                            }
                            catch
                            {
                                continue;
                            }
                        }

                        lblUpdateStatus.Text = "Bạn đã import thành công file \"" + fileImport.FileName + "\"";
                    }
                    else
                    {
                        lblUpdateStatus.Text = "File import sai định dạng";
                    }
                }
                else
                {
                    lblUpdateStatus.Text = "File import sai định dạng";
                }
            }
            else
            {
                lblUpdateStatus.Text = "File import sai định dạng";
            }
        }
 public static TongHopDanhGiaCaNhanThangInfo GetInfo(int _iD)
 {
     TongHopDanhGiaCaNhanThangInfo retVal = null;
     SqlConnection dbConn = new SqlConnection(AppEnv.ConnectionString);
     SqlCommand dbCmd = new SqlCommand("TongHopDanhGiaCaNhanThang_GetInfo", dbConn);
     dbCmd.CommandType = CommandType.StoredProcedure;
     dbCmd.Parameters.Add("@ID", _iD);
     try
     {
         dbConn.Open();
         SqlDataReader dr = dbCmd.ExecuteReader();
         if (dr.Read())
         {
             retVal = new TongHopDanhGiaCaNhanThangInfo();
             retVal.ID = Convert.ToInt32(dr["ID"]);
             retVal.BoPhan = Convert.ToString(dr["BoPhan"]);
             retVal.HoTen = Convert.ToString(dr["HoTen"]);
             retVal.KPI = Convert.ToDouble(dr["KPI"]);
             retVal.DiemDanhGiaDonVi = Convert.ToDouble(dr["DiemDanhGiaDonVi"]);
             retVal.LoiNhuanCongTy = Convert.ToDouble(dr["LoiNhuanCongTy"]);
             retVal.LoiNhuanBoPhan = Convert.ToDouble(dr["LoiNhuanBoPhan"]);
             retVal.QuanLyCongViecVaPhoiHop = Convert.ToDouble(dr["QuanLyCongViecVaPhoiHop"]);
             retVal.KyLuatCaNhan = Convert.ToDouble(dr["KyLuatCaNhan"]);
             retVal.DiemThuong = Convert.ToDouble(dr["DiemThuong"]);
             retVal.MucDoHoanThanh = Convert.ToDouble(dr["MucDoHoanThanh"]);
             retVal.XepLoai = Convert.ToString(dr["XepLoai"]);
             retVal.HeSoLuongMem = Convert.ToDouble(dr["HeSoLuongMem"]);
             retVal.Thang = Convert.ToInt32(dr["Thang"]);
             retVal.Nam = Convert.ToInt32(dr["Nam"]);
         }
         if (dr != null) dr.Close();
     }
     finally
     {
         dbConn.Close();
     }
     return retVal;
 }
 public static void Update(TongHopDanhGiaCaNhanThangInfo _tongHopDanhGiaCaNhanThangInfo)
 {
     SqlConnection dbConn = new SqlConnection(AppEnv.ConnectionString);
     SqlCommand dbCmd = new SqlCommand("TongHopDanhGiaCaNhanThang_Update", dbConn);
     dbCmd.CommandType = CommandType.StoredProcedure;
     dbCmd.Parameters.Add("@ID", _tongHopDanhGiaCaNhanThangInfo.ID);
     dbCmd.Parameters.Add("@BoPhan", _tongHopDanhGiaCaNhanThangInfo.BoPhan);
     dbCmd.Parameters.Add("@HoTen", _tongHopDanhGiaCaNhanThangInfo.HoTen);
     dbCmd.Parameters.Add("@KPI", _tongHopDanhGiaCaNhanThangInfo.KPI);
     dbCmd.Parameters.Add("@DiemDanhGiaDonVi", _tongHopDanhGiaCaNhanThangInfo.DiemDanhGiaDonVi);
     dbCmd.Parameters.Add("@LoiNhuanCongTy", _tongHopDanhGiaCaNhanThangInfo.LoiNhuanCongTy);
     dbCmd.Parameters.Add("@LoiNhuanBoPhan", _tongHopDanhGiaCaNhanThangInfo.LoiNhuanBoPhan);
     dbCmd.Parameters.Add("@QuanLyCongViecVaPhoiHop", _tongHopDanhGiaCaNhanThangInfo.QuanLyCongViecVaPhoiHop);
     dbCmd.Parameters.Add("@KyLuatCaNhan", _tongHopDanhGiaCaNhanThangInfo.KyLuatCaNhan);
     dbCmd.Parameters.Add("@DiemThuong", _tongHopDanhGiaCaNhanThangInfo.DiemThuong);
     dbCmd.Parameters.Add("@MucDoHoanThanh", _tongHopDanhGiaCaNhanThangInfo.MucDoHoanThanh);
     dbCmd.Parameters.Add("@XepLoai", _tongHopDanhGiaCaNhanThangInfo.XepLoai);
     dbCmd.Parameters.Add("@HeSoLuongMem", _tongHopDanhGiaCaNhanThangInfo.HeSoLuongMem);
     dbCmd.Parameters.Add("@Thang", _tongHopDanhGiaCaNhanThangInfo.Thang);
     dbCmd.Parameters.Add("@Year", _tongHopDanhGiaCaNhanThangInfo.Nam);
     try
     {
         dbConn.Open();
         dbCmd.ExecuteNonQuery();
     }
     finally
     {
         dbConn.Close();
     }
 }
 public static int Insert(TongHopDanhGiaCaNhanThangInfo _tongHopDanhGiaCaNhanThangInfo)
 {
     SqlConnection dbConn = new SqlConnection(AppEnv.ConnectionString);
     SqlCommand dbCmd = new SqlCommand("TongHopDanhGiaCaNhanThang_Insert", dbConn);
     dbCmd.CommandType = CommandType.StoredProcedure;
     dbCmd.Parameters.Add("@BoPhan", _tongHopDanhGiaCaNhanThangInfo.BoPhan);
     dbCmd.Parameters.Add("@HoTen", _tongHopDanhGiaCaNhanThangInfo.HoTen);
     dbCmd.Parameters.Add("@KPI", _tongHopDanhGiaCaNhanThangInfo.KPI);
     dbCmd.Parameters.Add("@DiemDanhGiaDonVi", _tongHopDanhGiaCaNhanThangInfo.DiemDanhGiaDonVi);
     dbCmd.Parameters.Add("@LoiNhuanCongTy", _tongHopDanhGiaCaNhanThangInfo.LoiNhuanCongTy);
     dbCmd.Parameters.Add("@LoiNhuanBoPhan", _tongHopDanhGiaCaNhanThangInfo.LoiNhuanBoPhan);
     dbCmd.Parameters.Add("@QuanLyCongViecVaPhoiHop", _tongHopDanhGiaCaNhanThangInfo.QuanLyCongViecVaPhoiHop);
     dbCmd.Parameters.Add("@KyLuatCaNhan", _tongHopDanhGiaCaNhanThangInfo.KyLuatCaNhan);
     dbCmd.Parameters.Add("@DiemThuong", _tongHopDanhGiaCaNhanThangInfo.DiemThuong);
     dbCmd.Parameters.Add("@MucDoHoanThanh", _tongHopDanhGiaCaNhanThangInfo.MucDoHoanThanh);
     dbCmd.Parameters.Add("@XepLoai", _tongHopDanhGiaCaNhanThangInfo.XepLoai);
     dbCmd.Parameters.Add("@HeSoLuongMem", _tongHopDanhGiaCaNhanThangInfo.HeSoLuongMem);
     dbCmd.Parameters.Add("@Thang", _tongHopDanhGiaCaNhanThangInfo.Thang);
     dbCmd.Parameters.Add("@Nam", _tongHopDanhGiaCaNhanThangInfo.Nam);
     dbCmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;
     try
     {
         dbConn.Open();
         dbCmd.ExecuteNonQuery();
         return (int)dbCmd.Parameters["@RETURN_VALUE"].Value;
     }
     finally
     {
         dbConn.Close();
     }
 }