Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.tsuhan_gt_cpbm model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tsuhan_gt_cpbm set ");
            strSql.Append("成品编码=@成品编码,");
            strSql.Append("录入员=@录入员,");
            strSql.Append("时间=@时间");
            strSql.Append(" where cpId=@cpId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@成品编码", SqlDbType.NVarChar,  30),
                new SqlParameter("@录入员",  SqlDbType.NVarChar,  10),
                new SqlParameter("@时间",   SqlDbType.DateTime),
                new SqlParameter("@cpId", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.成品编码;
            parameters[1].Value = model.录入员;
            parameters[2].Value = model.时间;
            parameters[3].Value = model.cpId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.tsuhan_gt_cpbm model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tsuhan_gt_cpbm(");
            strSql.Append("成品编码,录入员,时间)");
            strSql.Append(" values (");
            strSql.Append("@成品编码,@录入员,@时间)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@成品编码", SqlDbType.NVarChar, 30),
                new SqlParameter("@录入员",  SqlDbType.NVarChar, 10),
                new SqlParameter("@时间",   SqlDbType.DateTime)
            };
            parameters[0].Value = model.成品编码;
            parameters[1].Value = model.录入员;
            parameters[2].Value = model.时间;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.tsuhan_gt_cpbm DataRowToModel(DataRow row)
 {
     Maticsoft.Model.tsuhan_gt_cpbm model=new Maticsoft.Model.tsuhan_gt_cpbm();
     if (row != null)
     {
         if(row["cpId"]!=null && row["cpId"].ToString()!="")
         {
             model.cpId=int.Parse(row["cpId"].ToString());
         }
         if(row["成品编码"]!=null)
         {
             model.成品编码=row["成品编码"].ToString();
         }
         if(row["录入员"]!=null)
         {
             model.录入员=row["录入员"].ToString();
         }
         if(row["时间"]!=null && row["时间"].ToString()!="")
         {
             model.时间=DateTime.Parse(row["时间"].ToString());
         }
     }
     return model;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.tsuhan_gt_cpbm DataRowToModel(DataRow row)
 {
     Maticsoft.Model.tsuhan_gt_cpbm model = new Maticsoft.Model.tsuhan_gt_cpbm();
     if (row != null)
     {
         if (row["cpId"] != null && row["cpId"].ToString() != "")
         {
             model.cpId = int.Parse(row["cpId"].ToString());
         }
         if (row["成品编码"] != null)
         {
             model.成品编码 = row["成品编码"].ToString();
         }
         if (row["录入员"] != null)
         {
             model.录入员 = row["录入员"].ToString();
         }
         if (row["时间"] != null && row["时间"].ToString() != "")
         {
             model.时间 = DateTime.Parse(row["时间"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.tsuhan_gt_cpbm GetModel(int cpId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 cpId,成品编码,录入员,时间 from tsuhan_gt_cpbm ");
            strSql.Append(" where cpId=@cpId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@cpId", SqlDbType.Int, 4)
            };
            parameters[0].Value = cpId;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.tsuhan_gt_cpbm GetModel(int cpId)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 cpId,成品编码,录入员,时间 from tsuhan_gt_cpbm ");
            strSql.Append(" where cpId=@cpId");
            SqlParameter[] parameters = {
                    new SqlParameter("@cpId", SqlDbType.Int,4)
            };
            parameters[0].Value = cpId;

            Maticsoft.Model.tsuhan_gt_cpbm model=new Maticsoft.Model.tsuhan_gt_cpbm();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }