コード例 #1
0
        public int Add(Chain.Model.MemCustomField model)
        {
            int result;

            if (this.ExistTheSameColumnName(model.CustomType, model.CustomFieldName) || this.Exists(model.CustomField))
            {
                result = -1;
            }
            else
            {
                result = this.dal.Add(model);
            }
            return(result);
        }
コード例 #2
0
        public int Update(Chain.Model.MemCustomField model)
        {
            int result;

            if (this.Exists(model.CustomFieldID, model.CustomFieldName))
            {
                result = -1;
            }
            else
            {
                result = this.dal.Update(model);
            }
            return(result);
        }
コード例 #3
0
        public List <Chain.Model.MemCustomField> DataTableToList(DataTable dt)
        {
            List <Chain.Model.MemCustomField> modelList = new List <Chain.Model.MemCustomField>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                for (int i = 0; i < rowsCount; i++)
                {
                    Chain.Model.MemCustomField model = new Chain.Model.MemCustomField();
                    if (dt.Rows[i]["CustomFieldID"] != null && dt.Rows[i]["CustomFieldID"].ToString() != "")
                    {
                        model.CustomFieldID = int.Parse(dt.Rows[i]["CustomFieldID"].ToString());
                    }
                    if (dt.Rows[i]["CustomType"] != null && dt.Rows[i]["CustomType"].ToString() != "")
                    {
                        model.CustomType = int.Parse(dt.Rows[i]["CustomType"].ToString());
                    }
                    if (dt.Rows[i]["CustomField"] != null && dt.Rows[i]["CustomField"].ToString() != "")
                    {
                        model.CustomField = dt.Rows[i]["CustomField"].ToString();
                    }
                    if (dt.Rows[i]["CustomFieldName"] != null && dt.Rows[i]["CustomFieldName"].ToString() != "")
                    {
                        model.CustomFieldName = dt.Rows[i]["CustomFieldName"].ToString();
                    }
                    if (dt.Rows[i]["CustomFieldIsNull"] != null && dt.Rows[i]["CustomFieldIsNull"].ToString() != "")
                    {
                        if (dt.Rows[i]["CustomFieldIsNull"].ToString() == "1" || dt.Rows[i]["CustomFieldIsNull"].ToString().ToLower() == "true")
                        {
                            model.CustomFieldIsNull = true;
                        }
                        else
                        {
                            model.CustomFieldIsNull = false;
                        }
                    }
                    if (dt.Rows[i]["CustomFieldIsShow"] != null && dt.Rows[i]["CustomFieldIsShow"].ToString() != "")
                    {
                        if (dt.Rows[i]["CustomFieldIsShow"].ToString() == "1" || dt.Rows[i]["CustomFieldIsShow"].ToString().ToLower() == "true")
                        {
                            model.CustomFieldIsShow = true;
                        }
                        else
                        {
                            model.CustomFieldIsShow = false;
                        }
                    }
                    if (dt.Rows[i]["CustomFieldType"] != null && dt.Rows[i]["CustomFieldType"].ToString() != "")
                    {
                        model.CustomFieldType = dt.Rows[i]["CustomFieldType"].ToString();
                    }
                    if (dt.Rows[i]["CustomFieldInfo"] != null && dt.Rows[i]["CustomFieldInfo"].ToString() != "")
                    {
                        model.CustomFieldInfo = dt.Rows[i]["CustomFieldInfo"].ToString();
                    }
                    if (dt.Rows[i]["CustomFieldShopID"] != null && dt.Rows[i]["CustomFieldShopID"].ToString() != "")
                    {
                        model.CustomFieldShopID = int.Parse(dt.Rows[i]["CustomFieldShopID"].ToString());
                    }
                    if (dt.Rows[i]["CustomFieldCreateTime"] != null && dt.Rows[i]["CustomFieldCreateTime"].ToString() != "")
                    {
                        model.CustomFieldCreateTime = DateTime.Parse(dt.Rows[i]["CustomFieldCreateTime"].ToString());
                    }
                    if (dt.Rows[i]["CustomFieldUserID"] != null && dt.Rows[i]["CustomFieldUserID"].ToString() != "")
                    {
                        model.CustomFieldUserID = int.Parse(dt.Rows[i]["CustomFieldUserID"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }