/// <summary>
       /// 插入设备信息
       /// </summary>
       /// <param name="model"></param>
       /// <returns></returns>
       public static int InsertCodeEquipmentInfo(CodeEquipmentTypeModel model)
       {

           UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
           //登陆日志
           try
           {
               int succ = 0;
               LogInfoModel logModel = InitLogInfo(model.CodeName);
               logModel.Element = ConstUtil.LOG_PROCESS_INSERT;
               //设置模块ID 模块ID请在ConstUtil中定义,以便维护
               logModel.ModuleID = ConstUtil.Menu_Equipment;
               //设置操作日志类型 修改
               logModel.ObjectName = ConstUtil.CODING_RULE_TABLE_Equipment;
               //操作对象
               succ = CategorySetDBHelper.InsertCodeEquipmentInfo(model);
               if (succ<1)
                   logModel.Remark = ConstUtil.LOG_PROCESS_FAILED;
               else
                   logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS;
               LogDBHelper.InsertLog(logModel);
               return succ;
           }
           catch (Exception ex)
           {
               WriteSystemLog(userInfo, ex);
               return 0;
           }
       }
        /// <summary>
        /// 修改设备分类信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int UpdateCodeEquipmentInfo(CodeEquipmentTypeModel model)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("uPDATE officedba.CodeEquipmentType");
            sql.AppendLine("  SET CompanyCD =@CompanyCD                      ");
            sql.AppendLine("     ,TypeFlag = @TypeFlag                      ");
            sql.AppendLine("     ,CodeName =@CodeName                      ");
            sql.AppendLine("     ,SupperID =@SupperID                      ");
            sql.AppendLine("     ,Description =@Description                   ");
            sql.AppendLine("     ,WarningLimit =@WarningLimit                  ");
            //sql.AppendLine("     ,Path = @Path                         ");
            sql.AppendLine("     ,UsedStatus = @UsedStatus                   ");
            sql.AppendLine("     ,ModifiedDate =@ModifiedDate                  ");
            sql.AppendLine("     ,ModifiedUserID =@ModifiedUserID                ");
            sql.AppendLine("WHERE  ID=@ID                               ");
            //设置参数
            SqlParameter[] param = new SqlParameter[10];
            param[0] = SqlHelper.GetParameter("@CompanyCD", model.CompanyCD);
            param[1] = SqlHelper.GetParameter("@TypeFlag", model.TypeFlag);
            param[2] = SqlHelper.GetParameter("@CodeName", model.CodeName);
            param[3] = SqlHelper.GetParameter("@SupperID", model.SupperID);
            param[4] = SqlHelper.GetParameter("@Description", model.Description);
            param[5] = SqlHelper.GetParameter("@WarningLimit", model.WarningLimit);
            param[6] = SqlHelper.GetParameter("@UsedStatus", model.UsedStatus);
            param[7] = SqlHelper.GetParameter("@ModifiedDate", model.ModifiedDate);
            param[8] = SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID);
            param[9] = SqlHelper.GetParameter("@ID", model.ID);
            return SqlHelper.ExecuteTransSql(sql.ToString(), param);


        }
        /// <summary>
        /// 插入设备分类信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int InsertCodeEquipmentInfo(CodeEquipmentTypeModel model)
        {
            //SQL拼写
            SqlParameter[] param = new SqlParameter[10];
            param[0] = SqlHelper.GetParameter("@CompanyCD", model.CompanyCD);
            param[1] = SqlHelper.GetParameter("@TypeFlag", model.TypeFlag);
            param[2] = SqlHelper.GetParameter("@CodeName", model.CodeName);
            param[3] = SqlHelper.GetParameter("@SupperID", model.SupperID);
            param[4] = SqlHelper.GetParameter("@Description", model.Description);
            param[5] = SqlHelper.GetParameter("@WarningLimit", model.WarningLimit);
            param[6] = SqlHelper.GetParameter("@UsedStatus", model.UsedStatus);
            param[7] = SqlHelper.GetParameter("@ModifiedDate", model.ModifiedDate);
            param[8] = SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID);
            SqlParameter paramid = new SqlParameter("@RetID", SqlDbType.Int);
            paramid.Direction = ParameterDirection.Output;
            param[9] = paramid;
            //创建命令
            SqlCommand comm = new SqlCommand();
            SqlHelper.ExecuteTransStoredProcedure("officedba.CodeEquipmentInfo_insert", comm, param);
            int contantid = Convert.ToInt32(comm.Parameters["@RetID"].Value);

            return contantid;
        }
       /// <summary>
       /// 修改设备种类信息
       /// </summary>
       /// <param name="model"></param>
       /// <returns></returns>
       public static int UpdateCodeEquipmentInfo(CodeEquipmentTypeModel model)
       {


           UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
           //登陆日志
           try
           {
               int succ = 0;
               LogInfoModel logModel = InitLogInfo(model.CodeName);
               logModel.Element = ConstUtil.LOG_PROCESS_UPDATE;
               logModel.ModuleID = ConstUtil.Menu_Equipment;
               //设置操作日志类型 修改
               logModel.ObjectName = ConstUtil.CODING_RULE_TABLE_Equipment;
               succ = CategorySetDBHelper.UpdateCodeEquipmentInfo(model);
               if (succ < 1)
                   logModel.Remark = ConstUtil.LOG_PROCESS_FAILED;
               else
                   logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS;
               LogDBHelper.InsertLog(logModel);
               return succ;
           }
           catch (Exception)
           {
               return 0;
               throw;
           }
       }
       /// <summary>
       /// 修改文档种类信息
       /// </summary>
       /// <param name="model"></param>
       /// <returns></returns>
       public static int UpdateCodeBigTypeInfo(CodeEquipmentTypeModel model,string TableName)
       {
           UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
           //登陆日志
           try
           {
               int succ = 0;
               LogInfoModel logModel = InitLogInfo(model.CodeName);
               logModel.Element = ConstUtil.LOG_PROCESS_UPDATE;
               if (TableName == "officedba.CodeCompanyType")
               {
                   logModel.ModuleID = ConstUtil.Menu_CompanyType;
                   logModel.ObjectName = ConstUtil.CODING_RULE_TABLE_CompanyType;
               }
               else if (TableName == "officedba.CodeProductType")
               {
                   logModel.ModuleID = ConstUtil.Menu_ProductType;
                   logModel.ObjectName = ConstUtil.CODING_RULE_TABLE_ProductType;
               }
               succ = CategorySetDBHelper.UpdateCodeBigTypeInfo(model, TableName);
               if (succ < 1)
                   logModel.Remark = ConstUtil.LOG_PROCESS_FAILED;
               else
                   logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS;
               LogDBHelper.InsertLog(logModel);
               return succ;
           }
           catch (Exception)
           {
               return 0;
               throw;
           }


           //if (model == null)
           //    return 0;
           //try
           //{
           //    return CategorySetDBHelper.UpdateCodeBigTypeInfo(model,TableName);
           //}
           //catch (Exception ex)
           //{
           //    throw;
           //}

       }
        /// <summary>
        /// 根据ID获取文档信息
        /// </summary>
        /// <returns></returns>
        public static CodeEquipmentTypeModel GetodeDocType(int id)
        {
            CodeEquipmentTypeModel model = new CodeEquipmentTypeModel();
            string sql = "select * from officedba.CodeDocType where id=@id ";
            SqlParameter[] param = new SqlParameter[1];
            param[0] = SqlHelper.GetParameter("@id", id);
            DataTable dt = SqlHelper.ExecuteSql(sql, param);

            DataRow data = dt.Rows[0];
            if (dt.Rows.Count > 0)
            {
                model.SupperID = GetSafeData.ValidateDataRow_Int(data, "SupperID");
                model.ModifiedDate = GetSafeData.ValidateDataRow_DateTime(data, "ModifiedDate");
                model.UsedStatus = GetSafeData.ValidateDataRow_String(data, "UsedStatus");
                model.ModifiedUserID = GetSafeData.ValidateDataRow_String(data, "ModifiedUserID");
                model.CodeName = GetSafeData.ValidateDataRow_String(data, "CodeName");
                model.CompanyCD = GetSafeData.ValidateDataRow_String(data, "CompanyCD");
                model.Description = GetSafeData.ValidateDataRow_String(data, "Description");
                return model;
            }
            else
            {
                return null;
            }
        }
        /// <summary>
        /// 根据ID获取分类信息
        /// </summary>
        /// <returns></returns>
        public static CodeEquipmentTypeModel GetCodeBigTypeById(int id, string TableName)
        {
            CodeEquipmentTypeModel model = new CodeEquipmentTypeModel();
            string sql = "select * from " + TableName + " where id=@id ";
            SqlParameter[] param = new SqlParameter[1];
            param[0] = SqlHelper.GetParameter("@id", id);
            DataTable dt = SqlHelper.ExecuteSql(sql, param);

            DataRow data = dt.Rows[0];
            if (dt.Rows.Count > 0)
            {
                model.SupperID = GetSafeData.ValidateDataRow_Int(data, "SupperID");
                model.ModifiedDate = GetSafeData.ValidateDataRow_DateTime(data, "ModifiedDate");
                model.UsedStatus = GetSafeData.ValidateDataRow_String(data, "UsedStatus");
                model.ModifiedUserID = GetSafeData.ValidateDataRow_String(data, "ModifiedUserID");
                model.CodeName = GetSafeData.ValidateDataRow_String(data, "CodeName");
                model.CompanyCD = GetSafeData.ValidateDataRow_String(data, "CompanyCD");
                model.Description = GetSafeData.ValidateDataRow_String(data, "Description");
                if (TableName == "officedba.CodeCompanyType")// 往来单位
                    model.BigType = GetSafeData.ValidateDataRow_String(data, "BigType");
                else if (TableName == "officedba.CodeProductType")
                    model.BigType = GetSafeData.ValidateDataRow_String(data, "TypeFlag");
                return model;
            }
            else
            {
                return null;
            }
        }
        /// <summary>
        /// 修改分类信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int UpdateCodeBigTypeInfo(CodeEquipmentTypeModel model, string TableName)
        {
            StringBuilder sql = new StringBuilder();
            SqlParameter[] param = new SqlParameter[9];
            if (TableName == "officedba.CodeCompanyType")// 往来单位
            {
                sql.AppendLine("uPDATE  " + TableName + "");
                sql.AppendLine("  SET CompanyCD =@CompanyCD                      ");
                sql.AppendLine("     ,CodeName =@CodeName                      ");
                sql.AppendLine("     ,SupperID =@SupperID                      ");
                sql.AppendLine("     ,BigType =@TypeFlag                      ");
                sql.AppendLine("     ,Description =@Description                   ");
                sql.AppendLine("     ,UsedStatus = @UsedStatus                   ");
                sql.AppendLine("     ,ModifiedDate =@ModifiedDate                  ");
                sql.AppendLine("     ,ModifiedUserID =@ModifiedUserID                ");
                sql.AppendLine("WHERE  ID=@ID                               ");
                //设置参数
                param[0] = SqlHelper.GetParameter("@CompanyCD", model.CompanyCD);
                param[1] = SqlHelper.GetParameter("@CodeName", model.CodeName);
                param[2] = SqlHelper.GetParameter("@SupperID", model.SupperID);
                param[3] = SqlHelper.GetParameter("@TypeFlag", model.BigType);
                param[4] = SqlHelper.GetParameter("@Description", model.Description);
                param[5] = SqlHelper.GetParameter("@UsedStatus", model.UsedStatus);
                param[6] = SqlHelper.GetParameter("@ModifiedDate", model.ModifiedDate);
                param[7] = SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID);
                param[8] = SqlHelper.GetParameter("@ID", model.ID);
            }
            else if (TableName == "officedba.CodeProductType")
            {
                sql.AppendLine("uPDATE  " + TableName + "");
                sql.AppendLine("  SET CompanyCD =@CompanyCD                      ");
                sql.AppendLine("     ,CodeName =@CodeName                      ");
                sql.AppendLine("     ,SupperID =@SupperID                      ");
                sql.AppendLine("     ,TypeFlag =@TypeFlag                      ");
                sql.AppendLine("     ,Description =@Description                   ");
                sql.AppendLine("     ,UsedStatus = @UsedStatus                   ");
                sql.AppendLine("     ,ModifiedDate =@ModifiedDate                  ");
                sql.AppendLine("     ,ModifiedUserID =@ModifiedUserID                ");
                sql.AppendLine("WHERE  ID=@ID                               ");
                //设置参数
                param[0] = SqlHelper.GetParameter("@CompanyCD", model.CompanyCD);
                param[1] = SqlHelper.GetParameter("@CodeName", model.CodeName);
                param[2] = SqlHelper.GetParameter("@SupperID", model.SupperID);
                param[3] = SqlHelper.GetParameter("@TypeFlag", model.BigType);
                param[4] = SqlHelper.GetParameter("@Description", model.Description);
                param[5] = SqlHelper.GetParameter("@UsedStatus", model.UsedStatus);
                param[6] = SqlHelper.GetParameter("@ModifiedDate", model.ModifiedDate);
                param[7] = SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID);
                param[8] = SqlHelper.GetParameter("@ID", model.ID);
            }

            return SqlHelper.ExecuteTransSql(sql.ToString(), param);

        }