예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string colName = Request.QueryString["colName"];

            objectId = Convert.ToInt64(Request.QueryString["object_id"]);

            var objType = Request.QueryString["object_type"];

            switch (objType)
            {
            case "project":
                cate = DicEnum.UDF_CATE.PROJECTS;
                break;

            default:
                break;
            }
            thisUdfInfo = new DAL.sys_udf_field_dal().GetInfoByCateAndName((int)cate, colName);

            //if (!IsPostBack)
            //{
            var bll     = new UserDefinedFieldsBLL();
            var udfList = bll.GetUdf(cate);

            udf = udfList.First(f => f.name.Equals(colName));
            var udfValues = bll.GetUdfValue(cate, objectId, udfList);

            udfValue = udfValues.First(v => v.id == udf.id).value;
            //}


            if (thisUdfInfo == null)  // 没有找到该自定义相关信息,停止响应
            {
                Response.End();
            }
        }
예제 #2
0
        /// <summary>
        /// 增加自定义字段
        /// </summary>
        /// <param name="cate"></param>
        /// <param name="udf"></param>
        /// <returns></returns>
        public bool AddUdf(DicEnum.UDF_CATE cate, UserDefinedFieldDto udf, long userId)
        {
            string table = GetTableName(cate);
            var    dal   = new sys_udf_field_dal();

            var field = new sys_udf_field();

            field.id                    = dal.GetNextIdCom();
            field.col_name              = GetNextColName();
            field.col_comment           = udf.name;
            field.description           = udf.description;
            field.cate_id               = udf.cate;
            field.data_type_id          = udf.data_type;
            field.default_value         = udf.default_value;
            field.is_protected          = udf.is_protected;
            field.is_required           = udf.required;
            field.is_encrypted          = udf.is_encrypted;
            field.is_visible_in_portal  = udf.is_visible_in_portal;
            field.crm_to_project_udf_id = udf.crm_to_project;
            field.sort_order            = udf.sort_order;
            field.is_active             = udf.is_active;
            field.display_format_id     = udf.display_format;
            field.decimal_length        = udf.decimal_length;
            field.create_user_id        = userId;
            field.update_user_id        = userId;
            field.create_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            field.update_time           = field.create_time;
            dal.Insert(field);
            OperLogBLL.OperLogAdd <sys_udf_field>(field, field.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SYS_UDF_FILED, "新增自定义字段");

            if (udf.data_type == (int)DicEnum.UDF_DATA_TYPE.LIST)       // 字段为列表类型,保存列表值
            {
                if (udf.list != null && udf.list.Count > 0)
                {
                    var listDal = new sys_udf_list_dal();
                    foreach (var listVal in udf.list)
                    {
                        sys_udf_list val = new sys_udf_list();
                        val.id             = listDal.GetNextIdCom();
                        val.is_default     = listVal.is_default;
                        val.name           = listVal.name;
                        val.sort_order     = listVal.sort_order;
                        val.udf_field_id   = field.id;
                        val.status_id      = 0;
                        val.create_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                        val.update_time    = val.create_time;
                        val.create_user_id = field.create_user_id;
                        val.update_user_id = val.create_user_id;
                        listDal.Insert(val);

                        OperLogBLL.OperLogAdd <sys_udf_list>(val, val.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SYS_UDF_FILED_LIST, "新增自定义字段值");
                    }
                }
            }

            string sql = $"alter table {table} add {field.col_name} varchar(";

            if (field.data_type_id == (int)DicEnum.UDF_DATA_TYPE.SINGLE_TEXT)
            {
                sql += "200)";
            }
            else if (field.data_type_id == (int)DicEnum.UDF_DATA_TYPE.MUILTI_TEXT)
            {
                sql += "2000)";
            }
            else
            {
                sql += "20)";
            }
            dal.ExecuteSQL(sql);
            if (field.cate_id == (int)DicEnum.UDF_CATE.TICKETS)
            {
                table = GetTableName(DicEnum.UDF_CATE.FORM_RECTICKET);
                sql   = $"alter table {table} add {field.col_name} varchar(";
                if (field.data_type_id == (int)DicEnum.UDF_DATA_TYPE.SINGLE_TEXT)
                {
                    sql += "200)";
                }
                else if (field.data_type_id == (int)DicEnum.UDF_DATA_TYPE.MUILTI_TEXT)
                {
                    sql += "2000)";
                }
                else
                {
                    sql += "20)";
                }
                dal.ExecuteSQL(sql);

                table = GetTableName(DicEnum.UDF_CATE.FORM_TICKET);
                sql   = $"alter table {table} add {field.col_name} varchar(";
                if (field.data_type_id == (int)DicEnum.UDF_DATA_TYPE.SINGLE_TEXT)
                {
                    sql += "200)";
                }
                else if (field.data_type_id == (int)DicEnum.UDF_DATA_TYPE.MUILTI_TEXT)
                {
                    sql += "2000)";
                }
                else
                {
                    sql += "20)";
                }
                dal.ExecuteSQL(sql);
            }

            return(true);
        }