示例#1
0
        /// <summary>
        /// Load Check Items Data
        /// </summary>
        /// <param name="checkItemName"></param>
        /// Owner:Andy Gao 2011-07-12 08:48:53
        private void LoadCheckItemsData(string checkItemName)
        {
            string msg;

            int pageNo, pageSize, pages, records;

            this.paginationCheckItems.GetPaginationProperties(out pageNo, out pageSize);

            DataTable dataTable = this.equipmentCheckItemEntity.LoadCheckItemsData(checkItemName, pageNo, pageSize, out pages, out records, out msg);

            if (string.IsNullOrEmpty(msg))
            {
                this.paginationCheckItems.SetPaginationProperties(pageNo, pageSize, pages, records);

                this.grdCheckItemList.DataSource = dataTable;
            }
            else
            {
                this.grdCheckItemList.DataSource = EMS_CHECKITEMS_FIELDS.CreateDataTable(true);

                MessageService.ShowError(msg);
            }

            this.grvCheckItemList.BestFitColumns();

            State = ControlState.Read;
        }
示例#2
0
        protected override void InitUIControls()
        {
            #region Initial Check Item Type ComboBox

            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("CHECKITEM_TYPE");

            dataTable.Rows.Add("DATA");
            dataTable.Rows.Add("STRING");
            dataTable.Rows.Add("Y/N");

            dataTable.AcceptChanges();

            this.cmbCheckItemType.Properties.Columns.Clear();

            this.cmbCheckItemType.Properties.Columns.Add(new LookUpColumnInfo("CHECKITEM_TYPE"));

            this.cmbCheckItemType.Properties.ShowHeader = false;

            this.cmbCheckItemType.Properties.DisplayMember = "CHECKITEM_TYPE";
            this.cmbCheckItemType.Properties.ValueMember   = "CHECKITEM_TYPE";

            this.cmbCheckItemType.Properties.DataSource = dataTable;

            #endregion

            #region Initial Check Item Grid

            dataTable = EMS_CHECKITEMS_FIELDS.CreateDataTable(true);

            ControlUtils.InitialGridView(this.grvCheckItemList, dataTable);

            #endregion
        }
示例#3
0
        public override bool Insert()
        {
            DataSet reqDS = new DataSet();

            DataTable checkItemsDataTable = EMS_CHECKITEMS_FIELDS.CreateDataTable(false);

            Dictionary <string, string> dataRow = new Dictionary <string, string>()
            {
                { EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_KEY, checkItemKey },
                { EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_NAME, checkItemName },
                { EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_TYPE, checkItemType },
                { EMS_CHECKITEMS_FIELDS.FIELD_DESCRIPTION, description },

                { EMS_CHECKITEMS_FIELDS.FIELD_CREATOR, Creator },
                { EMS_CHECKITEMS_FIELDS.FIELD_CREATE_TIMEZONE_KEY, CreateTimeZone },
                { EMS_CHECKITEMS_FIELDS.FIELD_CREATE_TIME, string.Empty }
            };

            FanHai.Hemera.Utils.Common.Utils.AddKeyValuesToDataTable(ref checkItemsDataTable, dataRow);

            checkItemsDataTable.AcceptChanges();

            reqDS.Tables.Add(checkItemsDataTable);

            string msg;

            DataSet resDS = FanHai.Hemera.Utils.Common.Utils.ExecuteEngineMethod("FanHai.Hemera.Modules.EMS.EquipmentCheckItemsEngine, FanHai.Hemera.Modules.EMS", "InsertCheckItem", reqDS, out msg);

            if (string.IsNullOrEmpty(msg))
            {
                CreateTime = resDS.ExtendedProperties.ContainsKey(PARAMETERS.OUTPUT_EDIT_TIME) ? resDS.ExtendedProperties[PARAMETERS.OUTPUT_EDIT_TIME].ToString() : string.Empty;

                return(true);
            }
            else
            {
                MessageService.ShowError(msg);

                return(false);
            }
        }
