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

            foreach (DataRow dr in dt.Rows)
            {
                bill_lyds model = new bill_lyds();
                model.guid   = dr["guid"].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.myGuid = dr["myGuid"].ToString();
                model.fykm   = dr["fykm"].ToString();
                if (!DBNull.Value.Equals(dr["je"]))
                {
                    model.je = decimal.Parse(dr["je"].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();

                list.Add(model);
            }
            return(list);
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(bill_lyds model, SqlTransaction tran)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into bill_lyds(");
            strSql.Append("guid,note6,note7,note8,note9,note0,myGuid,fykm,je,note1,note2,note3,note4,note5");
            strSql.Append(") values (");
            strSql.Append("@guid,@note6,@note7,@note8,@note9,@note0,@myGuid,@fykm,@je,@note1,@note2,@note3,@note4,@note5");
            strSql.Append(") ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@guid",   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("@myGuid", SqlDbType.VarChar, 50),
                new SqlParameter("@fykm",   SqlDbType.VarChar, 50),
                new SqlParameter("@je",     SqlDbType.Decimal,  9),
                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)
            };

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

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

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

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

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

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

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

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

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

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

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

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

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

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


            return(DataHelper.ExcuteNonQuery(strSql.ToString(), tran, parameters, false));
        }
Esempio n. 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public bill_lyds 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_lyds model = new bill_lyds();

            using (SqlDataReader dr = DataHelper.GetDataReader(strSql.ToString(), parameters))
            {
                if (dr.Read())
                {
                    model.guid   = dr["guid"].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.myGuid = dr["myGuid"].ToString();
                    model.fykm   = dr["fykm"].ToString();
                    if (!DBNull.Value.Equals(dr["je"]))
                    {
                        model.je = decimal.Parse(dr["je"].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();

                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
Esempio n. 4
0
 public int Add(bill_lyds 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;
         }
     }
 }