Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(CPickOutBillBoxData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into CPickOutBillBox(");
            strSql.Append(@"boxNo,materialNo,num,palletNo,wareNo,wareLocatorNo,isrtEmpId,isrtDt,updtEmpId,updtDt)");
            strSql.Append(" values (");
            strSql.Append(@"@boxNo,@materialNo,@num,@palletNo,@wareNo,@wareLocatorNo,@isrtEmpId,@isrtDt,@updtEmpId,@updtDt)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@boxNo", SqlDbType.VarChar,20),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@num", SqlDbType.Float),
                    new SqlParameter("@palletNo", SqlDbType.VarChar,20),
                    new SqlParameter("@wareNo", SqlDbType.VarChar,20),
                    new SqlParameter("@wareLocatorNo", SqlDbType.VarChar,20),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.boxNo;
            parameters[1].Value = model.materialNo;
            parameters[2].Value = model.num;
            parameters[3].Value = model.palletNo;
            parameters[4].Value = model.wareNo;
            parameters[5].Value = model.wareLocatorNo;
            parameters[6].Value = model.isrtEmpId;
            parameters[7].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[8].Value = model.updtEmpId;
            parameters[9].Value = model.updtDt == string.Empty ? null : model.updtDt;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
Пример #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(CPickOutBillBoxData model)
 {
     return this.pickOutBillBoxDB.ModifyRecord(model);
 }
Пример #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(CPickOutBillBoxData model)
 {
     return this.pickOutBillBoxDB.AddRecord(model);
 }
Пример #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(CPickOutBillBoxData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update CPickOutBillBox set ");
            strSql.Append("boxNo=@boxNo,");
            strSql.Append("materialNo=@materialNo,");
            strSql.Append("num=@num,");
            strSql.Append("palletNo=@palletNo,");
            strSql.Append("wareNo=@wareNo,");
            strSql.Append("wareLocatorNo=@wareLocatorNo,");
            strSql.Append("isrtEmpId=@isrtEmpId,");
            strSql.Append("isrtDt=@isrtDt,");
            strSql.Append("updtEmpId=@updtEmpId,");
            strSql.Append("updtDt=@updtDt");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@boxNo", SqlDbType.VarChar,20),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@num", SqlDbType.Float),
                    new SqlParameter("@palletNo", SqlDbType.VarChar,20),
                    new SqlParameter("@wareNo", SqlDbType.VarChar,20),
                    new SqlParameter("@wareLocatorNo", SqlDbType.VarChar,20),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.boxNo;
            parameters[2].Value = model.materialNo;
            parameters[3].Value = model.num;
            parameters[4].Value = model.palletNo;
            parameters[5].Value = model.wareNo;
            parameters[6].Value = model.wareLocatorNo;
            parameters[7].Value = model.isrtEmpId;
            parameters[8].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[9].Value = model.updtEmpId;
            parameters[10].Value = model.updtDt == string.Empty ? null : model.updtDt;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
Пример #5
0
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public CPickOutBillBoxData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,boxNo,materialNo,num,palletNo,wareNo,wareLocatorNo,isrtEmpId,isrtDt,updtEmpId,updtDt from CPickOutBillBox");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            CPickOutBillBoxData model = new CPickOutBillBoxData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }
                if (row["boxNo"] != DBNull.Value)
                {
                    model.boxNo = Convert.ToString(row["boxNo"]);
                }
                if (row["materialNo"] != DBNull.Value)
                {
                    model.materialNo = Convert.ToString(row["materialNo"]);
                }
                if (row["num"] != DBNull.Value)
                {
                    model.num = Convert.ToDouble(row["num"]);
                }
                if (row["palletNo"] != DBNull.Value)
                {
                    model.palletNo = Convert.ToString(row["palletNo"]);
                }
                if (row["wareNo"] != DBNull.Value)
                {
                    model.wareNo = Convert.ToString(row["wareNo"]);
                }
                if (row["wareLocatorNo"] != DBNull.Value)
                {
                    model.wareLocatorNo = Convert.ToString(row["wareLocatorNo"]);
                }
                if (row["isrtEmpId"] != DBNull.Value)
                {
                    model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]);
                }
                if (row["isrtDt"] != DBNull.Value)
                {
                    model.isrtDt = Convert.ToString(row["isrtDt"]);
                }
                if (row["updtEmpId"] != DBNull.Value)
                {
                    model.updtEmpId = Convert.ToInt32(row["updtEmpId"]);
                }
                if (row["updtDt"] != DBNull.Value)
                {
                    model.updtDt = Convert.ToString(row["updtDt"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }