/// <summary>
        /// 得到方法输入参数的列表 (例如:用于Exists  Delete  GetModel 的参数传入)
        /// </summary>
        /// <param name="keys"></param>
        /// <returns></returns>
        public static string GetInParameter(List <ColumnInfo> keys)
        {
            StringPlus strclass = new StringPlus();

            foreach (ColumnInfo key in keys)
            {
                strclass.Append(CodeCommon.DbTypeToCS(key.TypeName) + " " + key.ColumnName + ",");
            }
            strclass.DelLastComma();
            return(strclass.Value);
        }
Beispiel #2
0
        /// <summary>
        /// 得到参数的列表(例如:用于Exists  Delete  GetModel 的参数传入)
        /// </summary>
        /// <param name="keys"></param>
        /// <returns></returns>
        public static string GetParameter(List <CodeKey> keys)
        {
            StringPlus strclass = new StringPlus();

            foreach (CodeKey key in keys)
            {
                strclass.Append(CodeCommon.DbTypeToCS(key.KeyType) + " " + key.KeyName + ",");
            }
            strclass.DelLastComma();
            return(strclass.Value);
        }
        /// <summary>
        /// 得到Where条件语句 - SQL方式 (例如:用于Exists  Delete  GetModel 的where)
        /// </summary>
        public static string GetModelWhereExpression(List <ColumnInfo> keys)
        {
            StringPlus strclass = new StringPlus();

            foreach (ColumnInfo key in keys)
            {
                if (CodeCommon.IsAddMark(key.TypeName))
                {
                    strclass.Append(key.ColumnName + "='\"+ model." + key.ColumnName + "+\"' and ");
                }
                else
                {
                    strclass.Append(key.ColumnName + "=\"+ model." + key.ColumnName + "+\" and ");
                }
            }
            strclass.DelLastChar("and");
            return(strclass.Value);
        }
Beispiel #4
0
        private void BindlistViewCol(string Dbname, string TableName)
        {
            SetListViewMenu("colum");
            //创建列表
            this.listView1.Columns.Clear();
            this.listView1.Items.Clear();
            this.listView1.LargeImageList = imglistView;
            this.listView1.SmallImageList = imglistView;
            this.listView1.View           = View.Details;
            this.listView1.GridLines      = true;
            this.listView1.FullRowSelect  = true;

            listView1.Columns.Add("序号", 60, HorizontalAlignment.Left);
            listView1.Columns.Add("列名", 110, HorizontalAlignment.Left);
            listView1.Columns.Add("数据类型", 80, HorizontalAlignment.Left);
            listView1.Columns.Add("长度", 40, HorizontalAlignment.Left);
            listView1.Columns.Add("小数", 40, HorizontalAlignment.Left);
            listView1.Columns.Add("标识", 40, HorizontalAlignment.Center);
            listView1.Columns.Add("主键", 40, HorizontalAlignment.Center);
            listView1.Columns.Add("允许空", 60, HorizontalAlignment.Center);
            listView1.Columns.Add("默认值", 100, HorizontalAlignment.Left);
            //listView1.Columns.Add("字段说明", 100, HorizontalAlignment.Left);

            var collist = dbObject.GetColumnInfoList(Dbname, TableName);

            if ((collist != null) && (collist.Count > 0))
            {
                foreach (var col in collist)
                {
                    var order      = col.ColOrder;
                    var columnName = col.ColumnName;
                    var columnType = col.TypeName;
                    var Length     = col.Length;
                    switch (columnType)
                    {
                    case "varchar":
                    case "nvarchar":
                    case "char":
                    case "nchar":
                    case "varbinary":
                    {
                        Length = CodeCommon.GetDataTypeLenVal(columnType, Length);
                    }
                    break;

                    default:
                        break;
                    }

                    var Preci       = col.Preci;
                    var Scale       = col.Scale;
                    var defaultVal  = col.DefaultVal;
                    var description = col.ColDescription;
                    var IsIdentity  = (col.IsIdentity) ? "√" : "";
                    var ispk        = (col.IsPK) ? "√" : "";
                    var isnull      = (col.IsNull) ? "√" : "";

                    var item1 = new ListViewItem(order, 0);
                    item1.ImageIndex = 4;
                    item1.SubItems.Add(columnName);
                    item1.SubItems.Add(columnType);
                    item1.SubItems.Add(Length);
                    item1.SubItems.Add(Scale);
                    item1.SubItems.Add(IsIdentity);
                    if ((ispk == "√") && (isnull.Trim() == ""))
                    {
                    }
                    else
                    {
                        ispk = "";
                    }
                    item1.SubItems.Add(ispk);
                    item1.SubItems.Add(isnull);
                    item1.SubItems.Add(defaultVal);

                    listView1.Items.AddRange(new ListViewItem[] { item1 });
                }
            }
        }