示例#4
0
        public override bool Update()
        {
            DataSet reqDS = new DataSet();

            reqDS.ExtendedProperties.Add(PARAMETERS.INPUT_KEY, checkItemKey);
            reqDS.ExtendedProperties.Add(PARAMETERS.INPUT_EDITOR, Editor);
            reqDS.ExtendedProperties.Add(PARAMETERS.INPUT_EDIT_TIME, EditTime);

            this.DirtyList.Add(EMS_CHECKITEMS_FIELDS.FIELD_EDIT_TIME, new DirtyItem(EMS_CHECKITEMS_FIELDS.FIELD_EDIT_TIME, string.Empty, string.Empty));

            Editor       = PropertyService.Get(PROPERTY_FIELDS.USER_NAME);
            EditTimeZone = PropertyService.Get(PROPERTY_FIELDS.TIMEZONE);

            DataTable checkItemsDataTable = EMS_CHECKITEMS_FIELDS.CreateDataTable(false);

            FanHai.Hemera.Utils.Common.Utils.AddKeyValuesToDataTable(ref checkItemsDataTable, this.DirtyList);

            checkItemsDataTable.AcceptChanges();

            reqDS.Tables.Add(checkItemsDataTable);

            string msg;

            DataSet resDS = FanHai.Hemera.Utils.Common.Utils.ExecuteEngineMethod("FanHai.Hemera.Modules.EMS.EquipmentCheckItemsEngine, FanHai.Hemera.Modules.EMS", "UpdateCheckItem", reqDS, out msg);

            if (string.IsNullOrEmpty(msg))
            {
                EditTime = resDS.ExtendedProperties.ContainsKey(PARAMETERS.OUTPUT_EDIT_TIME) ? resDS.ExtendedProperties[PARAMETERS.OUTPUT_EDIT_TIME].ToString() : string.Empty;

                return(true);
            }
            else
            {
                MessageService.ShowError(msg);

                return(false);
            }
        }
示例#5
0
        public DataSet DeleteCheckItem(DataSet reqDS)
        {
            DataSet resDS = new DataSet();

            if (reqDS != null &&
                reqDS.ExtendedProperties.ContainsKey(PARAMETERS.INPUT_KEY) &&
                reqDS.ExtendedProperties.ContainsKey(PARAMETERS.INPUT_EDITOR) &&
                reqDS.ExtendedProperties.ContainsKey(PARAMETERS.INPUT_EDIT_TIME))
            {
                string checkItemKey = reqDS.ExtendedProperties[PARAMETERS.INPUT_KEY].ToString();
                string editor       = reqDS.ExtendedProperties[PARAMETERS.INPUT_EDITOR].ToString();
                string editTime     = reqDS.ExtendedProperties[PARAMETERS.INPUT_EDIT_TIME].ToString();

                try
                {
                    EMS_CHECKITEMS_FIELDS checkItemsFields = new EMS_CHECKITEMS_FIELDS();

                    #region Build Delete SQL Conditions

                    Conditions conditions = new Conditions();

                    Condition condition;

                    if (string.IsNullOrEmpty(checkItemKey))
                    {
                        condition = new Condition(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_KEY,
                                                  GlobalEnums.DatabaseCompareOperator.Null, string.Empty);
                    }
                    else
                    {
                        condition = new Condition(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_KEY,
                                                  GlobalEnums.DatabaseCompareOperator.Equal, checkItemKey);
                    }

                    conditions.Add(condition);

                    if (string.IsNullOrEmpty(editor))
                    {
                        condition = new Condition(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKITEMS_FIELDS.FIELD_EDITOR,
                                                  GlobalEnums.DatabaseCompareOperator.Null, string.Empty);
                    }
                    else
                    {
                        condition = new Condition(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKITEMS_FIELDS.FIELD_EDITOR,
                                                  GlobalEnums.DatabaseCompareOperator.Equal, editor);
                    }

                    conditions.Add(condition);

                    if (string.IsNullOrEmpty(editTime))
                    {
                        condition = new Condition(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKITEMS_FIELDS.FIELD_EDIT_TIME,
                                                  GlobalEnums.DatabaseCompareOperator.Null, string.Empty);
                    }
                    else
                    {
                        condition = new Condition(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKITEMS_FIELDS.FIELD_EDIT_TIME,
                                                  GlobalEnums.DatabaseCompareOperator.Equal, editTime);
                    }

                    conditions.Add(condition);

                    List <Conditions> conditionsList = new List <Conditions>()
                    {
                        conditions
                    };

                    #endregion

                    List <string> sqlStringList = DatabaseTable.BuildDeleteSqlStatements(checkItemsFields, conditionsList);

                    string sqlString = string.Empty;

                    if (sqlStringList.Count > 0)
                    {
                        sqlString = sqlStringList[0];
                    }

                    #region Validate Check List Reference

                    conditions = new Conditions();

                    conditions.Add(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKLIST_ITEM_FIELDS.FIELD_CHECKITEM_KEY, GlobalEnums.DatabaseCompareOperator.Equal, checkItemKey);

                    EMS_CHECKLIST_ITEM_FIELDS checkListItemFields = new EMS_CHECKLIST_ITEM_FIELDS();

                    List <string> interestColumns = new List <string>()
                    {
                        EMS_CHECKLIST_ITEM_FIELDS.FIELD_CHECKITEM_KEY
                    };

                    string checkSqlString = DatabaseTable.BuildQuerySqlStatement(checkListItemFields, interestColumns, conditions);

                    object scalar = db.ExecuteScalar(CommandType.Text, checkSqlString);

                    if (scalar != null && scalar != DBNull.Value)
                    {
                        throw new Exception("检查项已经关联检查表单,不能删除!");
                    }

                    #endregion

                    #region Delete Check Item Data

                    if (db.ExecuteNonQuery(CommandType.Text, sqlString) > 0)
                    {
                        resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_MESSAGE, string.Empty);
                    }
                    else
                    {
                        throw new Exception("数据处理失败,请重新刷新数据后再提交!");
                    }

                    #endregion
                }
                catch (Exception ex)
                {
                    resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_MESSAGE, ex.Message);

                    LogService.LogError("DeleteCheckItem Error: " + ex.Message);
                }
            }
            else
            {
                resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_MESSAGE, "提交数据不存在,请重新提交!");
            }

            return(resDS);
        }
