public int GetEmployeeManagerLevel(int iEmplID, string sColumnName = "FK_HREmployeeManagerID") { DataSet ds = GMCDbUtil.ExecuteQuery(string.Format("SELECT {0} FROM HREmployees WHERE HREmployeeID = {1}", sColumnName, iEmplID)); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0][0] != DBNull.Value) { return(Convert.ToInt32(ds.Tables[0].Rows[0][0])); } return(0); }
private DataSet GetScreenByModuleNameAndUserGroupName(string sModuleName, string sUserGroupName) { if (GMCDbUtil.StoredProcedureIsExist("STScreenWebApps_SelectBySTModuleNameAndADUserGroupName")) { return(SqlDatabaseHelper.RunStoredProcedure("STScreenWebApps_SelectBySTModuleNameAndADUserGroupName", sModuleName, sUserGroupName)); } else { return(new STScreensController().GetScreenByModuleNameAndUserGroupName(sModuleName, sUserGroupName)); } }
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ý!")); } }
private List <DataRow> GetLocalDataSet(string strSelect, string strTable, string strWhere) { List <DataRow> lstDr = new List <DataRow>(); if (dsTmp.Tables.Cast <DataTable>().Where(x => x.TableName.Equals(strTable)).Count() > 0) { lstDr = dsTmp.Tables[strTable].Select(strWhere).ToList(); } if (lstDr.Count == 0) { DataSet ds = GMCDbUtil.ExecuteQuery(string.Format("SELECT {0} FROM {1} WHERE {2}", strSelect, strTable, strWhere)); if (ds != null && ds.Tables.Count > 0) { lstDr = ds.Tables[0].Rows.Cast <DataRow>().ToList(); } } lstDr.ForEach(x => AddRowToDataSet(x, strTable)); return(lstDr); }
private static string GetLookupQueryColumn(STGridColumnsInfo objSTGridColumnsInfo) { string str = string.Empty; string tablePrimaryColumn = GMCDbUtil.GetTablePrimaryColumn(objSTGridColumnsInfo.STGridColumnRepository); str = str + string.Format("{0},", tablePrimaryColumn); string name = tablePrimaryColumn.Substring(0, tablePrimaryColumn.Length - 2) + "No"; string str4 = tablePrimaryColumn.Substring(0, tablePrimaryColumn.Length - 2) + "Name"; try { System.Type businessObjectType = BusinessObjectFactory.GetBusinessObject(objSTGridColumnsInfo.STGridColumnRepository + "Info").GetType(); if (businessObjectType != null) { if (businessObjectType.GetProperty(name) != null) { str = str + string.Format("{0},", name); } if (businessObjectType.GetProperty(str4) != null) { str = str + string.Format("{0},", str4); } } } catch { } if (!string.IsNullOrEmpty(objSTGridColumnsInfo.STGridColumnRepoDsplMem) && ((!objSTGridColumnsInfo.STGridColumnRepoDsplMem.Equals(tablePrimaryColumn) && !objSTGridColumnsInfo.STGridColumnRepoDsplMem.Equals(name)) && !objSTGridColumnsInfo.STGridColumnRepoDsplMem.Equals(str4))) { str = str + string.Format("{0},", objSTGridColumnsInfo.STGridColumnRepoDsplMem); } if (!objSTGridColumnsInfo.STGridColumnRepoDsplMem.StartsWith("FK_")) { if (!string.IsNullOrEmpty(objSTGridColumnsInfo.STGridColumnRepoCol1) && ((!objSTGridColumnsInfo.STGridColumnRepoCol1.Equals(tablePrimaryColumn) && !objSTGridColumnsInfo.STGridColumnRepoCol1.Equals(name)) && !objSTGridColumnsInfo.STGridColumnRepoCol1.Equals(str4))) { str = str + string.Format("{0},", objSTGridColumnsInfo.STGridColumnRepoCol1); } if (!string.IsNullOrEmpty(objSTGridColumnsInfo.STGridColumnRepoCol2) && ((!objSTGridColumnsInfo.STGridColumnRepoCol2.Equals(tablePrimaryColumn) && !objSTGridColumnsInfo.STGridColumnRepoCol2.Equals(name)) && !objSTGridColumnsInfo.STGridColumnRepoCol2.Equals(str4))) { str = str + string.Format("{0},", objSTGridColumnsInfo.STGridColumnRepoCol2); } if (!string.IsNullOrEmpty(objSTGridColumnsInfo.STGridColumnRepoCol3) && ((!objSTGridColumnsInfo.STGridColumnRepoCol3.Equals(tablePrimaryColumn) && !objSTGridColumnsInfo.STGridColumnRepoCol3.Equals(name)) && !objSTGridColumnsInfo.STGridColumnRepoCol3.Equals(str4))) { str = str + string.Format("{0},", objSTGridColumnsInfo.STGridColumnRepoCol3); } if (!string.IsNullOrEmpty(objSTGridColumnsInfo.STGridColumnRepoCol4) && ((!objSTGridColumnsInfo.STGridColumnRepoCol4.Equals(tablePrimaryColumn) && !objSTGridColumnsInfo.STGridColumnRepoCol4.Equals(name)) && !objSTGridColumnsInfo.STGridColumnRepoCol4.Equals(str4))) { str = str + string.Format("{0},", objSTGridColumnsInfo.STGridColumnRepoCol4); } if (!string.IsNullOrEmpty(objSTGridColumnsInfo.STGridColumnRepoCol5) && ((!objSTGridColumnsInfo.STGridColumnRepoCol5.Equals(tablePrimaryColumn) && !objSTGridColumnsInfo.STGridColumnRepoCol5.Equals(name)) && !objSTGridColumnsInfo.STGridColumnRepoCol5.Equals(str4))) { str = str + string.Format("{0},", objSTGridColumnsInfo.STGridColumnRepoCol5); } } if (GMCWebApp.LookupExColumsList.ContainsKey(objSTGridColumnsInfo.STGridColumnRepository)) { str = str + string.Format("{0},", GMCWebApp.LookupExColumsList[objSTGridColumnsInfo.STGridColumnRepository]); } if (str.Substring(str.Length - 1).Equals(",")) { str = str.Substring(0, str.Length - 1); } return(str); }
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); }
public Dictionary <List <STGridColumnsInfo>, DataSet> ShowModuleByJournal(String strSourceLeger, String strDocumentNo, ADInboxItemsInfo objInbox, STFieldsInfo objOldField) { STModulesController ModuleCtrl = new STModulesController(); STModuleTablesController ModuleTableCtrl = new STModuleTablesController(); int iMainObjectID = -1; String strTable = String.Empty; String strTablePrefix = String.Empty; String strPrimaryKey = String.Empty; Object MainObj = null; int iModuleID = 0; List <DataRow> dr = GetLocalDataSet("STModuleID,STModuleName", "STModules", string.Format("STModuleName = '{0}'", strSourceLeger)); if (dr.Count > 0) { iModuleID = Convert.ToInt32(dr.First()["STModuleID"]); } dr = GetLocalDataSet("STModuleTableID,STModuleTableName,STModuleID,STModuleTableLevelIndex", "STModuleTables", string.Format("STModuleID = {0} AND STModuleTableLevelIndex = 0", iModuleID)); if (dr.Count > 0) { strTable = dr.First()["STModuleTableName"].ToString(); } if (String.IsNullOrEmpty(strTable) == false) { strTablePrefix = strTable.Substring(0, strTable.Length - 1); strPrimaryKey = strTablePrefix + "ID"; } BaseBusinessController Ctrl = BusinessControllerFactory.GetBusinessController(strTable + "Controller"); if (Ctrl != null) { MainObj = Ctrl.GetObjectByNo(strDocumentNo); } if (MainObj != null) { iMainObjectID = Convert.ToInt32(GMCDbUtil.GetPropertyValue(MainObj, strPrimaryKey)); if (GMCDbUtil.GetPropertyValue(MainObj, "FK_HREmployeeID") != null) { int iEmployeeID = Convert.ToInt32(GMCDbUtil.GetPropertyValue(MainObj, "FK_HREmployeeID")); objInbox.FK_HRFromEmployeeID = iEmployeeID; } if (GMCDbUtil.GetPropertyValue(MainObj, strTable.TrimEnd('s') + "Desc") != null) { //TextEdit txtRemark = (TextEdit)GetControlByName("fld_medADInboxItemRemark1"); //if (txtRemark != null) //{ // txtRemark.EditValue = GMCDbUtil.GetPropertyValue(MainObj, strTable.TrimEnd('s') + "Desc"); //} objInbox.ADInboxItemMessage = Convert.ToString(GMCDbUtil.GetPropertyValue(MainObj, strTable.TrimEnd('s') + "Desc")); } } //ShowModuleByJournal(strSourceLeger, iMainObjectID, false); //Thang - edit 26/4/2016 hiển thị chi tiêt chứng từ ADUserGroupsInfo objUserGroup = AuthConfig.CurrenUserGroupInfo; dr = GetLocalDataSet("STScreenID,STScreenNumber,STModuleID,STUserGroupID,STScreenSortOrder", "STScreens", string.Format(@"STModuleID = {0} AND STUserGroupID = {1} AND STScreenNumber like 'DM%' AND STScreenSortOrder > 0 AND STScreenSortOrder <= 1", iModuleID, objUserGroup.ADUserGroupID)); int iScreenID = 0; if (dr.Count > 0) { iScreenID = Convert.ToInt32(dr.First()["STScreenID"]); } //Thang edit - 8/2/2017 Chỉnh sửa nếu 1 user group không có giao diện riêng thì sẽ lấy mặc định giao diện admin if (iScreenID == 0) { int iUserGroupDefaultID = new ADUserGroupsController().GetObjectIDByName("ADMIN"); dr = GetLocalDataSet("STScreenID,STScreenNumber,STModuleID,STUserGroupID,STScreenSortOrder", "STScreens", string.Format(@"STModuleID = {0} AND STUserGroupID = {1} AND STScreenNumber like 'DM%' AND STScreenSortOrder > 0 AND STScreenSortOrder <= 1", iModuleID, iUserGroupDefaultID)); if (dr.Count > 0) { iScreenID = Convert.ToInt32(dr.First()["STScreenID"]); } } dr = GetLocalDataSet("*", "STFields", string.Format(@"STScreenID = {0} AND STFieldType = 'GMCGridControl' AND(STFieldDataSource like '%Items' OR STFieldDataSource like '%Details') AND STFieldGroup <> ''", iScreenID)); if (dr.Count == 0) { return(null); } STFieldsInfo objField = (STFieldsInfo) new STFieldsController().GetObjectFromDataRow(dr[0]); if (objField == null) { return(null); } BaseBusinessController itemCtrl = BusinessControllerFactory.GetBusinessController(objField.STFieldDataSource + "Controller"); DataSet ds = new DataSet(); if (itemCtrl != null) { ds = itemCtrl.GetAllDataByForeignColumn("FK_" + strPrimaryKey, iMainObjectID); } List <STGridColumnsInfo> lstGridColumns = new List <STGridColumnsInfo>(); if (objOldField == null || !objOldField.STFieldID.Equals(objField.STFieldID)) { objOldField = objField; dr = GetLocalDataSet("*", "STGridColumns", string.Format("FK_STFieldID = {0}", objField.STFieldID)); STGridColumnsController GridColCtrl = new STGridColumnsController(); dr.Distinct().ToList().ForEach(x => { STGridColumnsInfo colInfo = (STGridColumnsInfo)GridColCtrl.GetObjectFromDataRow(x); lstGridColumns.Add(colInfo); }); } return(new Dictionary <List <STGridColumnsInfo>, DataSet>() { { lstGridColumns, ds } }); }