コード例 #1
0
 public static bool TryToInitLookupTable(string strLookupTable, string strQueryColumn)
 {
     if (GMCWebApp.LookupTables == null)
     {
         GMCWebApp.InitLookupTables();
     }
     if (!GMCWebApp.LookupTables.ContainsKey(strLookupTable))
     {
         if (!string.IsNullOrEmpty(strLookupTable))
         {
             DataSet allObjectForDataLookups = GetAllObjectForDataLookups(strLookupTable, strQueryColumn);
             if ((allObjectForDataLookups != null) && (allObjectForDataLookups.Tables.Count > 0))
             {
                 GMCWebApp.LookupTables.Add(strLookupTable, allObjectForDataLookups.Tables[0]);
                 GMCWebApp.LookupTablesUpdatedDate.Add(strLookupTable, DateTime.Now);
             }
         }
         return(true);
     }
     else if (GMCWebApp.LookupTables[strLookupTable].Columns.Count < strQueryColumn.Split(',').Length)
     {
         DataSet allObjectForDataLookups = GetAllObjectForDataLookups(strLookupTable, strQueryColumn);
         if ((allObjectForDataLookups != null) && (allObjectForDataLookups.Tables.Count > 0))
         {
             GMCWebApp.LookupTables[strLookupTable] = allObjectForDataLookups.Tables[0];
         }
     }
     else
     {
         return(true);
     }
     return(false);
 }
コード例 #2
0
 public ActionResult Index()
 {
     if (AuthConfig.GetSession("CurrentUser") != null)
     {
         ViewData["title"] = AuthConfig.CurrentCompanyInfo.CSCompanyDesc;
         HREmployeesInfo EmployeeInfo = GMCWebApp.GetEmployeeByUserName(Convert.ToString(AuthConfig.GetSession("CurrentUser")));
         if (EmployeeInfo == null)
         {
             EmployeeInfo = new HREmployeesInfo();
         }
         ViewData["EmployeeInfo"] = EmployeeInfo;
         ViewData["lstBranchs"]   = Helpers.HtmlControls.GetDropDownListObjects("BRBranchs", "BRBranchID", "BRBranchName", EmployeeInfo.FK_BRBranchID);
         ViewData["lstPositions"] = Helpers.HtmlControls.GetDropDownListObjects("HRPositions", "HRPositionID", "HRPositionName", EmployeeInfo.FK_HRPositionID);
         ViewData["lstSections"]  = Helpers.HtmlControls.GetDropDownListObjects("HRSections", "HRSectionID", "HRSectionName", EmployeeInfo.FK_HRSectionID);
         ViewData["lstAreas"]     = Helpers.HtmlControls.GetDropDownListObjects("HRAreas", "HRAreaID", "HRAreaName", EmployeeInfo.FK_HRAreaID);
         HomeModels home = new HomeModels();
         foreach (KeyValuePair <string, double> item in home.GetTonPhepTheoNhanVien(EmployeeInfo))
         {
             ViewData[item.Key] = item.Value;
         }
         if (AuthConfig.GetSession("TongNgayPhep") == null)
         {
             AuthConfig.SetSession("TongNgayPhep", ViewData["ConLai"]);
         }
         //DevExpress.Web.Localization.ASPxGridViewLocalizer.Active =
         return(View());
     }
     else
     {
         return(RedirectToAction("Login", "Account"));
     }
 }
