private void Save_Data(int _year, int _month, int _phongban)
        {
            _ChamCongData.RemoveByYearMonth(_year, _month, _phongban);//Xóa bảng lương có phòng ban đã chọn

            if (fileUpload.HasFile == true)
            {
                string path = Server.MapPath("/File/ExcelFile/" + fileUpload.FileName);
                fileUpload.SaveAs(path);
                DataTable dt     = getDataexcel(path);
                int       _count = dt.Rows.Count;
                for (int i = 0; i < _count; i++)
                {
                    string _maNV = Utils.CStrDef(dt.Rows[i][0]);
                    if (_maNV.Contains("Mã nhân viên"))
                    {
                        string _getMaCC = _maNV.Substring(14, 5);
                        var    obj      = _UserRepo.GetInfoUserByMaCC(_getMaCC, _phongban);
                        if (obj.Count > 0)
                        {
                            i += 7;
                            while (Utils.CStrDef(dt.Rows[i][0]) != "")
                            {
                                CHAM_CONG c = new CHAM_CONG();
                                c.CC_MACC     = _getMaCC;
                                c.CC_USERID   = obj[0].USER_ID;
                                c.CC_PHONGBAN = obj[0].GROUP_ID;
                                c.CC_NAM      = _year;
                                c.CC_THANG    = _month;
                                c.CC_NGAY     = DateTime.ParseExact(Utils.CStrDef(dt.Rows[i][0]), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);

                                double dGioVao = getHourIn(Utils.CDblDef(dt.Rows[i][2]), Utils.CDblDef(dt.Rows[i][3]));
                                double dGioRa  = getHourOut(Utils.CDblDef(dt.Rows[i][2]), Utils.CDblDef(dt.Rows[i][3]));

                                c.CC_THU        = Utils.CStrDef(dt.Rows[i][1]);
                                c.CC_VAO        = dGioVao;
                                c.CC_RA         = dGioRa;
                                c.CC_SONGAYTRE  = getDayLate(dGioVao);
                                c.CC_SONGAYNGHI = getDayoff(dt.Rows[i][1], dGioVao, dGioRa);
                                c.CC_SOPHUTTRE  = getTimeLate(dGioVao, 8);
                                _ChamCongData.Create(c);
                                i++;
                            }
                        }
                    }
                }

                string strScript = "<script>";
                strScript += "alert('Đã Import dữ liệu thành công');";
                strScript += "parent.emailwindow.close(); parent.GetCurrentTime();";
                strScript += "</script>";
                Page.RegisterClientScriptBlock("strScript", strScript);
            }
            else
            {
                string strScript = "<script>";
                strScript += "alert('Xin chọn file để Import');";
                strScript += "</script>";
                Page.RegisterClientScriptBlock("strScript", strScript);
            }
        }
        private void Save_Data(int _year, int _month, int _phongban)
        {
            _ChamCongData.RemoveByYearMonth(_year, _month, _phongban);//Xóa bảng lương có phòng ban đã chọn

            if (fileUpload.HasFile == true)
            {
                string path = Server.MapPath("/File/ExcelFile/" + fileUpload.FileName);
                fileUpload.SaveAs(path);
                DataTable dt = getDataexcel(path);
                int _count = dt.Rows.Count;
                for (int i = 0; i < _count; i++)
                {
                    string _maNV = Utils.CStrDef(dt.Rows[i][0]);
                    if (_maNV.Contains("Mã nhân viên"))
                    {
                        string _getMaCC = _maNV.Substring(14, 5);
                        var obj = _UserRepo.GetInfoUserByMaCC(_getMaCC, _phongban);
                        if (obj.Count > 0)
                        {
                            i += 7;
                            while (Utils.CStrDef(dt.Rows[i][0]) != "")
                            {
                                CHAM_CONG c = new CHAM_CONG();
                                c.CC_MACC = _getMaCC;
                                c.CC_USERID = obj[0].USER_ID;
                                c.CC_PHONGBAN = obj[0].GROUP_ID;
                                c.CC_NAM = _year;
                                c.CC_THANG = _month;
                                c.CC_NGAY = DateTime.ParseExact(Utils.CStrDef(dt.Rows[i][0]), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);

                                double dGioVao = getHourIn(Utils.CDblDef(dt.Rows[i][2]), Utils.CDblDef(dt.Rows[i][3]));
                                double dGioRa = getHourOut(Utils.CDblDef(dt.Rows[i][2]), Utils.CDblDef(dt.Rows[i][3]));

                                c.CC_THU = Utils.CStrDef(dt.Rows[i][1]);
                                c.CC_VAO = dGioVao;
                                c.CC_RA = dGioRa;
                                c.CC_SONGAYTRE = getDayLate(dGioVao);
                                c.CC_SONGAYNGHI = getDayoff(dt.Rows[i][1], dGioVao, dGioRa);
                                c.CC_SOPHUTTRE = getTimeLate(dGioVao, 8);
                                _ChamCongData.Create(c);
                                i++;
                            }
                        }
                    }
                }

                string strScript = "<script>";
                strScript += "alert('Đã Import dữ liệu thành công');";
                strScript += "parent.emailwindow.close(); parent.GetCurrentTime();";
                strScript += "</script>";
                Page.RegisterClientScriptBlock("strScript", strScript);
            }
            else
            {
                string strScript = "<script>";
                strScript += "alert('Xin chọn file để Import');";
                strScript += "</script>";
                Page.RegisterClientScriptBlock("strScript", strScript);
            }
        }
 public virtual void Remove(CHAM_CONG b)
 {
     try
     {
         db.CHAM_CONGs.DeleteOnSubmit(b);
         db.SubmitChanges();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
 public virtual void Create(CHAM_CONG cus)
 {
     try
     {
         this.db.CHAM_CONGs.InsertOnSubmit(cus);
         db.SubmitChanges();
     }
     catch //(Exception e)
     {
         //throw new Exception(e.Message);
     }
 }
 public virtual void Remove(int id)
 {
     try
     {
         CHAM_CONG b = this.GetById(id);
         this.Remove(b);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
 public virtual void Remove(CHAM_CONG b)
 {
     try
     {
         db.CHAM_CONGs.DeleteOnSubmit(b);
         db.SubmitChanges();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
 public virtual void Create(CHAM_CONG cus)
 {
     try
     {
         this.db.CHAM_CONGs.InsertOnSubmit(cus);
         db.SubmitChanges();
     }
     catch //(Exception e)
     {
         //throw new Exception(e.Message);
     }
 }
 public virtual void Update(CHAM_CONG cus)
 {
     try
     {
         CHAM_CONG cusOld = this.GetById(cus.ID);
         cusOld = cus;
         db.SubmitChanges();
     }
     catch //(Exception e)
     {
         //throw new Exception(e.Message);
     }
 }
 public virtual void Update(CHAM_CONG cus)
 {
     try
     {
         CHAM_CONG cusOld = this.GetById(cus.ID);
         cusOld = cus;
         db.SubmitChanges();
     }
     catch //(Exception e)
     {
         //throw new Exception(e.Message);
     }
 }