Exemple #1
0
 //Delete删除命令创建
 string Create_CMD_Delete(T entity, int Id)
 {
     strCmd_Delete.Clear();
     strCmd_Delete.Append("delete from [" + ClassPropertyHelper.GetClassName <T>(entity));
     strCmd_Delete.Append("]  where ID=" + Id);
     return(strCmd_Delete.ToString());
 }
Exemple #2
0
        //插入命令创建
        string Create_CMD_Insert(T entity)
        {
            strCmd_Insert.Clear();
            strCmd_Insert.Append("insert into [" + ClassPropertyHelper.GetClassName <T>(entity) + "]([");
            var DI = ClassPropertyHelper.GetPropertyNameAndValue <T>(entity);

            for (int i = 0; i < DI.Count; i++)
            {
                if (DI.ElementAt(i).Key == "ID")
                {
                    continue;
                }
                if (i == DI.Count - 1)
                {
                    strCmd_Insert.Append(DI.ElementAt(i).Key + "])");
                    break;
                }
                strCmd_Insert.Append(DI.ElementAt(i).Key + "],[");
            }
            strCmd_Insert.Append(" values(");
            for (int i = 0; i < DI.Count; i++)
            {
                if (DI.ElementAt(i).Key == "ID")
                {
                    continue;
                }
                if (i == DI.Count - 1)
                {
                    strCmd_Insert.Append("@" + DI.ElementAt(i).Key + ")");
                    break;
                }
                strCmd_Insert.Append("@" + DI.ElementAt(i).Key + ",");
            }
            return(strCmd_Insert.ToString());
        }
Exemple #3
0
        /// <summary>
        /// 查询变压器参数
        /// </summary>
        /// <param name="Filed_Name"></param>
        /// <param name="Filed_Value"></param>
        /// <returns></returns>
        public List <T> SelectAll()
        {
            strCmd_Select.Clear();
            T entity = new T();

            strCmd_Select.Append("select * from  [" + ClassPropertyHelper.GetClassName <T>(entity) + " ] ");
            return(PutAllVal(entity, ExecuteDataSet(strCmd_Select.ToString())));
        }
Exemple #4
0
        void CreateTable(T entity, Catalog catalog)
        {
            ADODB.Connection cn = new ADODB.Connection();
            cn.Open(strConnection, null, null, -1);
            catalog.ActiveConnection = cn;
            Table table = new Table();

            var DI  = ClassPropertyHelper.GetPropertyNameAndValue <T>(entity);
            var DIT = ClassPropertyHelper.GetPropertyNameAndType <T>(entity);

            table.Name = ClassPropertyHelper.GetClassName <T>(entity);
            for (int i = 0; i < DI.Count; i++)
            {
                if (DI.ElementAt(i).Key == "ID")
                {
                    ADOX.Column column = new ADOX.Column();
                    column.ParentCatalog = catalog;
                    column.Name          = "ID";
                    column.Type          = DataTypeEnum.adInteger;
                    column.DefinedSize   = 32;
                    column.Properties["AutoIncrement"].Value = true;
                    table.Columns.Append(column, DataTypeEnum.adInteger, 32);
                    table.Keys.Append("PrimaryKey", ADOX.KeyTypeEnum.adKeyPrimary, "ID", "", "");
                }
                else
                {
                    table.Columns.Append(DI.ElementAt(i).Key, ConverType(DIT.ElementAt(i).Value), 64);
                }
            }
            try {
                catalog.Tables.Append(table);
            }
            catch (Exception ex) {
                //MessageBox.Show("OleHelper行号92:" + ex.Message);
            }
            finally {
                cn.Close();
            }
        }
Exemple #5
0
        //Update命令创建
        string Create_CMD_Update(T entity, int Id)
        {
            strCmd_Update.Clear();
            strCmd_Update.Append("update  [" + ClassPropertyHelper.GetClassName <T>(entity) + "]  set  ");

            var DI = ClassPropertyHelper.GetPropertyNameAndValue <T>(entity);

            for (int j = 0; j < DI.Count; j++)
            {
                if (DI.ElementAt(j).Key == "ID")
                {
                    continue;
                }
                if (j == DI.Count - 1)
                {
                    strCmd_Update.Append("[" + DI.ElementAt(j).Key + "]=@" + DI.ElementAt(j).Key + "");
                    break;
                }
                strCmd_Update.Append("[" + DI.ElementAt(j).Key + "]=@" + DI.ElementAt(j).Key + ", ");
            }
            strCmd_Update.Append("   where  [ID]=@ID");
            return(strCmd_Update.ToString());
        }