예제 #1
0
        public IList <bill_pingzheng_xmModel> ListMaker(string tempsql, SqlParameter[] sps)
        {
            DataTable dt = DataHelper.GetDataTable(tempsql, sps, false);
            IList <bill_pingzheng_xmModel> list = new List <bill_pingzheng_xmModel>();

            foreach (DataRow dr in dt.Rows)
            {
                bill_pingzheng_xmModel model = new bill_pingzheng_xmModel();
                if (!DBNull.Value.Equals(dr["list_id"]))
                {
                    model.list_id = int.Parse(dr["list_id"].ToString());
                }
                model.Note3      = dr["Note3"].ToString();
                model.Note4      = dr["Note4"].ToString();
                model.Note5      = dr["Note5"].ToString();
                model.Note6      = dr["Note6"].ToString();
                model.Note7      = dr["Note7"].ToString();
                model.Note8      = dr["Note8"].ToString();
                model.Note9      = dr["Note9"].ToString();
                model.xmCode     = dr["xmCode"].ToString();
                model.xmName     = dr["xmName"].ToString();
                model.parentCode = dr["parentCode"].ToString();
                model.parentName = dr["parentName"].ToString();
                model.isDefault  = dr["isDefault"].ToString();
                model.Status     = dr["Status"].ToString();
                model.Note1      = dr["Note1"].ToString();
                model.Note2      = dr["Note2"].ToString();

                list.Add(model);
            }
            return(list);
        }
예제 #2
0
 public int Add(bill_pingzheng_xmModel modelPingZhengXmModel, out string strMsg)
 {
     try
     {
         strMsg = "";
         return(dal.Add(modelPingZhengXmModel));
     }
     catch (Exception ex)
     {
         strMsg = ex.Message;
         return(-1);
     }
 }
