Пример #1
0
        public List <MODEL_V_Common_Dict> DataTableToList(DataTable dt)
        {
            List <MODEL_V_Common_Dict> list = new List <MODEL_V_Common_Dict>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    MODEL_V_Common_Dict item = new MODEL_V_Common_Dict();
                    if ((dt.Rows[i]["Common_Dict_ID"] != null) && (dt.Rows[i]["Common_Dict_ID"].ToString() != ""))
                    {
                        item.Common_Dict_ID = dt.Rows[i]["Common_Dict_ID"].ToString();
                    }
                    if ((dt.Rows[i]["D_Name"] != null) && (dt.Rows[i]["D_Name"].ToString() != ""))
                    {
                        item.D_Name = dt.Rows[i]["D_Name"].ToString();
                    }
                    if ((dt.Rows[i]["D_Value"] != null) && (dt.Rows[i]["D_Value"].ToString() != ""))
                    {
                        item.D_Value = new int?(int.Parse(dt.Rows[i]["D_Value"].ToString()));
                    }
                    if ((dt.Rows[i]["D_Code"] != null) && (dt.Rows[i]["D_Code"].ToString() != ""))
                    {
                        item.D_Code = dt.Rows[i]["D_Code"].ToString();
                    }
                    if ((dt.Rows[i]["D_Level"] != null) && (dt.Rows[i]["D_Level"].ToString() != ""))
                    {
                        item.D_Level = new int?(int.Parse(dt.Rows[i]["D_Level"].ToString()));
                    }
                    if ((dt.Rows[i]["D_Order"] != null) && (dt.Rows[i]["D_Order"].ToString() != ""))
                    {
                        item.D_Order = new int?(int.Parse(dt.Rows[i]["D_Order"].ToString()));
                    }
                    if ((dt.Rows[i]["D_Type"] != null) && (dt.Rows[i]["D_Type"].ToString() != ""))
                    {
                        item.D_Type = dt.Rows[i]["D_Type"].ToString();
                    }
                    if ((dt.Rows[i]["D_Remark"] != null) && (dt.Rows[i]["D_Remark"].ToString() != ""))
                    {
                        item.D_Remark = dt.Rows[i]["D_Remark"].ToString();
                    }
                    if ((dt.Rows[i]["D_CreateUser"] != null) && (dt.Rows[i]["D_CreateUser"].ToString() != ""))
                    {
                        item.D_CreateUser = dt.Rows[i]["D_CreateUser"].ToString();
                    }
                    if ((dt.Rows[i]["D_CreateTime"] != null) && (dt.Rows[i]["D_CreateTime"].ToString() != ""))
                    {
                        item.D_CreateTime = new DateTime?(DateTime.Parse(dt.Rows[i]["D_CreateTime"].ToString()));
                    }
                    if ((dt.Rows[i]["D_ModifyUser"] != null) && (dt.Rows[i]["D_ModifyUser"].ToString() != ""))
                    {
                        item.D_ModifyUser = dt.Rows[i]["D_ModifyUser"].ToString();
                    }
                    if ((dt.Rows[i]["D_ModifyTime"] != null) && (dt.Rows[i]["D_ModifyTime"].ToString() != ""))
                    {
                        item.D_ModifyTime = new DateTime?(DateTime.Parse(dt.Rows[i]["D_ModifyTime"].ToString()));
                    }
                    list.Add(item);
                }
            }
            return(list);
        }
Пример #2
0
        public MODEL_V_Common_Dict GetModel(string Common_Dict_ID)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("select  top 1 Common_Dict_ID,D_Name,D_Value,D_Code,D_Level,D_Order,D_Type,D_Remark,D_CreateUser,D_CreateTime,D_ModifyUser,D_ModifyTime from V_Common_Dict ");
            builder.Append(" where Common_Dict_ID=@Common_Dict_ID ");
            SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@Common_Dict_ID", SqlDbType.Char, 0x24) };
            cmdParms[0].Value = Common_Dict_ID;
            MODEL_V_Common_Dict dict = new MODEL_V_Common_Dict();
            DataSet             set  = DbHelperSQL.Query(builder.ToString(), cmdParms);

            if (set.Tables[0].Rows.Count <= 0)
            {
                return(null);
            }
            if ((set.Tables[0].Rows[0]["Common_Dict_ID"] != null) && (set.Tables[0].Rows[0]["Common_Dict_ID"].ToString() != ""))
            {
                dict.Common_Dict_ID = set.Tables[0].Rows[0]["Common_Dict_ID"].ToString();
            }
            if ((set.Tables[0].Rows[0]["D_Name"] != null) && (set.Tables[0].Rows[0]["D_Name"].ToString() != ""))
            {
                dict.D_Name = set.Tables[0].Rows[0]["D_Name"].ToString();
            }
            if ((set.Tables[0].Rows[0]["D_Value"] != null) && (set.Tables[0].Rows[0]["D_Value"].ToString() != ""))
            {
                dict.D_Value = new int?(int.Parse(set.Tables[0].Rows[0]["D_Value"].ToString()));
            }
            if ((set.Tables[0].Rows[0]["D_Code"] != null) && (set.Tables[0].Rows[0]["D_Code"].ToString() != ""))
            {
                dict.D_Code = set.Tables[0].Rows[0]["D_Code"].ToString();
            }
            if ((set.Tables[0].Rows[0]["D_Level"] != null) && (set.Tables[0].Rows[0]["D_Level"].ToString() != ""))
            {
                dict.D_Level = new int?(int.Parse(set.Tables[0].Rows[0]["D_Level"].ToString()));
            }
            if ((set.Tables[0].Rows[0]["D_Order"] != null) && (set.Tables[0].Rows[0]["D_Order"].ToString() != ""))
            {
                dict.D_Order = new int?(int.Parse(set.Tables[0].Rows[0]["D_Order"].ToString()));
            }
            if ((set.Tables[0].Rows[0]["D_Type"] != null) && (set.Tables[0].Rows[0]["D_Type"].ToString() != ""))
            {
                dict.D_Type = set.Tables[0].Rows[0]["D_Type"].ToString();
            }
            if ((set.Tables[0].Rows[0]["D_Remark"] != null) && (set.Tables[0].Rows[0]["D_Remark"].ToString() != ""))
            {
                dict.D_Remark = set.Tables[0].Rows[0]["D_Remark"].ToString();
            }
            if ((set.Tables[0].Rows[0]["D_CreateUser"] != null) && (set.Tables[0].Rows[0]["D_CreateUser"].ToString() != ""))
            {
                dict.D_CreateUser = set.Tables[0].Rows[0]["D_CreateUser"].ToString();
            }
            if ((set.Tables[0].Rows[0]["D_CreateTime"] != null) && (set.Tables[0].Rows[0]["D_CreateTime"].ToString() != ""))
            {
                dict.D_CreateTime = new DateTime?(DateTime.Parse(set.Tables[0].Rows[0]["D_CreateTime"].ToString()));
            }
            if ((set.Tables[0].Rows[0]["D_ModifyUser"] != null) && (set.Tables[0].Rows[0]["D_ModifyUser"].ToString() != ""))
            {
                dict.D_ModifyUser = set.Tables[0].Rows[0]["D_ModifyUser"].ToString();
            }
            if ((set.Tables[0].Rows[0]["D_ModifyTime"] != null) && (set.Tables[0].Rows[0]["D_ModifyTime"].ToString() != ""))
            {
                dict.D_ModifyTime = new DateTime?(DateTime.Parse(set.Tables[0].Rows[0]["D_ModifyTime"].ToString()));
            }
            return(dict);
        }