コード例 #1
0
    /// <summary>
    /// 绑定Grid
    /// </summary>
    protected void BindGrid()
    {
        LProductLineBB productLineBB = new LProductLineBB();
        DataSet ds = new DataSet();

        try
        {
            string strWhere = this.StrWhere;

            //生产线编码
            if (this.tbProductLineNo.Text.Trim() != "")
            {
                strWhere += " and productLineNo like '%" + this.tbProductLineNo.Text.Trim().Replace("'", "''") + "%'";
            }

            //生产线名称
            if (this.tbProductLineNm.Text.Trim() != "")
            {
                strWhere += " and productLineNm like '%" + this.tbProductLineNm.Text.Trim().Replace("'", "''") + "%'";
            }

            ds = productLineBB.GetVList(strWhere);
            this.grid.DataSource = ds.Tables[0];
            this.grid.DataBind();

            //赋值记录条数、页面总数
            this.Label3.Text = ds.Tables[0].Rows.Count.ToString();
            this.Label2.Text = this.grid.PageCount.ToString();
            this.currPage.Text = (this.grid.PageIndex + 1).ToString();
        }
        finally
        {
            productLineBB.Dispose();
        }
    }
コード例 #2
0
    /// <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);
    }
コード例 #3
0
    /// <summary>
    /// 展示数据
    /// </summary>
    /// <param name="id">记录Id</param>
    private void ShowInfo(int id)
    {
        LProductLineBB productLineBB = new LProductLineBB();
        vLProductLineData model = new vLProductLineData();

        try
        {
            model = productLineBB.GetVModel(id);
            this.tbProductLineNo.Text = model.productLineNo;
            this.tbProductLineNm.Text = model.productLineNm;
        }
        finally
        {
            productLineBB.Dispose();
        }
    }
コード例 #4
0
    /// <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();
        }
    }