예제 #3
0
        public bill_pingzheng_xmModel GetChildByName(string strName)
        {
            string        s      = "select top 1 Note3,Note4,Note5,Note6,Note7,Note8,Note9,xmCode,xmName,parentCode,parentName,isDefault,(case isDefault when '0' then '否' when '1' then '是' end) as isDefaultShow,Status,Note1,Note2,list_id,Row_Number()over(order by list_id) as crow from bill_pingzheng_xm";
            StringBuilder strSql = new StringBuilder();

            strSql.Append(s);
            strSql.Append(" where parentName=@parentName order by isDefault desc");
            SqlParameter[] parameters =
            {
                new SqlParameter("@parentName", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = strName;


            bill_pingzheng_xmModel model = new bill_pingzheng_xmModel();

            using (SqlDataReader dr = DataHelper.GetDataReader(strSql.ToString(), parameters))
            {
                if (dr.Read())
                {
                    if (!DBNull.Value.Equals(dr["list_id"]))
                    {
                        model.list_id = int.Parse(dr["list_id"].ToString());
                    }
                    model.Note3      = dr["Note3"].ToString();
                    model.Note4      = dr["Note4"].ToString();
                    model.Note5      = dr["Note5"].ToString();
                    model.Note6      = dr["Note6"].ToString();
                    model.Note7      = dr["Note7"].ToString();
                    model.Note8      = dr["Note8"].ToString();
                    model.Note9      = dr["Note9"].ToString();
                    model.xmCode     = dr["xmCode"].ToString();
                    model.xmName     = dr["xmName"].ToString();
                    model.parentCode = dr["parentCode"].ToString();
                    model.parentName = dr["parentName"].ToString();
                    model.isDefault  = dr["isDefault"].ToString();
                    model.Status     = dr["Status"].ToString();
                    model.Note1      = dr["Note1"].ToString();
                    model.Note2      = dr["Note2"].ToString();

                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public bill_pingzheng_xmModel GetModel(int list_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(sql);
            strSql.Append(" where list_id=@list_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@list_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = list_id;


            bill_pingzheng_xmModel model = new bill_pingzheng_xmModel();

            using (SqlDataReader dr = DataHelper.GetDataReader(strSql.ToString(), parameters))
            {
                if (dr.Read())
                {
                    if (!DBNull.Value.Equals(dr["list_id"]))
                    {
                        model.list_id = int.Parse(dr["list_id"].ToString());
                    }
                    model.Note3      = dr["Note3"].ToString();
                    model.Note4      = dr["Note4"].ToString();
                    model.Note5      = dr["Note5"].ToString();
                    model.Note6      = dr["Note6"].ToString();
                    model.Note7      = dr["Note7"].ToString();
                    model.Note8      = dr["Note8"].ToString();
                    model.Note9      = dr["Note9"].ToString();
                    model.xmCode     = dr["xmCode"].ToString();
                    model.xmName     = dr["xmName"].ToString();
                    model.parentCode = dr["parentCode"].ToString();
                    model.parentName = dr["parentName"].ToString();
                    model.isDefault  = dr["isDefault"].ToString();
                    model.Status     = dr["Status"].ToString();
                    model.Note1      = dr["Note1"].ToString();
                    model.Note2      = dr["Note2"].ToString();

                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
예제 #5
0
 public int Add(bill_pingzheng_xmModel model)
 {
     using (SqlConnection conn = new SqlConnection(DataHelper.constr))
     {
         conn.Open();
         SqlTransaction tran = conn.BeginTransaction();
         int            iRel = 0;
         try
         {
             Delete(model.list_id, tran);
             iRel = Add(model, tran);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             iRel = -1;;
         }
         return(iRel);
     }
 }
예제 #6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(bill_pingzheng_xmModel model, SqlTransaction tran)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into bill_pingzheng_xm(");
            strSql.Append("Note3,Note4,Note5,Note6,Note7,Note8,Note9,xmCode,xmName,parentCode,parentName,isDefault,Status,Note1,Note2");
            strSql.Append(") values (");
            strSql.Append("@Note3,@Note4,@Note5,@Note6,@Note7,@Note8,@Note9,@xmCode,@xmName,@parentCode,@parentName,@isDefault,@Status,@Note1,@Note2");
            strSql.Append(") ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Note3",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Note4",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Note5",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Note6",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Note7",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Note8",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Note9",      SqlDbType.NVarChar,  50),
                new SqlParameter("@xmCode",     SqlDbType.NVarChar,  50),
                new SqlParameter("@xmName",     SqlDbType.NVarChar, 100),
                new SqlParameter("@parentCode", SqlDbType.NVarChar,  50),
                new SqlParameter("@parentName", SqlDbType.NVarChar, 100),
                new SqlParameter("@isDefault",  SqlDbType.Char,       1),
                new SqlParameter("@Status",     SqlDbType.Char,       1),
                new SqlParameter("@Note1",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Note2",      SqlDbType.NVarChar, 50)
            };

            parameters[0].Value = SqlNull(model.Note3);

            parameters[1].Value = SqlNull(model.Note4);

            parameters[2].Value = SqlNull(model.Note5);

            parameters[3].Value = SqlNull(model.Note6);

            parameters[4].Value = SqlNull(model.Note7);

            parameters[5].Value = SqlNull(model.Note8);

            parameters[6].Value = SqlNull(model.Note9);

            parameters[7].Value = SqlNull(model.xmCode);

            parameters[8].Value = SqlNull(model.xmName);

            parameters[9].Value = SqlNull(model.parentCode);

            parameters[10].Value = SqlNull(model.parentName);

            parameters[11].Value = SqlNull(model.isDefault);

            parameters[12].Value = SqlNull(model.Status);

            parameters[13].Value = SqlNull(model.Note1);

            parameters[14].Value = SqlNull(model.Note2);


            return(DataHelper.ExcuteNonQuery(strSql.ToString(), tran, parameters, false));
        }