Ejemplo n.º 1
0
        public IList <bill_lyd> ListMaker(string tempsql, SqlParameter[] sps)
        {
            DataTable        dt   = DataHelper.GetDataTable(tempsql, sps, false);
            IList <bill_lyd> list = new List <bill_lyd>();

            foreach (DataRow dr in dt.Rows)
            {
                bill_lyd model = new bill_lyd();
                model.guid   = dr["guid"].ToString();
                model.note1  = dr["note1"].ToString();
                model.note2  = dr["note2"].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.note0  = dr["note0"].ToString();
                model.lyDate = dr["lyDate"].ToString();
                model.lyr    = dr["lyr"].ToString();
                model.zdr    = dr["zdr"].ToString();
                model.lyDept = dr["lyDept"].ToString();
                if (!DBNull.Value.Equals(dr["je"]))
                {
                    model.je = decimal.Parse(dr["je"].ToString());
                }
                model.sm = dr["sm"].ToString();
                model.bz = dr["bz"].ToString();
                model.zt = dr["zt"].ToString();

                list.Add(model);
            }
            return(list);
        }
Ejemplo n.º 2
0
 public bool Add(bill_lyd main, IList <bill_lyds> list)
 {
     using (SqlConnection conn = new SqlConnection(DataHelper.constr))
     {
         conn.Open();
         SqlTransaction tran = conn.BeginTransaction();
         try
         {
             dalMain.Delete(main.guid, tran);
             dalItem.Delete(main.guid, tran);
             dalMain.Add(main, tran);
             for (int i = 0; i < list.Count; i++)
             {
                 dalItem.Add(list[i], tran);
             }
             tran.Commit();
             return(true);
         }
         catch
         {
             tran.Rollback();
             throw;
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public bill_lyd GetModel(string guid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(sql);
            strSql.Append(" where guid=@guid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@guid", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = guid;


            bill_lyd model = new bill_lyd();

            using (SqlDataReader dr = DataHelper.GetDataReader(strSql.ToString(), parameters))
            {
                if (dr.Read())
                {
                    model.guid   = dr["guid"].ToString();
                    model.note1  = dr["note1"].ToString();
                    model.note2  = dr["note2"].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.note0  = dr["note0"].ToString();
                    model.lyDate = dr["lyDate"].ToString();
                    model.lyr    = dr["lyr"].ToString();
                    model.zdr    = dr["zdr"].ToString();
                    model.lyDept = dr["lyDept"].ToString();
                    if (!DBNull.Value.Equals(dr["je"]))
                    {
                        model.je = decimal.Parse(dr["je"].ToString());
                    }
                    model.sm = dr["sm"].ToString();
                    model.bz = dr["bz"].ToString();
                    model.zt = dr["zt"].ToString();

                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 4
0
 public int Add(bill_lyd model)
 {
     using (SqlConnection conn = new SqlConnection(DataHelper.constr))
     {
         conn.Open();
         SqlTransaction tran = conn.BeginTransaction();
         try
         {
             Delete(model.guid, tran);
             int iRel = Add(model, tran);
             tran.Commit();
             return(iRel);
         }
         catch
         {
             tran.Rollback();
             throw;
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(bill_lyd model, SqlTransaction tran)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into bill_lyd(");
            strSql.Append("guid,note1,note2,note3,note4,note5,note6,note7,note8,note9,note0,lyDate,lyr,zdr,lyDept,je,sm,bz,zt");
            strSql.Append(") values (");
            strSql.Append("@guid,@note1,@note2,@note3,@note4,@note5,@note6,@note7,@note8,@note9,@note0,@lyDate,@lyr,@zdr,@lyDept,@je,@sm,@bz,@zt");
            strSql.Append(") ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@guid",   SqlDbType.VarChar,   50),
                new SqlParameter("@note1",  SqlDbType.VarChar,   50),
                new SqlParameter("@note2",  SqlDbType.VarChar,   50),
                new SqlParameter("@note3",  SqlDbType.VarChar,   50),
                new SqlParameter("@note4",  SqlDbType.VarChar,   50),
                new SqlParameter("@note5",  SqlDbType.VarChar,   50),
                new SqlParameter("@note6",  SqlDbType.VarChar,   50),
                new SqlParameter("@note7",  SqlDbType.VarChar,   50),
                new SqlParameter("@note8",  SqlDbType.VarChar,   50),
                new SqlParameter("@note9",  SqlDbType.VarChar,   50),
                new SqlParameter("@note0",  SqlDbType.VarChar,   50),
                new SqlParameter("@lyDate", SqlDbType.VarChar,   30),
                new SqlParameter("@lyr",    SqlDbType.VarChar,   50),
                new SqlParameter("@zdr",    SqlDbType.VarChar,   50),
                new SqlParameter("@lyDept", SqlDbType.VarChar,   50),
                new SqlParameter("@je",     SqlDbType.Decimal,    9),
                new SqlParameter("@sm",     SqlDbType.VarChar, 1000),
                new SqlParameter("@bz",     SqlDbType.VarChar, 1000),
                new SqlParameter("@zt",     SqlDbType.VarChar, 10)
            };

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            parameters[15].Value = SqlNull(model.je);

            parameters[16].Value = SqlNull(model.sm);

            parameters[17].Value = SqlNull(model.bz);

            parameters[18].Value = SqlNull(model.zt);


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