Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(EShop.Model.Account_Goods model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Account_Goods set ");
            strSql.Append("GoodsCode=@GoodsCode,");
            strSql.Append("Dealer=@Dealer,");
            strSql.Append("DealDate=@DealDate,");
            strSql.Append("KRepairStart=@KRepairStart,");
            strSql.Append("KRepairOver=@KRepairOver,");
            strSql.Append("Status=@Status");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GoodsCode",    SqlDbType.VarChar, 50),
                new SqlParameter("@Dealer",       SqlDbType.VarChar, 50),
                new SqlParameter("@DealDate",     SqlDbType.Date,     3),
                new SqlParameter("@KRepairStart", SqlDbType.Date,     3),
                new SqlParameter("@KRepairOver",  SqlDbType.Date,     3),
                new SqlParameter("@Status",       SqlDbType.Int,      4),
                new SqlParameter("@Id",           SqlDbType.Int, 4)
            };
            parameters[0].Value = model.GoodsCode;
            parameters[1].Value = model.Dealer;
            parameters[2].Value = model.DealDate;
            parameters[3].Value = model.KRepairStart;
            parameters[4].Value = model.KRepairOver;
            parameters[5].Value = model.Status;
            parameters[6].Value = model.Id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public EShop.Model.Account_Goods DataRowToModel(DataRow row)
 {
     EShop.Model.Account_Goods model = new EShop.Model.Account_Goods();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["GoodsCode"] != null)
         {
             model.GoodsCode = row["GoodsCode"].ToString();
         }
         if (row["Dealer"] != null)
         {
             model.Dealer = row["Dealer"].ToString();
         }
         if (row["DealDate"] != null && row["DealDate"].ToString() != "")
         {
             model.DealDate = DateTime.Parse(row["DealDate"].ToString());
         }
         if (row["KRepairStart"] != null && row["KRepairStart"].ToString() != "")
         {
             model.KRepairStart = DateTime.Parse(row["KRepairStart"].ToString());
         }
         if (row["KRepairOver"] != null && row["KRepairOver"].ToString() != "")
         {
             model.KRepairOver = DateTime.Parse(row["KRepairOver"].ToString());
         }
         if (row["Status"] != null && row["Status"].ToString() != "")
         {
             model.Status = int.Parse(row["Status"].ToString());
         }
     }
     return(model);
 }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(EShop.Model.Account_Goods model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Account_Goods(");
            strSql.Append("GoodsCode,Dealer,DealDate,KRepairStart,KRepairOver,Status)");
            strSql.Append(" values (");
            strSql.Append("@GoodsCode,@Dealer,@DealDate,@KRepairStart,@KRepairOver,@Status)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GoodsCode",    SqlDbType.VarChar, 50),
                new SqlParameter("@Dealer",       SqlDbType.VarChar, 50),
                new SqlParameter("@DealDate",     SqlDbType.Date,     3),
                new SqlParameter("@KRepairStart", SqlDbType.Date,     3),
                new SqlParameter("@KRepairOver",  SqlDbType.Date,     3),
                new SqlParameter("@Status",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.GoodsCode;
            parameters[1].Value = model.Dealer;
            parameters[2].Value = model.DealDate;
            parameters[3].Value = model.KRepairStart;
            parameters[4].Value = model.KRepairOver;
            parameters[5].Value = model.Status;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public EShop.Model.Account_Goods GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,GoodsCode,Dealer,DealDate,KRepairStart,KRepairOver,Status from Account_Goods ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            EShop.Model.Account_Goods model = new EShop.Model.Account_Goods();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }