/// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(LCheckDetailData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update LCheckDetail set ");
            strSql.Append("checkDetailDesc=@checkDetailDesc,");
            strSql.Append("materialNo=@materialNo,");
            strSql.Append("checkFileId=@checkFileId,");
            strSql.Append("checkItemId=@checkItemId,");
            strSql.Append("dateType=@dateType,");
            strSql.Append("unit=@unit,");
            strSql.Append("uplimit=@uplimit,");
            strSql.Append("downlimit=@downlimit,");
            strSql.Append("standDesc=@standDesc,");
            strSql.Append("isMustCheck=@isMustCheck,");
            strSql.Append("isAddupCheck=@isAddupCheck,");
            strSql.Append("checkAmount=@checkAmount,");
            strSql.Append("arrivedAmount=@arrivedAmount,");
            strSql.Append("openBoxScale=@openBoxScale,");
            strSql.Append("checkOutScale=@checkOutScale,");
            strSql.Append("mark=@mark,");
            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("@checkDetailDesc", SqlDbType.NVarChar,50),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@checkFileId", SqlDbType.Int),
                    new SqlParameter("@checkItemId", SqlDbType.Int),
                    new SqlParameter("@dateType", SqlDbType.NVarChar,10),
                    new SqlParameter("@unit", SqlDbType.NVarChar,20),
                    new SqlParameter("@uplimit", SqlDbType.NVarChar,200),
                    new SqlParameter("@downlimit", SqlDbType.NVarChar,200),
                    new SqlParameter("@standDesc", SqlDbType.NVarChar,200),
                    new SqlParameter("@isMustCheck", SqlDbType.Bit),
                    new SqlParameter("@isAddupCheck", SqlDbType.Bit),
                    new SqlParameter("@checkAmount", SqlDbType.Float),
                    new SqlParameter("@arrivedAmount", SqlDbType.Float),
                    new SqlParameter("@openBoxScale", SqlDbType.Float),
                    new SqlParameter("@checkOutScale", SqlDbType.Float),
                    new SqlParameter("@mark", SqlDbType.NVarChar,500),
                    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.checkDetailDesc;
            parameters[2].Value = model.materialNo;
            parameters[3].Value = model.checkFileId;
            parameters[4].Value = model.checkItemId;
            parameters[5].Value = model.dateType;
            parameters[6].Value = model.unit;
            parameters[7].Value = model.uplimit;
            parameters[8].Value = model.downlimit;
            parameters[9].Value = model.standDesc;
            parameters[10].Value = model.isMustCheck;
            parameters[11].Value = model.isAddupCheck;
            parameters[12].Value = model.checkAmount;
            parameters[13].Value = model.arrivedAmount;
            parameters[14].Value = model.openBoxScale;
            parameters[15].Value = model.checkOutScale;
            parameters[16].Value = model.mark;
            parameters[17].Value = model.isrtEmpId;
            parameters[18].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[19].Value = model.updtEmpId;
            parameters[20].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;
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(LCheckDetailData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into LCheckDetail(");
            strSql.Append(@"checkDetailDesc,materialNo,checkFileId,checkItemId,dateType,unit,uplimit,downlimit,standDesc,isMustCheck,
                            isAddupCheck,checkAmount,arrivedAmount,openBoxScale,checkOutScale,mark,isrtEmpId,isrtDt,updtEmpId,updtDt)");
            strSql.Append(" values (");
            strSql.Append(@"@checkDetailDesc,@materialNo,@checkFileId,@checkItemId,@dateType,@unit,@uplimit,@downlimit,@standDesc,@isMustCheck,
                            @isAddupCheck,@checkAmount,@arrivedAmount,@openBoxScale,@checkOutScale,@mark,@isrtEmpId,@isrtDt,@updtEmpId,@updtDt)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@checkDetailDesc", SqlDbType.NVarChar,50),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@checkFileId", SqlDbType.Int),
                    new SqlParameter("@checkItemId", SqlDbType.Int),
                    new SqlParameter("@dateType", SqlDbType.NVarChar,10),
                    new SqlParameter("@unit", SqlDbType.NVarChar,20),
                    new SqlParameter("@uplimit", SqlDbType.NVarChar,200),
                    new SqlParameter("@downlimit", SqlDbType.NVarChar,200),
                    new SqlParameter("@standDesc", SqlDbType.NVarChar,200),
                    new SqlParameter("@isMustCheck", SqlDbType.Bit),
                    new SqlParameter("@isAddupCheck", SqlDbType.Bit),
                    new SqlParameter("@checkAmount", SqlDbType.Float),
                    new SqlParameter("@arrivedAmount", SqlDbType.Float),
                    new SqlParameter("@openBoxScale", SqlDbType.Float),
                    new SqlParameter("@checkOutScale", SqlDbType.Float),
                    new SqlParameter("@mark", SqlDbType.NVarChar,500),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.checkDetailDesc;
            parameters[1].Value = model.materialNo;
            parameters[2].Value = model.checkFileId;
            parameters[3].Value = model.checkItemId;
            parameters[4].Value = model.dateType;
            parameters[5].Value = model.unit;
            parameters[6].Value = model.uplimit;
            parameters[7].Value = model.downlimit;
            parameters[8].Value = model.standDesc;
            parameters[9].Value = model.isMustCheck;
            parameters[10].Value = model.isAddupCheck;
            parameters[11].Value = model.checkAmount;
            parameters[12].Value = model.arrivedAmount;
            parameters[13].Value = model.openBoxScale;
            parameters[14].Value = model.checkOutScale;
            parameters[15].Value = model.mark;
            parameters[16].Value = model.isrtEmpId;
            parameters[17].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[18].Value = model.updtEmpId;
            parameters[19].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;
        }
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public LCheckDetailData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,checkDetailDesc,materialNo,checkFileId,checkItemId,dateType,unit,uplimit,downlimit,standDesc,isMustCheck,
                            isAddupCheck,checkAmount,arrivedAmount,openBoxScale,checkOutScale,mark,isrtEmpId,isrtDt,updtEmpId,updtDt from LCheckDetail");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            LCheckDetailData model = new LCheckDetailData();
            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["checkDetailDesc"] != DBNull.Value)
                {
                    model.checkDetailDesc = Convert.ToString(row["checkDetailDesc"]);
                }
                if (row["materialNo"] != DBNull.Value)
                {
                    model.materialNo = Convert.ToString(row["materialNo"]);
                }
                if (row["checkFileId"] != DBNull.Value)
                {
                    model.checkFileId = Convert.ToInt32(row["checkFileId"]);
                }
                if (row["checkItemId"] != DBNull.Value)
                {
                    model.checkItemId = Convert.ToInt32(row["checkItemId"]);
                }
                if (row["dateType"] != DBNull.Value)
                {
                    model.dateType = Convert.ToString(row["dateType"]);
                }
                if (row["unit"] != DBNull.Value)
                {
                    model.unit = Convert.ToString(row["unit"]);
                }
                if (row["uplimit"] != DBNull.Value)
                {
                    model.uplimit = Convert.ToString(row["uplimit"]);
                }
                if (row["downlimit"] != DBNull.Value)
                {
                    model.downlimit = Convert.ToString(row["downlimit"]);
                }
                if (row["standDesc"] != DBNull.Value)
                {
                    model.standDesc = Convert.ToString(row["standDesc"]);
                }
                if (row["isMustCheck"] != DBNull.Value)
                {
                    model.isMustCheck = Convert.ToBoolean(row["isMustCheck"]);
                }
                if (row["isAddupCheck"] != DBNull.Value)
                {
                    model.isAddupCheck = Convert.ToBoolean(row["isAddupCheck"]);
                }
                if (row["checkAmount"] != DBNull.Value)
                {
                    model.checkAmount = Convert.ToDouble(row["checkAmount"]);
                }
                if (row["arrivedAmount"] != DBNull.Value)
                {
                    model.arrivedAmount = Convert.ToDouble(row["arrivedAmount"]);
                }
                if (row["openBoxScale"] != DBNull.Value)
                {
                    model.openBoxScale = Convert.ToDouble(row["openBoxScale"]);
                }
                if (row["checkOutScale"] != DBNull.Value)
                {
                    model.checkOutScale = Convert.ToDouble(row["checkOutScale"]);
                }
                if (row["mark"] != DBNull.Value)
                {
                    model.mark = Convert.ToString(row["mark"]);
                }
                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;
            }
        }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(LCheckDetailData model)
 {
     return this.checkDetailDB.ModifyRecord(model);
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(LCheckDetailData model)
 {
     return this.checkDetailDB.AddRecord(model);
 }
 /// <summary>
 /// 数据保存
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     LCheckDetailData model = new LCheckDetailData();
     LCheckDetailBB checkDetailBB = new LCheckDetailBB();
     try
     {
         if (this.State == "1")
         {
             this.SetModel(ref model);
             model.isrtDt = DateTime.Now.ToString();
             model.isrtEmpId = this.currentUser.empId;
             this.IdValue = checkDetailBB.AddRecord(model);
             this.State = "2";
         }
         else if (this.State == "2")
         {
             model = checkDetailBB.GetModel(this.IdValue);
             this.SetModel(ref model);
             model.updtDt = DateTime.Now.ToString();
             model.updtEmpId = this.currentUser.empId;
             checkDetailBB.ModifyRecord(model);
         }
     }
     catch (Exception ex)
     {
         this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
         return;
     }
     finally
     {
         checkDetailBB.Dispose();
     }
     this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('保存成功!');", true);
 }
    /// <summary>
    /// 实体类赋值
    /// </summary>
    /// <param name="model">实体类实例</param>
    private void SetModel(ref LCheckDetailData model)
    {
        model.materialNo = this.materialNo.Text;
        model.checkDetailDesc = this.checkDetailDesc.Text;

        if (this.checkItemId.SelectedValue != "")
        {
            model.checkItemId = Convert.ToInt32(this.checkItemId.SelectedValue);
        }
        else
        {
            model.checkItemId = 0;
        }
        model.dateType = this.dateType.Text;
        model.unit = this.unit.Text;
        model.uplimit = this.uplimit.Text;
        model.downlimit = this.downlimit.Text;
        model.standDesc = this.standDesc.Text;
        model.isMustCheck = this.isMustCheck.Checked;
        model.isAddupCheck = this.isAddupCheck.Checked;

        if (this.checkAmount.Text != "")
        {
            model.checkAmount = Convert.ToDouble(this.checkAmount.Text);
        }
        else
        {
            model.checkAmount = 0;
        }
        if (this.openBoxScale.Text != "")
        {
            model.openBoxScale = Convert.ToDouble(this.openBoxScale.Text) / 100;
        }
        else
        {
            model.openBoxScale = 0;
        }
        if (this.checkOutScale.Text != "")
        {
            model.checkOutScale = Convert.ToDouble(this.checkOutScale.Text) / 100;
        }
        else
        {
            model.checkOutScale = 0;
        }
        model.mark = this.mark.Text;

        if (this.fileId.Value != "")
        {
            model.checkFileId = Convert.ToInt32(this.fileId.Value);
        }
        else
        {
            model.checkFileId = 0;
        }
    }