/// <summary>
    /// 数据保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string strInfo = "";

        if (!this.ValidateData(out strInfo))
        {
            strInfo = strInfo.Replace("\"", "'").Replace("\n", "");
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + strInfo + "');", true);
            return;
        }

        LWareLocatorRelationData model = new LWareLocatorRelationData();
        LWareLocatorRelationBB wareLocatorBB = new LWareLocatorRelationBB();

        try
        {
            if (this.State == "1")
            {
                this.SetModel(ref model);
                model.isrtDt = DateTime.Now.ToString();
                model.isrtEmpId = this.currentUser.empId;
                this.IdValue = wareLocatorBB.AddRecord(model);
            }
            else if (this.State == "2")
            {
                //model = wareLocatorBB.GetModel(this.IdValue);
                //this.SetModel(ref model);
                //model.updtDt = DateTime.Now.ToString();
                //model.updtEmpId = this.currentUser.empId;
                //wareLocatorBB.ModifyRecord(model);
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            wareLocatorBB.Dispose();
        }

        if (Request.Params["backurl"] != null && Request.Params["backurl"].Trim() != "")
        {
            Response.Redirect(Request.Params["backurl"], true);
        }
    }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(LWareLocatorRelationData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into LWareLocatorRelation(");
            strSql.Append(@"wareLocatorStartPrefix,wareLocatorEndPrefix,priority,isrtEmpId,isrtDt,updtEmpId,updtDt,isDel)");
            strSql.Append(" values (");
            strSql.Append(@"@wareLocatorStartPrefix,@wareLocatorEndPrefix,@priority,@isrtEmpId,@isrtDt,@updtEmpId,@updtDt,@isDel)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@wareLocatorStartPrefix", SqlDbType.NVarChar,50),
                    new SqlParameter("@wareLocatorEndPrefix", SqlDbType.NVarChar,50),
                    new SqlParameter("@priority", SqlDbType.Int),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime),
                    new SqlParameter("@isDel", SqlDbType.Bit)
                };
            parameters[0].Value = model.wareLocatorStartPrefix;
            parameters[1].Value = model.wareLocatorEndPrefix;
            parameters[2].Value = model.priority;
            parameters[3].Value = model.isrtEmpId;
            parameters[4].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[5].Value = model.updtEmpId;
            parameters[6].Value = model.updtDt == string.Empty ? null : model.updtDt;
            parameters[7].Value = model.isDel;

            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>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(LWareLocatorRelationData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update LWareLocatorRelation set ");
            strSql.Append("priority=@priority,");
            strSql.Append("isrtEmpId=@isrtEmpId,");
            strSql.Append("isrtDt=@isrtDt,");
            strSql.Append("updtEmpId=@updtEmpId,");
            strSql.Append("updtDt=@updtDt,");
            strSql.Append("isDel=@isDel");
            strSql.Append(" where wareLocatorStartPrefix = @wareLocatorStartPrefix AND wareLocatorEndPrefix = @wareLocatorEndPrefix ");
            SqlParameter[] parameters = {
                    new SqlParameter("@wareLocatorStartPrefix", SqlDbType.NVarChar,50),
                    new SqlParameter("@wareLocatorEndPrefix", SqlDbType.NVarChar,50),
                    new SqlParameter("@priority", SqlDbType.Int),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime),
                    new SqlParameter("@isDel", SqlDbType.Bit)
                };
            parameters[0].Value = model.wareLocatorStartPrefix;
            parameters[1].Value = model.wareLocatorEndPrefix;
            parameters[2].Value = model.priority;
            parameters[3].Value = model.isrtEmpId;
            parameters[4].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[5].Value = model.updtEmpId;
            parameters[6].Value = model.updtDt == string.Empty ? null : model.updtDt;
            parameters[7].Value = model.isDel;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="wareLocatorStartPrefix">主键值</param>
        /// <param name="wareLocatorEndPrefix">主键值</param>
        /// <returns>model</returns>
        public LWareLocatorRelationData GetModel(string wareLocatorStartPrefix, string wareLocatorEndPrefix)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,wareLocatorStartPrefix,wareLocatorEndPrefix,priority,isrtEmpId,isrtDt,updtEmpId,updtDt,isDel from LWareLocatorRelation");
            strSql.Append(" where wareLocatorStartPrefix = @wareLocatorStartPrefix AND wareLocatorEndPrefix = @wareLocatorEndPrefix ");
            SqlParameter[] parameters = {
                    new SqlParameter("@wareLocatorStartPrefix", SqlDbType.NVarChar,50),
                    new SqlParameter("@wareLocatorEndPrefix", SqlDbType.NVarChar,50)
                };
            parameters[0].Value = wareLocatorStartPrefix;
            parameters[1].Value = wareLocatorEndPrefix;

            LWareLocatorRelationData model = new LWareLocatorRelationData();
            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["wareLocatorStartPrefix"] != DBNull.Value)
                {
                    model.wareLocatorStartPrefix = Convert.ToString(row["wareLocatorStartPrefix"]);
                }
                if (row["wareLocatorEndPrefix"] != DBNull.Value)
                {
                    model.wareLocatorEndPrefix = Convert.ToString(row["wareLocatorEndPrefix"]);
                }
                if (row["priority"] != DBNull.Value)
                {
                    model.priority = Convert.ToInt32(row["priority"]);
                }
                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"]);
                }
                if (row["isDel"] != DBNull.Value)
                {
                    model.isDel = Convert.ToBoolean(row["isDel"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(LWareLocatorRelationData model)
 {
     return this.wareLocatorRelationDB.ModifyRecord(model);
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(LWareLocatorRelationData model)
 {
     return this.wareLocatorRelationDB.AddRecord(model);
 }
    /// <summary>
    /// 实体类赋值
    /// </summary>
    /// <param name="model">实体类实例</param>
    private void SetModel(ref LWareLocatorRelationData model)
    {
        model.wareLocatorStartPrefix = this.tbWareLocatorNoStartPrefix.Text;//库位的对应前缀
        model.wareLocatorEndPrefix = this.tbWareLocatorNoEndPrefix.Text;

        //是否层板
        if (this.ddlIsBoard.SelectedValue != "")
        {
            model.isDel = this.ddlIsBoard.SelectedValue == "0" ? false : true;
        }

        //优先级设定
        if (this.tbPriopity.Text.Trim() != "")
        {
            model.priority = Convert.ToInt32(this.tbPriopity.Text.Trim());
        }
    }