コード例 #3
0
        public ActionResult RegisterOffWork(string oEmplOffWork)
        {
            string[] arr = oEmplOffWork.Split('&');
            HREmployeeOffWorksInfo       objEmplOffWork      = new HREmployeeOffWorksInfo();
            HREmployeeOffWorksController EmployeeOffWorkCtrl = new HREmployeeOffWorksController();

            arr.ToList().ForEach(x =>
            {
                string[] arrItem = x.Split('=');
                GMCDbUtil.SetPropertyValue(objEmplOffWork, arrItem.FirstOrDefault(), Convert.ChangeType(arrItem.LastOrDefault(), GMCDbUtil.GetCSharpVariableType("HREmployeeOffWorks", arrItem.FirstOrDefault())));
            });
            int iLeaveTypeID = new HREmployeeLeaveTypesController().GetObjectIDByNo("PN");

            if (objEmplOffWork.FK_HREmployeeLeaveTypeID == iLeaveTypeID && objEmplOffWork.HREmployeeOffWorkRegDays > Convert.ToDouble(AuthConfig.GetSession("TongNgayPhep")))
            {
                return(Content("Số ngày nghỉ phép vượt quá tổng số ngày nghỉ phép còn lại! Kiểm tra lại"));
            }
            HREmployeesInfo objEmpl = ExpertERP.Controller.EmployeeCtrl.GetObjectByID(objEmplOffWork.FK_HREmployeeID) as HREmployeesInfo;

            if (objEmpl == null)
            {
                objEmpl = GMCWebApp.GetEmployeeByUserName(Convert.ToString(AuthConfig.GetSession("CurrentUser")));
            }
            if (objEmpl != null)
            {
                DataSet ds = SqlDatabaseHelper.RunStoredProcedure("spl_GetAllDataEmployeeOffWorkByEmployeeIDAndDate", objEmpl.HREmployeeID, objEmplOffWork.HREmployeeOffWorkFromDate.Value, objEmplOffWork.HREmployeeOffWorkToDate.Value);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    return(Content(string.Format("Bạn đã đăng ký phép trong thời gian {0} - {1}! Vui lòng kiểm tra lại!", objEmplOffWork.HREmployeeOffWorkFromDate.Value.ToShortDateString(), objEmplOffWork.HREmployeeOffWorkToDate.Value.ToShortDateString())));
                }
                if (objEmplOffWork.FK_HREmployeeID == 0)
                {
                    objEmplOffWork.FK_HREmployeeID = objEmpl.HREmployeeID;
                }
                objEmplOffWork.AACreatedUser              = Convert.ToString(AuthConfig.GetSession("CurrentUser"));
                objEmplOffWork.ApprovalStatusCombo        = "New";
                objEmplOffWork.HREmployeeOffWorkTypeCombo = "Permision";
                EmployeeOffWorkCtrl.SaveObject(objEmplOffWork);
                return(Content("OK"));
            }
            else
            {
                return(Content("User hiện chưa cấu hình nhân viên! Không thể đăng ký!"));
            }
        }
コード例 #4
0
ファイル: AuthConfig.cs プロジェクト: hthang369/WebApp_NDCHR
 private static void SetCurrentUserLogin(System.DateTime dt)
 {
     if (CurrenUserInfo != null)
     {
         ADUsersController ADUserCtrl = new ADUsersController();
         SetSession("IsLoggingOff", false);
         CurrentCompanyInfo        = (CSCompanysInfo) new CSCompanysController().GetFirstObject();
         CurrenUserGroupInfo       = (ADUserGroupsInfo) new ADUserGroupsController().GetObjectByID(ADUserCtrl.GetUserGroupOfUser(CurrenUserInfo.ADUserName));
         GMCWebApp.CurrentLanguage = CurrenUserInfo.ADUserCurLang;
         GMCWebApp.InitDictionary();
         SetSession("CurrentUser", CurrenUserInfo.ADUserName);
         SetSession("WorkingDate", dt);
         SetSession("WorkingPeriod", dt.Month);
         SetSession("WorkingYear", dt.Year);
         //SetCookie("RecentUser", CurrenUserInfo.ADUserName);
         SetCookie("Server", Convert.ToString(GetSession("CurrentServer")));
         //SetValueConfigSettings("RecentUser", CurrenUserInfo.ADUserName);
         SetValueConfigSettings("Server", Convert.ToString(GetSession("CurrentServer")));
     }
 }
コード例 #5
0
        public ActionResult ShowSubScreenRegisterOffWork(string sType)
        {
            HomeModels home = new HomeModels();

            ViewData["type"] = sType;
            DataTable dtSource = ADConfigValueUtility.InitConfigValueTable("EmployeeOffWorkShiftType");

            ViewData["ModalTitle"]           = "Thông tin đăng ký nghỉ phép";
            ViewData["lstEmployeeLeaveType"] = home.GetEmployeeLeaveTypes();
            ViewData["objEmployeeOffWork"]   = new HREmployeeOffWorksInfo();
            ViewData["lstShiftTypeCombo"]    = Helpers.HtmlControls.GetDropDownListObjects(dtSource, "Value", "Text");
            HREmployeesInfo objCurrent = GMCWebApp.GetEmployeeByUserName(Convert.ToString(AuthConfig.GetSession("CurrentUser")));

            if (objCurrent != null)
            {
                dtSource = new HREmployeesController().GetDataTableByDataSet(new HREmployeesController().GetAllDataByForeignColumn("FK_HREmployeeManagerID", objCurrent.HREmployeeID));
                if (dtSource == null)
                {
                    dtSource = new DataTable();
                }
                DataRow dr = dtSource.NewRow();
                if (dtSource.Columns.Contains("HREmployeeID"))
                {
                    dr.SetField("HREmployeeID", objCurrent.HREmployeeID);
                }
                if (dtSource.Columns.Contains("HREmployeeFullName"))
                {
                    dr.SetField("HREmployeeFullName", objCurrent.HREmployeeFullName);
                }
                dtSource.Rows.InsertAt(dr, 0);
            }
            ViewData["EmployeeID"]  = objCurrent.HREmployeeID;
            ViewData["lstEmployee"] = Helpers.HtmlControls.GetDropDownListObjects(dtSource, "HREmployeeID", "HREmployeeFullName");
            foreach (KeyValuePair <string, double> item in home.GetTonPhepTheoNhanVien(objCurrent))
            {
                ViewData[item.Key] = item.Value;
            }
            return(PartialView("ShowSubScreenRegisterOffWork"));
        }
コード例 #6
0
        public ActionResult GridViewPartialView(int iFieldID, string sType, string sDocType, string sStatus)
        {
            // DXCOMMENT: Pass a data model for GridView in the PartialView method's second parameter
            HomeModels home = new HomeModels();
            Dictionary <STFieldsInfo, List <BusinessObject> > dic = home.GetFieldInfo(iFieldID);

            ViewData["sType"]   = sType;
            ViewData["control"] = dic;
            string sApproval       = Request.Url.Query.Split('=').LastOrDefault();
            string sApprovalStatus = (sApproval == "Register") ? "New" : ((sApproval == "Submit" ? "Approving" : "Approved"));

            sStatus = (sApproval == "Cancel") ? "Cancel" : "Alive";
            HREmployeesInfo objEmployee = GMCWebApp.GetEmployeeByUserName(Convert.ToString(AuthConfig.GetSession("CurrentUser")));
            int             iEmployeeID = 0;

            if (objEmployee != null)
            {
                iEmployeeID = objEmployee.HREmployeeID;
            }
            ViewData["data"] = home.GetEmployeeOffWorkByApprovalStatus(iEmployeeID, sApprovalStatus, sStatus);
            return(PartialView("GridViewAjaxPartialView", null));
        }
