private static T_COM_Master_Position GetItemFromReader(IDataReader dataReader)
        {
            T_COM_Master_Position objItem = new T_COM_Master_Position();

            objItem.PositionID = SqlHelper.GetInt(dataReader, "PositionID");

            objItem.PositionName_EN = SqlHelper.GetString(dataReader, "PositionName_EN");

            objItem.PositionName_VN = SqlHelper.GetString(dataReader, "PositionName_VN");

            objItem.EntityID = SqlHelper.GetInt(dataReader, "EntityID");

            objItem.EmployeeType = SqlHelper.GetString(dataReader, "EmployeeType");

            objItem.CreatedBy = SqlHelper.GetInt(dataReader, "CreatedBy");

            objItem.CreatedDate = SqlHelper.GetDateTime(dataReader, "CreatedDate");

            objItem.ModifiedBy = SqlHelper.GetInt(dataReader, "ModifiedBy");

            objItem.ModifiedDate = SqlHelper.GetDateTime(dataReader, "ModifiedDate");

            objItem.IsActive = SqlHelper.GetBoolean(dataReader, "IsActive");



            return(objItem);
        }
        public static T_COM_Master_Position UpdateItem(T_COM_Master_Position model)
        {
            int result = 0;

            using (var reader = SqlHelper.ExecuteReaderService(ModuleConfig.MyConnection, CommandType.StoredProcedure, "T_COM_Master_Position_Update", CreateSqlParameter(model)))
            {
                while (reader.Read())
                {
                    result = (int)reader[0];
                }
            }
            return(GetItemByID(result));
        }
        public static T_COM_Master_PositionCollection Search(SearchFilter SearchKey)
        {
            T_COM_Master_PositionCollection collection = new T_COM_Master_PositionCollection();

            using (var reader = SqlHelper.ExecuteReaderService(ModuleConfig.MyConnection, "T_COM_Master_Position_Search", SearchFilterManager.SqlSearchParamNoCompany(SearchKey)))
            {
                while (reader.Read())
                {
                    T_COM_Master_Position obj = new T_COM_Master_Position();
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
        public static T_COM_Master_PositionCollection GetAllItem()
        {
            T_COM_Master_PositionCollection collection = new T_COM_Master_PositionCollection();

            using (var reader = SqlHelper.ExecuteReaderService(ModuleConfig.MyConnection, "T_COM_Master_Position_GetAll", null))
            {
                while (reader.Read())
                {
                    T_COM_Master_Position obj = new T_COM_Master_Position();
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
        public static T_COM_Master_Position GetItemByName(string PositionName_EN)
        {
            T_COM_Master_Position item = new T_COM_Master_Position();
            var sqlParams = new SqlParameter[1];

            sqlParams[0] = new SqlParameter("@PositionName_EN", PositionName_EN);
            using (var reader = SqlHelper.ExecuteReaderService(ModuleConfig.MyConnection, "T_COM_Master_Position_GetByName", sqlParams))
            {
                while (reader.Read())
                {
                    item = GetItemFromReader(reader);
                }
            }
            return(item);
        }
 private static SqlParameter[] CreateSqlParameter(T_COM_Master_Position model)
 {
     return(new SqlParameter[]
     {
         new SqlParameter("@PositionID", model.PositionID),
         new SqlParameter("@PositionName_EN", model.PositionName_EN),
         new SqlParameter("@PositionName_VN", model.PositionName_VN),
         new SqlParameter("@EntityID", model.EntityID),
         new SqlParameter("@EmployeeType", model.EmployeeType),
         new SqlParameter("@CreatedBy", model.CreatedBy),
         new SqlParameter("@CreatedDate", model.CreatedDate),
         new SqlParameter("@ModifiedBy", model.ModifiedBy),
         new SqlParameter("@ModifiedDate", model.ModifiedDate),
         new SqlParameter("@IsActive", model.IsActive),
     });
 }