示例#6
0
        public DataSet GetCheckItems(DataSet reqDS)
        {
            DataSet resDS = new DataSet();

            int pages   = 0;
            int records = 0;

            if (reqDS != null &&
                reqDS.ExtendedProperties.ContainsKey(PARAMETERS.INPUT_KEY) &&
                reqDS.ExtendedProperties.ContainsKey(PARAMETERS.INPUT_PAGENO) &&
                reqDS.ExtendedProperties.ContainsKey(PARAMETERS.INPUT_PAGESIZE))
            {
                string checkItemName = reqDS.ExtendedProperties[PARAMETERS.INPUT_KEY].ToString();
                int    pageNo        = Convert.ToInt32(reqDS.ExtendedProperties[PARAMETERS.INPUT_PAGENO]);
                int    pageSize      = Convert.ToInt32(reqDS.ExtendedProperties[PARAMETERS.INPUT_PAGESIZE]);

                try
                {
                    EMS_CHECKITEMS_FIELDS checkItemsFields = new EMS_CHECKITEMS_FIELDS();

                    List <string> interestColumns = new List <string>();

                    interestColumns.Add(EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_KEY);
                    interestColumns.Add(EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_NAME);
                    interestColumns.Add(EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_TYPE);
                    interestColumns.Add(EMS_CHECKITEMS_FIELDS.FIELD_DESCRIPTION);

                    interestColumns.Add(EMS_CHECKITEMS_FIELDS.FIELD_CREATOR);
                    interestColumns.Add(EMS_CHECKITEMS_FIELDS.FIELD_CREATE_TIMEZONE_KEY);
                    interestColumns.Add(EMS_CHECKITEMS_FIELDS.FIELD_CREATE_TIME);
                    interestColumns.Add(EMS_CHECKITEMS_FIELDS.FIELD_EDITOR);
                    interestColumns.Add(EMS_CHECKITEMS_FIELDS.FIELD_EDIT_TIMEZONE_KEY);
                    interestColumns.Add(EMS_CHECKITEMS_FIELDS.FIELD_EDIT_TIME);

                    Conditions conditions = new Conditions();

                    if (!string.IsNullOrEmpty(checkItemName))
                    {
                        conditions.Add(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_NAME, GlobalEnums.DatabaseCompareOperator.Like, string.Format("%{0}%", checkItemName));
                    }

                    string sqlString = DatabaseTable.BuildQuerySqlStatement(checkItemsFields, interestColumns, conditions);

                    if (pageNo > 0 && pageSize > 0)
                    {
                        AllCommonFunctions.CommonPagingData(sqlString, pageNo, pageSize, out pages, out records, db, resDS, EMS_CHECKITEMS_FIELDS.DATABASE_TABLE_NAME);
                    }
                    else
                    {
                        db.LoadDataSet(CommandType.Text, sqlString, resDS, new string[] { EMS_CHECKITEMS_FIELDS.DATABASE_TABLE_NAME });
                    }

                    resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_MESSAGE, string.Empty);
                    resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_PAGES, pages);
                    resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_RECORDS, records);
                }
                catch (Exception ex)
                {
                    resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_MESSAGE, ex.Message);

                    LogService.LogError("GetCheckItems Error: " + ex.Message);
                }
            }
            else
            {
                resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_MESSAGE, "提交数据不存在,请重新提交!");
            }

            return(resDS);
        }
示例#7
0
        public DataSet UpdateCheckItem(DataSet reqDS)
        {
            DataSet resDS = new DataSet();

            if (reqDS != null &&
                reqDS.Tables.Contains(EMS_CHECKITEMS_FIELDS.DATABASE_TABLE_NAME) &&
                reqDS.ExtendedProperties.ContainsKey(PARAMETERS.INPUT_KEY) &&
                reqDS.ExtendedProperties.ContainsKey(PARAMETERS.INPUT_EDITOR) &&
                reqDS.ExtendedProperties.ContainsKey(PARAMETERS.INPUT_EDIT_TIME))
            {
                DataTable checkItemsDataTable = reqDS.Tables[EMS_CHECKITEMS_FIELDS.DATABASE_TABLE_NAME];

                string checkItemKey = reqDS.ExtendedProperties[PARAMETERS.INPUT_KEY].ToString();
                string editor       = reqDS.ExtendedProperties[PARAMETERS.INPUT_EDITOR].ToString();
                string editTime     = reqDS.ExtendedProperties[PARAMETERS.INPUT_EDIT_TIME].ToString();

                try
                {
                    EMS_CHECKITEMS_FIELDS checkItemsFields = new EMS_CHECKITEMS_FIELDS();

                    #region Build Update SQL Conditions

                    Conditions conditions = new Conditions();

                    Condition condition;

                    if (string.IsNullOrEmpty(checkItemKey))
                    {
                        condition = new Condition(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_KEY,
                                                  GlobalEnums.DatabaseCompareOperator.Null, string.Empty);
                    }
                    else
                    {
                        condition = new Condition(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_KEY,
                                                  GlobalEnums.DatabaseCompareOperator.Equal, checkItemKey);
                    }

                    conditions.Add(condition);

                    if (string.IsNullOrEmpty(editor))
                    {
                        condition = new Condition(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKITEMS_FIELDS.FIELD_EDITOR,
                                                  GlobalEnums.DatabaseCompareOperator.Null, string.Empty);
                    }
                    else
                    {
                        condition = new Condition(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKITEMS_FIELDS.FIELD_EDITOR,
                                                  GlobalEnums.DatabaseCompareOperator.Equal, editor);
                    }

                    conditions.Add(condition);

                    if (string.IsNullOrEmpty(editTime))
                    {
                        condition = new Condition(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKITEMS_FIELDS.FIELD_EDIT_TIME,
                                                  GlobalEnums.DatabaseCompareOperator.Null, string.Empty);
                    }
                    else
                    {
                        condition = new Condition(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKITEMS_FIELDS.FIELD_EDIT_TIME,
                                                  GlobalEnums.DatabaseCompareOperator.Equal, editTime);
                    }

                    conditions.Add(condition);

                    List <Conditions> conditionsList = new List <Conditions>()
                    {
                        conditions
                    };

                    #endregion

                    List <string> sqlStringList = DatabaseTable.BuildUpdateSqlStatements(checkItemsFields, checkItemsDataTable, conditionsList);

                    string checkItemName = string.Empty;
                    string sqlString     = string.Empty;

                    if (sqlStringList.Count > 0 && checkItemsDataTable.Rows.Count > 0)
                    {
                        checkItemName = checkItemsDataTable.Rows[0][EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_NAME].ToString();

                        sqlString = sqlStringList[0];
                    }

                    using (DbConnection connection = db.CreateConnection())
                    {
                        connection.Open();

                        using (DbTransaction transaction = connection.BeginTransaction())
                        {
                            try
                            {
                                #region Validate Check Item Name

                                if (!string.IsNullOrEmpty(checkItemName))
                                {
                                    conditions = new Conditions();

                                    conditions.Add(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_NAME, GlobalEnums.DatabaseCompareOperator.Equal, checkItemName);

                                    conditions.Add(GlobalEnums.DatabaseLogicOperator.And, EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_KEY, GlobalEnums.DatabaseCompareOperator.NotEqual, checkItemKey);

                                    string returnData = AllCommonFunctions.GetSpecifyTableColumnData(checkItemsFields, EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_NAME, conditions, transaction);

                                    if (!string.IsNullOrEmpty(returnData))
                                    {
                                        throw new Exception("检查项名称已存在!");
                                    }
                                }

                                #endregion

                                #region Update Check Item Data

                                if (db.ExecuteNonQuery(transaction, CommandType.Text, sqlString) > 0)
                                {
                                    editTime = AllCommonFunctions.GetSpecifyTableColumnData(checkItemsFields, EMS_CHECKITEMS_FIELDS.FIELD_EDIT_TIME, EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_KEY,
                                                                                            checkItemKey, transaction);
                                }
                                else
                                {
                                    throw new Exception("数据处理失败,请重新刷新数据后再提交!");
                                }

                                #endregion

                                transaction.Commit();
                            }
                            catch
                            {
                                transaction.Rollback();

                                throw;
                            }
                            finally
                            {
                                connection.Close();
                            }
                        }
                    }

                    resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_MESSAGE, string.Empty);
                    resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_EDIT_TIME, editTime);
                }
                catch (Exception ex)
                {
                    resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_MESSAGE, ex.Message);

                    LogService.LogError("UpdateCheckItem Error: " + ex.Message);
                }
            }
            else
            {
                resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_MESSAGE, "提交数据不存在,请重新提交!");
            }

            return(resDS);
        }