コード例 #7
0
        public static ComboBoxProperties InitColumnLookupEdit(ComboBoxProperties cboProperty, STGridColumnsInfo objGridColumnInfo)
        {
            string sTGridColumnRepository = objGridColumnInfo.STGridColumnRepository;

            if (string.IsNullOrEmpty(sTGridColumnRepository))
            {
                //GMCDbUtil.GetPrimaryTableWhichForeignColumnReferenceTo(objGridColumnInfo.STGridColumnTableName, objGridColumnInfo.STGridColumnName);
            }
            string lookupQueryColumn = GetLookupQueryColumn(objGridColumnInfo);

            TryToInitLookupTable(sTGridColumnRepository, lookupQueryColumn);
            if (!GMCWebApp.LookupTables.ContainsKey(sTGridColumnRepository))
            {
                return(null);
            }
            DataView dvLookupTable       = new DataView();
            string   strPrimaryRepostory = GMCDbUtil.GetTablePrimaryColumn(sTGridColumnRepository);

            if (GMCDbUtil.IsForeignKey(sTGridColumnRepository, objGridColumnInfo.STGridColumnRepoDsplMem))
            {
                string primaryTableWhichForeignColumnReferenceTo = GMCDbUtil.GetPrimaryTableWhichForeignColumnReferenceTo(sTGridColumnRepository, objGridColumnInfo.STGridColumnRepoDsplMem);
                if (!string.IsNullOrEmpty(primaryTableWhichForeignColumnReferenceTo))
                {
                    string str7 = GMCWebApp.GetLookupQueryColumn(primaryTableWhichForeignColumnReferenceTo);
                    if (string.IsNullOrEmpty(str7))
                    {
                        str7 = "*";
                    }
                    else
                    {
                        str7 = str7.Replace(",", ",b.");
                    }
                    string  strQuery = string.Format("SELECT a.{0},b.{5}\r\n                        FROM {1} a\r\n                        INNER JOIN {2} b ON a.{3} = b.{4}", new object[] { strPrimaryRepostory, sTGridColumnRepository, primaryTableWhichForeignColumnReferenceTo, objGridColumnInfo.STGridColumnRepoDsplMem, GMCDbUtil.GetTablePrimaryColumn(primaryTableWhichForeignColumnReferenceTo), str7 });
                    DataSet dataSet  = BusinessControllerFactory.GetBusinessController(sTGridColumnRepository + "Controller").GetDataSet(strQuery);
                    if ((dataSet != null) && (dataSet.Tables.Count > 0))
                    {
                        string strLookupTableName = sTGridColumnRepository + "_" + primaryTableWhichForeignColumnReferenceTo;
                        dvLookupTable = dataSet.Tables[0].DefaultView;
                        if (!GMCWebApp.LookupTables.ContainsKey(strLookupTableName))
                        {
                            GMCWebApp.LookupTables.Add(strLookupTableName, dataSet.Tables[0]);
                        }
                        else
                        {
                            GMCWebApp.LookupTables[strLookupTableName] = dataSet.Tables[0];
                        }
                    }
                }
            }
            else
            {
                dvLookupTable = GMCWebApp.LookupTables[sTGridColumnRepository].DefaultView;
            }
            string sTGridColumnRepoDsplMem = objGridColumnInfo.STGridColumnRepoDsplMem;

            if (!dvLookupTable.Table.Columns.Contains(sTGridColumnRepoDsplMem))
            {
                sTGridColumnRepoDsplMem = "";
            }
            if (string.IsNullOrEmpty(sTGridColumnRepoDsplMem))
            {
                sTGridColumnRepoDsplMem = strPrimaryRepostory.Substring(0, strPrimaryRepostory.Length - 2) + "No";
            }
            if (GMCDbUtil.IsForeignKey(sTGridColumnRepository, objGridColumnInfo.STGridColumnRepoDsplMem))
            {
                string str13 = GMCDbUtil.GetPrimaryTableWhichForeignColumnReferenceTo(sTGridColumnRepository, objGridColumnInfo.STGridColumnRepoDsplMem);
                if (string.IsNullOrEmpty(objGridColumnInfo.STGridColumnRepoCol1))
                {
                    sTGridColumnRepoDsplMem = str13.Substring(0, str13.Length - 1) + "No";
                }
                else
                {
                    sTGridColumnRepoDsplMem = objGridColumnInfo.STGridColumnRepoCol1;
                }
            }
            if (cboProperty == null)
            {
                cboProperty = new ComboBoxProperties();
            }
            DataTable dtLookupTable = dvLookupTable.ToTable(false, strPrimaryRepostory, sTGridColumnRepoDsplMem);

            cboProperty.DataSource    = dtLookupTable.DefaultView;
            cboProperty.TextField     = sTGridColumnRepoDsplMem;
            cboProperty.ValueField    = strPrimaryRepostory;
            cboProperty.ValueType     = GMCDbUtil.GetCSharpVariableType(objGridColumnInfo.STGridColumnTableName, objGridColumnInfo.STGridColumnName);
            cboProperty.DropDownStyle = DropDownStyle.DropDownList;
            if (string.IsNullOrEmpty(objGridColumnInfo.STGridColumnRepoCol1))
            {
                ListBoxColumn column = new ListBoxColumn(sTGridColumnRepoDsplMem);
                if (sTGridColumnRepoDsplMem.EndsWith("No"))
                {
                    column.Caption = "Mã số";
                    column.Width   = 50;
                }
                else if (sTGridColumnRepoDsplMem.EndsWith("Name"))
                {
                    column.Caption = "Tên";
                    column.Width   = 200;
                }
                cboProperty.Columns.AddColumn(dtLookupTable, column);
                if (!GMCDbUtil.IsForeignKey(sTGridColumnRepository, objGridColumnInfo.STGridColumnRepoDsplMem))
                {
                    ListBoxColumn column1 = new ListBoxColumn();
                    if (sTGridColumnRepoDsplMem.EndsWith("No"))
                    {
                        column1.FieldName = sTGridColumnRepoDsplMem.Substring(0, sTGridColumnRepoDsplMem.Length - 2) + "Name";
                        column1.Caption   = GMCWebApp.GetControlText("Tên");
                        column1.Width     = 200;
                    }
                    else if (sTGridColumnRepoDsplMem.EndsWith("Name"))
                    {
                        column1.FieldName = sTGridColumnRepoDsplMem.Substring(0, sTGridColumnRepoDsplMem.Length - 4) + "No";
                        column1.Caption   = GMCWebApp.GetControlText("Mã số");
                        column1.Width     = 50;
                    }
                    cboProperty.Columns.AddColumn(dtLookupTable, column1);
                }
            }
            else
            {
                ListBoxColumn info6 = new ListBoxColumn
                {
                    FieldName = objGridColumnInfo.STGridColumnRepoCol1,
                    Caption   = GMCWebApp.GetControlText(objGridColumnInfo.STGridColumnRepoCol1Caption),
                    Width     = 100
                };
                cboProperty.Columns.AddColumn(dtLookupTable, info6);
                if (!string.IsNullOrEmpty(objGridColumnInfo.STGridColumnRepoCol2))
                {
                    ListBoxColumn info7 = new ListBoxColumn
                    {
                        FieldName = objGridColumnInfo.STGridColumnRepoCol2,
                        Caption   = GMCWebApp.GetControlText(objGridColumnInfo.STGridColumnRepoCol2Caption),
                        Width     = 100,
                    };
                    cboProperty.Columns.AddColumn(dtLookupTable, info7);
                }
                if (!string.IsNullOrEmpty(objGridColumnInfo.STGridColumnRepoCol3))
                {
                    ListBoxColumn info8 = new ListBoxColumn
                    {
                        FieldName = objGridColumnInfo.STGridColumnRepoCol3,
                        Caption   = GMCWebApp.GetControlText(objGridColumnInfo.STGridColumnRepoCol3Caption),
                        Width     = 100
                    };
                    cboProperty.Columns.AddColumn(dtLookupTable, info8);
                }
                if (!string.IsNullOrEmpty(objGridColumnInfo.STGridColumnRepoCol4))
                {
                    ListBoxColumn info9 = new ListBoxColumn
                    {
                        FieldName = objGridColumnInfo.STGridColumnRepoCol4,
                        Caption   = GMCWebApp.GetControlText(objGridColumnInfo.STGridColumnRepoCol4Caption),
                        Width     = 100
                    };
                    cboProperty.Columns.AddColumn(dtLookupTable, info9);
                }
                if (!string.IsNullOrEmpty(objGridColumnInfo.STGridColumnRepoCol5))
                {
                    ListBoxColumn info10 = new ListBoxColumn
                    {
                        FieldName = objGridColumnInfo.STGridColumnRepoCol5,
                        Caption   = GMCWebApp.GetControlText(objGridColumnInfo.STGridColumnRepoCol5Caption),
                        Width     = 100
                    };
                    cboProperty.Columns.AddColumn(dtLookupTable, info10);
                }
            }
            if (!string.IsNullOrEmpty(objGridColumnInfo.STGridColumnRepoDsplMem))
            {
                int idx = cboProperty.Columns.Cast <ListBoxColumn>().ToList().FindIndex(x => x.FieldName.Equals(objGridColumnInfo.STGridColumnRepoDsplMem));
                if (idx != -1)
                {
                    cboProperty.TextFormatString = "{" + idx.ToString() + "}";
                }
            }
            return(cboProperty);
        }
