Пример #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.BPM_Product GetModel(string ProductID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ProductID,Alias,Name,Spec,ConnectorQty,PtID,Pic from BPM_Product ");
            strSql.Append(" where ProductID=@ProductID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductID", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = ProductID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                model = DataRowToModel(ds.Tables[0].Rows[0]);
                //赋值工序列表
                BPM_ProductTemplate pt = new BPM_ProductTemplate();

                model.ProcessList = pt.GetModelList(model.PtID);
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Model.BPM_Product model)
        {
            var _model = GetModel(model.ProductID);

            if (_model != null)
            {
                if (ZhuifengLib.MyMessage.IsOkMessage("您所添加的品号已存在与数据库,对应的模板为:" + _model.PtID + "\r\n继续将更新现有数据!"))
                {
                    return(dal.Update(model));
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(dal.Add(model));
            }
        }
Пример #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.BPM_Product model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BPM_Product set ");
            strSql.Append("Alias=@Alias,");
            strSql.Append("Name=@Name,");
            strSql.Append("Spec=@Spec,");
            strSql.Append("ConnectorQty=@ConnectorQty,");
            strSql.Append("PtID=@PtID,");
            strSql.Append("Pic=@Pic");
            strSql.Append(" where ProductID=@ProductID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Alias",        SqlDbType.VarChar,  50),
                new SqlParameter("@Name",         SqlDbType.VarChar, 150),
                new SqlParameter("@Spec",         SqlDbType.VarChar, 200),
                new SqlParameter("@ConnectorQty", SqlDbType.Int,       4),
                new SqlParameter("@PtID",         SqlDbType.VarChar, 150),
                new SqlParameter("@Pic",          SqlDbType.VarChar, 250),
                new SqlParameter("@ProductID",    SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.Alias;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Spec;
            parameters[3].Value = model.ConnectorQty;
            parameters[4].Value = model.PtID;
            parameters[5].Value = model.Pic;
            parameters[6].Value = model.ProductID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Model.BPM_Product model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into BPM_Product(");
            strSql.Append("ProductID,Alias,Name,Spec,ConnectorQty,PtID,Pic)");
            strSql.Append(" values (");
            strSql.Append("@ProductID,@Alias,@Name,@Spec,@ConnectorQty,@PtID,@Pic)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductID",    SqlDbType.VarChar,  50),
                new SqlParameter("@Alias",        SqlDbType.VarChar,  50),
                new SqlParameter("@Name",         SqlDbType.VarChar, 150),
                new SqlParameter("@Spec",         SqlDbType.VarChar, 200),
                new SqlParameter("@ConnectorQty", SqlDbType.Int,       4),
                new SqlParameter("@PtID",         SqlDbType.VarChar, 150),
                new SqlParameter("@Pic",          SqlDbType.VarChar, 250)
            };
            parameters[0].Value = model.ProductID;
            parameters[1].Value = model.Alias;
            parameters[2].Value = model.Name;
            parameters[3].Value = model.Spec;
            parameters[4].Value = model.ConnectorQty;
            parameters[5].Value = model.PtID;
            parameters[6].Value = model.Pic;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.BPM_Product DataRowToModel(DataRow row)
 {
     Model.BPM_Product model = new Model.BPM_Product();
     if (row != null)
     {
         if (row["ProductID"] != null)
         {
             model.ProductID = row["ProductID"].ToString();
         }
         if (row["Alias"] != null)
         {
             model.Alias = row["Alias"].ToString();
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Spec"] != null)
         {
             model.Spec = row["Spec"].ToString();
         }
         if (row["ConnectorQty"] != null && row["ConnectorQty"].ToString() != "")
         {
             model.ConnectorQty = int.Parse(row["ConnectorQty"].ToString());
         }
         if (row["PtID"] != null)
         {
             model.PtID = row["PtID"].ToString();
         }
         if (row["Pic"] != null)
         {
             model.Pic = row["Pic"].ToString();
         }
     }
     return(model);
 }
Пример #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.BPM_Product model)
 {
     return(dal.Update(model));
 }