示例#8
0
        public DataSet InsertCheckItem(DataSet reqDS)
        {
            DataSet resDS = new DataSet();

            if (reqDS != null && reqDS.Tables.Contains(EMS_CHECKITEMS_FIELDS.DATABASE_TABLE_NAME))
            {
                DataTable checkItemsDataTable = reqDS.Tables[EMS_CHECKITEMS_FIELDS.DATABASE_TABLE_NAME];

                try
                {
                    EMS_CHECKITEMS_FIELDS checkItemsFields = new EMS_CHECKITEMS_FIELDS();

                    List <string> sqlStringList = DatabaseTable.BuildInsertSqlStatements(checkItemsFields, checkItemsDataTable);

                    string checkItemKey  = string.Empty;
                    string checkItemName = string.Empty;
                    string createTime    = string.Empty;
                    string sqlString     = string.Empty;

                    if (sqlStringList.Count > 0 && checkItemsDataTable.Rows.Count > 0)
                    {
                        checkItemKey  = checkItemsDataTable.Rows[0][EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_KEY].ToString();
                        checkItemName = checkItemsDataTable.Rows[0][EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_NAME].ToString();

                        sqlString = sqlStringList[0];
                    }

                    using (DbConnection connection = db.CreateConnection())
                    {
                        connection.Open();

                        using (DbTransaction transaction = connection.BeginTransaction())
                        {
                            try
                            {
                                #region Validate Check Item Name

                                string returnData = AllCommonFunctions.GetSpecifyTableColumnData(checkItemsFields, EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_NAME, EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_NAME, checkItemName, transaction);

                                if (!string.IsNullOrEmpty(returnData))
                                {
                                    throw new Exception("检查项名称已存在!");
                                }

                                #endregion

                                #region Insert Check Item Data

                                if (db.ExecuteNonQuery(transaction, CommandType.Text, sqlString) > 0)
                                {
                                    createTime = AllCommonFunctions.GetSpecifyTableColumnData(checkItemsFields, EMS_CHECKITEMS_FIELDS.FIELD_CREATE_TIME, EMS_CHECKITEMS_FIELDS.FIELD_CHECKITEM_KEY, checkItemKey, transaction);
                                }
                                else
                                {
                                    throw new Exception("数据处理失败,请重新刷新数据后再提交!");
                                }

                                #endregion

                                transaction.Commit();
                            }
                            catch
                            {
                                transaction.Rollback();

                                throw;
                            }
                            finally
                            {
                                connection.Close();
                            }
                        }
                    }

                    resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_MESSAGE, string.Empty);
                    resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_EDIT_TIME, createTime);
                }
                catch (Exception ex)
                {
                    resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_MESSAGE, ex.Message);

                    LogService.LogError("InsertCheckItem Error: " + ex.Message);
                }
            }
            else
            {
                resDS.ExtendedProperties.Add(PARAMETERS.OUTPUT_MESSAGE, "提交数据不存在,请重新提交!");
            }

            return(resDS);
        }