コード例 #8
0
ファイル: AuthConfig.cs プロジェクト: hthang369/WebApp_NDCHR
        public static string LogIn(string strSrv, string strUser, string strPassword, System.DateTime dt)
        {
            ConnectionAuth(strSrv);
            if (!SqlDatabaseHelper.TestConnection())
            {
                return("Không kết nối được CSDL! Vui lòng liên hệ người quản trị!");
            }
            ADUsersController ADUserCtrl = new ADUsersController();

            CurrenUserInfo = (ADUsersInfo)ADUserCtrl.GetObjectByName(strUser);
            ADUserConfigsInfo UserCfgInfo = new ADUserConfigsController().GetFirstObject() as ADUserConfigsInfo;

            GMCWebApp.GetLocalMachineInfo();
            if (CurrenUserInfo != null && CurrenUserInfo.ADUserIsLockedCheck)
            {
                return("Tài khoản đăng nhập này đã bị khóa! Vui lòng liên hệ người quản trị!");
            }
            else if (IsUserLoggedIn(strUser))
            {
                GEUserAuditsInfo UserAudisInfo = new GEUserAuditsController().GetGEUserAuditsByADUserName(strUser);
                return(string.Format("Người dùng này đã đăng nhập trên máy {0} với địa chỉ IP {1}!", UserAudisInfo.GEUserAuditPCName, UserAudisInfo.GEUserAuditIP));
            }
            else if (IsAuthenticated(strUser, strPassword))
            {
                if (!new ADUserGroupsController().IsExist(CurrenUserInfo.ADUserGroupID))
                {
                    return(string.Format("Nhóm người dùng của tài khoản {0} không tồn tại trên hệ thống!", strUser));
                }
                else
                {
                    SetCurrentUserLogin(dt);
                    SaveUserAuditLogin("Login");
                    if (UserCfgInfo != null && UserCfgInfo.ADUserConfigPassDayExpires > 0)
                    {
                        if (new ADUserPassHistorysController().IsOldPassExpired(CurrenUserInfo.ADUserID, UserCfgInfo.ADUserConfigPassDayExpires))
                        {
                            return("Mật khẩu đã hết hạn! Vui lòng đổi mật khẩu mới!");
                        }
                    }
                }
            }
            else
            {
                int iCountLoginFail = new GEUserAuditsController().GetCountLoginFail(strUser, "WebHome", dt);
                iCountLoginFail++;
                if (UserCfgInfo != null && (iCountLoginFail >= UserCfgInfo.ADUserConfigMaxLogonCount) && UserCfgInfo.ADUserConfigMaxLogonCount > 0)
                {
                    SaveUserAuditLogin("LoginFailLock", 0, strUser);
                    if (CurrenUserInfo != null)
                    {
                        CurrenUserInfo.ADUserIsLockedCheck = true;
                        CurrenUserInfo.ADUserLockedInfo    = Environment.MachineName + ", " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
                        ADUserCtrl.UpdateObject(CurrenUserInfo, true, "ADUserIsLockedCheck", "ADUserLockedInfo");
                    }
                    return(string.Format("Vượt quá số lần đăng nhập sai cho phép! Tài khoản đăng nhập {0} đã bị khóa", strUser));
                }
                SaveUserAuditLogin("LoginFail", 0, strUser);
                string strError = "Tên đăng nhập/ Mật khẩu không hợp lệ!";
                if (UserCfgInfo != null && UserCfgInfo.ADUserConfigMaxLogonCount > 0)
                {
                    strError += string.Format(" Còn lại {0} lần thử", UserCfgInfo.ADUserConfigMaxLogonCount - iCountLoginFail);
                }
                return(strError);
            }
            ADConfigValueUtility.InitGlobalConfigValueTables();
            return("");
        }