/// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(BArriveDetail_HangHaoData model)
 {
     return this.arriveDetail_HangHaoDB.ModifyRecord(model);
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(BArriveDetail_HangHaoData model)
 {
     return this.arriveDetail_HangHaoDB.AddRecord(model);
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(BArriveDetail_HangHaoData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update BArriveDetail_HangHao set ");
            strSql.Append("arriveBillNo=@arriveBillNo,");
            strSql.Append("financeBillNo=@financeBillNo,");
            strSql.Append("baseLine=@baseLine,");
            strSql.Append("financeBillSort=@financeBillSort,");
            strSql.Append("materialNo=@materialNo,");
            strSql.Append("num=@num,");
            strSql.Append("partialBox=@partialBox,");
            strSql.Append("uintQty=@uintQty,");
            strSql.Append("boxqty=@boxqty,");
            strSql.Append("boxNum=@boxNum,");
            strSql.Append("saleBillNo=@saleBillNo,");
            strSql.Append("customNo=@customNo,");
            strSql.Append("firstBoxSingleWeight=@firstBoxSingleWeight,");
            strSql.Append("isFinishReceive=@isFinishReceive,");
            strSql.Append("sapInStockNum=@sapInStockNum,");
            strSql.Append("BaseEntry=@BaseEntry,");
            strSql.Append("isSapInStock=@isSapInStock");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@arriveBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@baseLine", SqlDbType.Int),
                    new SqlParameter("@financeBillSort", SqlDbType.NVarChar,20),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@num", SqlDbType.Float),
                    new SqlParameter("@partialBox", SqlDbType.Char,1),
                    new SqlParameter("@uintQty", SqlDbType.Float),
                    new SqlParameter("@boxqty", SqlDbType.Float),
                    new SqlParameter("@boxNum", SqlDbType.Float),
                    new SqlParameter("@saleBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@customNo", SqlDbType.VarChar,20),
                    new SqlParameter("@firstBoxSingleWeight", SqlDbType.Float),
                    new SqlParameter("@isFinishReceive", SqlDbType.Bit),
                    new SqlParameter("@sapInStockNum", SqlDbType.Float),
                    new SqlParameter("@BaseEntry", SqlDbType.Int),
                    new SqlParameter("@isSapInStock", SqlDbType.Bit)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.arriveBillNo;
            parameters[2].Value = model.financeBillNo;
            parameters[3].Value = model.baseLine;
            parameters[4].Value = model.financeBillSort;
            parameters[5].Value = model.materialNo;
            parameters[6].Value = model.num;
            parameters[7].Value = model.partialBox;
            parameters[8].Value = model.uintQty;
            parameters[9].Value = model.boxqty;
            parameters[10].Value = model.boxNum;
            parameters[11].Value = model.saleBillNo;
            parameters[12].Value = model.customNo;
            parameters[13].Value = model.firstBoxSingleWeight;
            parameters[14].Value = model.isFinishReceive;
            parameters[15].Value = model.sapInStockNum;
            parameters[16].Value = model.BaseEntry;
            parameters[17].Value = model.isSapInStock;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(BArriveDetail_HangHaoData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into BArriveDetail_HangHao(");
            strSql.Append(@"arriveBillNo,financeBillNo,baseLine,financeBillSort,materialNo,num,partialBox,uintQty,boxqty,boxNum,
                            saleBillNo,customNo,firstBoxSingleWeight,isFinishReceive,sapInStockNum,BaseEntry,isSapInStock)");
            strSql.Append(" values (");
            strSql.Append(@"@arriveBillNo,@financeBillNo,@baseLine,@financeBillSort,@materialNo,@num,@partialBox,@uintQty,@boxqty,@boxNum,
                            @saleBillNo,@customNo,@firstBoxSingleWeight,@isFinishReceive,@sapInStockNum,@BaseEntry,@isSapInStock)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@arriveBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@baseLine", SqlDbType.Int),
                    new SqlParameter("@financeBillSort", SqlDbType.NVarChar,20),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@num", SqlDbType.Float),
                    new SqlParameter("@partialBox", SqlDbType.Char,1),
                    new SqlParameter("@uintQty", SqlDbType.Float),
                    new SqlParameter("@boxqty", SqlDbType.Float),
                    new SqlParameter("@boxNum", SqlDbType.Float),
                    new SqlParameter("@saleBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@customNo", SqlDbType.VarChar,20),
                    new SqlParameter("@firstBoxSingleWeight", SqlDbType.Float),
                    new SqlParameter("@isFinishReceive", SqlDbType.Bit),
                    new SqlParameter("@sapInStockNum", SqlDbType.Float),
                    new SqlParameter("@BaseEntry", SqlDbType.Int),
                    new SqlParameter("@isSapInStock", SqlDbType.Bit)
                };
            parameters[0].Value = model.arriveBillNo;
            parameters[1].Value = model.financeBillNo;
            parameters[2].Value = model.baseLine;
            parameters[3].Value = model.financeBillSort;
            parameters[4].Value = model.materialNo;
            parameters[5].Value = model.num;
            parameters[6].Value = model.partialBox;
            parameters[7].Value = model.uintQty;
            parameters[8].Value = model.boxqty;
            parameters[9].Value = model.boxNum;
            parameters[10].Value = model.saleBillNo;
            parameters[11].Value = model.customNo;
            parameters[12].Value = model.firstBoxSingleWeight;
            parameters[13].Value = model.isFinishReceive;
            parameters[14].Value = model.sapInStockNum;
            parameters[15].Value = model.BaseEntry;
            parameters[16].Value = model.isSapInStock;

            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;
        }
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public BArriveDetail_HangHaoData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,arriveBillNo,financeBillNo,baseLine,financeBillSort,materialNo,num,partialBox,uintQty,boxqty,boxNum,
                            saleBillNo,customNo,firstBoxSingleWeight,isFinishReceive,sapInStockNum,BaseEntry,isSapInStock from BArriveDetail_HangHao");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            BArriveDetail_HangHaoData model = new BArriveDetail_HangHaoData();
            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["arriveBillNo"] != DBNull.Value)
                {
                    model.arriveBillNo = Convert.ToString(row["arriveBillNo"]);
                }
                if (row["financeBillNo"] != DBNull.Value)
                {
                    model.financeBillNo = Convert.ToString(row["financeBillNo"]);
                }
                if (row["baseLine"] != DBNull.Value)
                {
                    model.baseLine = Convert.ToInt32(row["baseLine"]);
                }
                if (row["financeBillSort"] != DBNull.Value)
                {
                    model.financeBillSort = Convert.ToString(row["financeBillSort"]);
                }
                if (row["materialNo"] != DBNull.Value)
                {
                    model.materialNo = Convert.ToString(row["materialNo"]);
                }
                if (row["num"] != DBNull.Value)
                {
                    model.num = Convert.ToDouble(row["num"]);
                }
                if (row["partialBox"] != DBNull.Value)
                {
                    model.partialBox = Convert.ToString(row["partialBox"]);
                }
                if (row["uintQty"] != DBNull.Value)
                {
                    model.uintQty = Convert.ToDouble(row["uintQty"]);
                }
                if (row["boxqty"] != DBNull.Value)
                {
                    model.boxqty = Convert.ToDouble(row["boxqty"]);
                }
                if (row["boxNum"] != DBNull.Value)
                {
                    model.boxNum = Convert.ToDouble(row["boxNum"]);
                }
                if (row["saleBillNo"] != DBNull.Value)
                {
                    model.saleBillNo = Convert.ToString(row["saleBillNo"]);
                }
                if (row["customNo"] != DBNull.Value)
                {
                    model.customNo = Convert.ToString(row["customNo"]);
                }
                if (row["firstBoxSingleWeight"] != DBNull.Value)
                {
                    model.firstBoxSingleWeight = Convert.ToDouble(row["firstBoxSingleWeight"]);
                }
                if (row["isFinishReceive"] != DBNull.Value)
                {
                    model.isFinishReceive = Convert.ToBoolean(row["isFinishReceive"]);
                }
                if (row["sapInStockNum"] != DBNull.Value)
                {
                    model.sapInStockNum = Convert.ToDouble(row["sapInStockNum"]);
                }
                if (row["BaseEntry"] != DBNull.Value)
                {
                    model.BaseEntry = Convert.ToInt32(row["BaseEntry"]);
                }
                if (row["isSapInStock"] != DBNull.Value)
                {
                    model.isSapInStock = Convert.ToBoolean(row["isSapInStock"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }