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

        LNoPassReasonData model = new LNoPassReasonData();
        LNoPassReasonBB noPassReasonBB = new LNoPassReasonBB();

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

        Response.Redirect("LNoPassReasonList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main", false);
    }
    /// <summary>
    /// 绑定Grid
    /// </summary>
    protected void BindGrid()
    {
        LNoPassReasonBB noPassReasonBB = new LNoPassReasonBB();
        DataSet ds = new DataSet();

        try
        {
            string strWhere = this.StrWhere;

            //不合格原因编码
            if (this.tbNoPassReasonNo.Text.Trim() != "")
            {
                strWhere += " and noPassReasonNo like '%" + this.tbNoPassReasonNo.Text.Trim().Replace("'", "''") + "%'";
            }

            //不合格原因名称
            if (this.tbNoPassReasonNo.Text.Trim() != "")
            {
                strWhere += " and noPassReasonNm like '%" + this.tbNoPassReasonNm.Text.Trim().Replace("'", "''") + "%'";
            }

            //检测项目
            if (this.ddlCheckItem.SelectedValue != "")
            {
                strWhere += " and checkItemId='" + this.ddlCheckItem.SelectedValue + "'";
            }

            ds = noPassReasonBB.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
        {
            noPassReasonBB.Dispose();
        }
    }
 /// <summary>
 /// 展示数据
 /// </summary>
 /// <param name="id">记录Id</param>
 private void ShowInfo(int id)
 {
     LNoPassReasonBB noPassReasonBB = new LNoPassReasonBB();
     vLNoPassReasonData model = new vLNoPassReasonData();
     try
     {
         model = noPassReasonBB.GetVModel(id);
         this.tbNoPassReasonNo.Text = model.noPassReasonNo;
         this.tbNoPassReasonNm.Text = model.noPassReasonNm;
         this.ddlCheckItem.SelectedValue = model.checkItemId.ToString();
     }
     finally
     {
         noPassReasonBB.Dispose();
     }
 }
Example #4
0
    public DataTable GetNoPassReason(int checkItemId)
    {
        LNoPassReasonBB noPassReasonBB = new LNoPassReasonBB();

        try
        {
            DataTable dt = new DataTable();

            dt = noPassReasonBB.GetList("isDel=0 and checkItemId=" + checkItemId.ToString()).Tables[0];
            return dt;
        }
        finally
        {
            noPassReasonBB.Dispose();
        }
    }
    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        bool retChecked = false;
        LNoPassReasonBB noPassReasonBB = new LNoPassReasonBB();
        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);
                    LNoPassReasonData noPassReasonModel = new LNoPassReasonData();

                    noPassReasonModel = noPassReasonBB.GetModel(id);
                    noPassReasonModel.isDel = true;
                    noPassReasonModel.updtDt = System.DateTime.Now.ToString();
                    noPassReasonModel.updtEmpId = this.currentUser.empId;
                    noPassReasonBB.ModifyRecord(noPassReasonModel);
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            noPassReasonBB.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
    }