/// <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;
        }

        LProductLineData model = new LProductLineData();
        LProductLineBB productLineBB = new LProductLineBB();

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

        Response.Redirect("LProductLineList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main", false);
    }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(LProductLineData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into LProductLine(");
            strSql.Append(@"productLineNo,productLineNm,isDel,isrtEmpId,isrtDt,updtEmpId,updtDt)");
            strSql.Append(" values (");
            strSql.Append(@"@productLineNo,@productLineNm,@isDel,@isrtEmpId,@isrtDt,@updtEmpId,@updtDt)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@productLineNo", SqlDbType.VarChar,20),
                    new SqlParameter("@productLineNm", SqlDbType.NVarChar,50),
                    new SqlParameter("@isDel", SqlDbType.Bit),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.productLineNo;
            parameters[1].Value = model.productLineNm;
            parameters[2].Value = model.isDel;
            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;

            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">实体类实例</param>
 private void SetModel(ref LProductLineData model)
 {
     model.productLineNo = this.tbProductLineNo.Text;
     model.productLineNm = this.tbProductLineNm.Text;
 }
    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        bool retChecked = false;
        LProductLineBB productLineBB = new LProductLineBB();

        try
        {
            //获取选中的数据Id
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    retChecked = true;
                    int id = int.Parse(chkId.ValidationGroup);
                    LProductLineData productLineModel = new LProductLineData();

                    productLineModel = productLineBB.GetModel(id);

                    productLineModel.isDel = true;
                    productLineModel.updtDt = System.DateTime.Now.ToString();
                    productLineModel.updtEmpId = this.currentUser.empId;

                    productLineBB.ModifyRecord(productLineModel);
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            productLineBB.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
    }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(LProductLineData model)
 {
     return this.productLineDB.ModifyRecord(model);
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(LProductLineData model)
 {
     return this.productLineDB.AddRecord(model);
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(LProductLineData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update LProductLine set ");
            strSql.Append("productLineNo=@productLineNo,");
            strSql.Append("productLineNm=@productLineNm,");
            strSql.Append("isDel=@isDel,");
            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("@productLineNo", SqlDbType.VarChar,20),
                    new SqlParameter("@productLineNm", SqlDbType.NVarChar,50),
                    new SqlParameter("@isDel", SqlDbType.Bit),
                    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.productLineNo;
            parameters[2].Value = model.productLineNm;
            parameters[3].Value = model.isDel;
            parameters[4].Value = model.isrtEmpId;
            parameters[5].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[6].Value = model.updtEmpId;
            parameters[7].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>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public LProductLineData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,productLineNo,productLineNm,isDel,isrtEmpId,isrtDt,updtEmpId,updtDt from LProductLine");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            LProductLineData model = new LProductLineData();
            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["productLineNo"] != DBNull.Value)
                {
                    model.productLineNo = Convert.ToString(row["productLineNo"]);
                }
                if (row["productLineNm"] != DBNull.Value)
                {
                    model.productLineNm = Convert.ToString(row["productLineNm"]);
                }
                if (row["isDel"] != DBNull.Value)
                {
                    model.isDel = Convert.ToBoolean(row["isDel"]);
                }
                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;
            }
        }