protected void Btn_U_parameter_Click(object sender, EventArgs e)
    {
        DataSet   ds = ppl.S_ProProcessParameter(new Guid(Label_PT_ID.Text.Trim()), new Guid(Label_PBCID.Text.Trim()));
        DataTable dt = ds.Tables[0];
        DataView  dv = ds.Tables[0].DefaultView;

        if (dt.Rows.Count == 0)
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('修改失败!您尚未制定工艺参数或合格率标准,您需要先制定!')", true);
            return;
        }
        if (Convert.ToDecimal(Txt_PassRate.Text) > 1 || Convert.ToDecimal(Txt_PassRate.Text) <= 0)
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('合格率标准应该是0至1之间的小数形式')", true);
            return;
        }
        pplinfo.PPP_Parameter = Txt_parameter.Text;
        pplinfo.PT_ID         = new Guid(Label_PT_ID.Text.Trim());
        pplinfo.PBC_ID        = new Guid(Label_PBCID.Text.Trim());
        pplinfo.PPP_Note      = TextBox_Note.Text;
        pplinfo.PPP_PassRate  = Convert.ToDecimal(Txt_PassRate.Text);
        ppl.U_ProProcessParameter(pplinfo);
        ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('修改成功')", true);
        Panel_CheckParameter.Visible = false;
        UpdatePanel_CheckParameter.Update();
        Txt_parameter.Text = "";
        Txt_PassRate.Text  = "";
        TextBox_Note.Text  = "";
    }
 protected void Btn_Close_Parameter_Click(object sender, EventArgs e)
 {
     Panel_Parameter.Visible      = false;
     Panel_CheckParameter.Visible = false;
     UpdatePanel_CheckParameter.Update();
     GridView_Parameter.SelectedIndex = -1;
 }
    } //行链接按钮命令

    protected void Gridview_PS_Editing(object sender, GridViewEditEventArgs e)//显示编辑产品系列状态
    {
        GridView1.SelectedIndex = e.NewEditIndex;
        GridView1.EditIndex     = e.NewEditIndex;

        if (Label_Grid1_State.Text == "默认数据源")
        {
            GridView1.DataSource = ppl.SList_ProSeries();
            GridView1.DataBind();
        }
        if (Label_Grid1_State.Text == "模糊搜索数据源")
        {
            GridView1.DataSource = ppl.S_ProSeries(Txt_search.Text.Trim());
            GridView1.DataBind();
        } //绑定数据源
        //无关信息隐藏
        Panel_PT.Visible             = false;
        Panel_AddPS.Visible          = false;
        Panel_AddPT.Visible          = false;
        Panel_CheckParameter.Visible = false;
        Panel_Parameter.Visible      = false;
        UpdatePanel_PT.Update();
        UpdatePanel_AddPS.Update();
        UpdatePanel_AddPT.Update();
        UpdatePanel_CheckParameter.Update();
        UpdatePanel_Parameter.Update();
    }
 protected void Button_Close_CheckParameter_Click(object sender, EventArgs e)
 {
     Panel_CheckParameter.Visible = false;
     Panel_CheckParameter.Visible = false;
     UpdatePanel_CheckParameter.Update();
     Txt_parameter.Text = "";
     Txt_PassRate.Text  = "";
 }
    }  //行分页

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Delete1")
        {
            GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
            GridView1.SelectedIndex = row.RowIndex;
            GridView1.SelectedIndex = -1;

            // this.Lab_State.Text = "Delete1";
            string id      = e.CommandArgument.ToString();
            Guid   guid_id = new Guid(id);
            ppl.D_ProSeries(guid_id);
            GridView1.DataSource = ppl.SList_ProSeries();
            GridView1.DataBind();
            UpdatePanel_PS.Update();
            //无关信息隐藏
            Panel_PT.Visible             = false;
            Panel_AddPS.Visible          = false;
            Panel_AddPT.Visible          = false;
            Panel_CheckParameter.Visible = false;
            Panel_Parameter.Visible      = false;
            UpdatePanel_PT.Update();
            UpdatePanel_AddPS.Update();
            UpdatePanel_AddPT.Update();
            UpdatePanel_CheckParameter.Update();
            UpdatePanel_Parameter.Update();
        }


        if (e.CommandName == "CheckProType")
        {
            Panel_PT.Visible                 = true;
            GridView2.SelectedIndex          = -1;
            GridView_Parameter.SelectedIndex = -1;
            GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
            GridView1.SelectedIndex = row.RowIndex;
            string[] al = e.CommandArgument.ToString().Split(new char[] { ',' });
            string   id = al[0];
            Label_PsName.Text = al[1] + " 所属";
            Label_PS.Text     = id;
            Guid   guid_id   = new Guid(id);
            string condition = " PS_ID='" + id + "'";
            GridView2.DataSource = ppl.S_ProSeries_ProType(condition);
            GridView2.DataBind();
            UpdatePanel_PT.Update();
            //无关信息隐藏
            Panel_AddPS.Visible          = false;
            Panel_AddPT.Visible          = false;
            Panel_CheckParameter.Visible = false;
            Panel_Parameter.Visible      = false;
            UpdatePanel_AddPS.Update();
            UpdatePanel_AddPT.Update();
            UpdatePanel_CheckParameter.Update();
            UpdatePanel_Parameter.Update();
        }
    } //行链接按钮命令
 protected void Button_Close_PT_Click(object sender, EventArgs e)
 {
     GridView2.SelectedIndex          = -1;
     GridView_Parameter.SelectedIndex = -1;
     Panel_PT.Visible    = false;
     Panel_AddPT.Visible = false;
     UpdatePanel_AddPT.Update();
     Panel_Parameter.Visible = false;
     UpdatePanel_Parameter.Update();
     Panel_CheckParameter.Visible = false;
     UpdatePanel_CheckParameter.Update();
     Txt_PT_Search.Text = "";
 }
    protected void Btn_I_parameter_Click(object sender, EventArgs e)
    {
        try
        { decimal a = Convert.ToDecimal(Txt_PassRate.Text); }
        catch (Exception)
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('合格率标准必须是小数形式')", true);
            return;
        }


        if (Convert.ToDecimal(Txt_PassRate.Text) > 1 || Convert.ToDecimal(Txt_PassRate.Text) < 0)
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('合格率标准应该是0至1之间的小数形式')", true);
            return;
        }
        DataSet   ds = ppl.S_ProProcessParameter(new Guid(Label_PT_ID.Text.Trim()), new Guid(Label_PBCID.Text.Trim()));
        DataTable dt = ds.Tables[0];
        DataView  dv = ds.Tables[0].DefaultView;

        if (dt.Rows.Count != 0)
        {
            //ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "alert", "alert('已经制定过了工艺参数或合格率标准,您只能修改')", true);
            //return;
            pplinfo.PPP_Parameter = Txt_parameter.Text;
            pplinfo.PT_ID         = new Guid(Label_PT_ID.Text.Trim());
            pplinfo.PBC_ID        = new Guid(Label_PBCID.Text.Trim());
            pplinfo.PPP_Note      = TextBox_Note.Text;
            pplinfo.PPP_PassRate  = Convert.ToDecimal(Txt_PassRate.Text);
            ppl.U_ProProcessParameter(pplinfo);
        }
        else
        {
            pplinfo.PPP_Parameter = Txt_parameter.Text;
            pplinfo.PT_ID         = new Guid(Label_PT_ID.Text.Trim());
            pplinfo.PBC_ID        = new Guid(Label_PBCID.Text.Trim());
            pplinfo.PPP_Note      = TextBox_Note.Text;
            pplinfo.PPP_PassRate  = Convert.ToDecimal(Txt_PassRate.Text);
            ppl.I_ProProcessParameter(pplinfo);
        }
        ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('提交成功')", true);
        Panel_CheckParameter.Visible = false;
        UpdatePanel_CheckParameter.Update();
        Txt_parameter.Text = "";
        Txt_PassRate.Text  = "";
        TextBox_Note.Text  = "";
    }
    protected void GridView_Parameter_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Check_PT_Parameter")
        {
            GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
            GridView_Parameter.SelectedIndex = row.RowIndex;
            string[] a     = e.CommandArgument.ToString().Split(new char[] { ',' });
            string   pbcid = a[0];
            Label_PBCID.Text             = pbcid;
            Panel_CheckParameter.Visible = true;
            UpdatePanel_CheckParameter.Update();
            Guid      guid_id = new Guid(pbcid);
            DataSet   ds      = ppl.S_ProProcessParameter(new Guid(Label_PT_ID.Text.Trim()), guid_id);
            DataTable dt      = ds.Tables[0];
            DataView  dv      = ds.Tables[0].DefaultView;
            if (dt.Rows.Count == 0)
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('您尚未制定工艺参数或合格率标准,请先输入相关参数并制定!您将看到参考的工艺参数和合格率标准')", true);

                DataSet   ds2 = ppl.S_PBCraftInfo(new Guid(Label_PBCID.Text));
                DataTable dt2 = ds2.Tables[0];
                DataView  dv2 = ds2.Tables[0].DefaultView;
                foreach (DataRowView datav in dv2)
                {
                    Txt_parameter.Text = datav["PBC_Parameter"].ToString().Trim();
                    Txt_PassRate.Text  = datav["PBC_PassRate"].ToString().Trim();
                }
                // this.Txt_parameter.Text = "";
                // this.Txt_PassRate.Text = "";
                TextBox_Note.Text = "";
                if (!Session["UserRole"].ToString().Contains("产品基础信息维护"))
                {
                    Panel_CheckParameter.Visible = false;
                    UpdatePanel_CheckParameter.Update();
                }
                return;
            }

            foreach (DataRowView datav in dv)
            {
                Txt_parameter.Text = datav["PPP_Parameter"].ToString().Trim();
                Txt_PassRate.Text  = datav["PPP_PassRate"].ToString().Trim();
                TextBox_Note.Text  = datav["PPP_Note"].ToString().Trim();
            }
            Label_PT2.Text = Label_PTP.Text + " " + a[1] + " ";
        }
    }
    protected void Button_Cancel_Click(object sender, EventArgs e) //取消搜索产品系列
    {
        Label_Grid1_State.Text = "默认数据源";
        Txt_search.Text        = "";
        GridView1.DataSource   = ppl.SList_ProSeries();
        GridView1.DataBind();
        UpdatePanel_PS.Update();
        UpdatePanel_Search.Update();
        UpdatePanel_AddPS.Update();

        //无关信息隐藏
        Panel_PT.Visible             = false;
        Panel_AddPS.Visible          = false;
        Panel_AddPT.Visible          = false;
        Panel_CheckParameter.Visible = false;
        Panel_Parameter.Visible      = false;
        UpdatePanel_PT.Update();
        UpdatePanel_AddPS.Update();
        UpdatePanel_AddPT.Update();
        UpdatePanel_CheckParameter.Update();
        UpdatePanel_Parameter.Update();
    }
    protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Check_Parameter")
        {
            GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
            GridView2.SelectedIndex = row.RowIndex;

            //无关信息隐藏

            Panel_AddPS.Visible          = false;
            Panel_AddPT.Visible          = false;
            Panel_CheckParameter.Visible = false;


            UpdatePanel_AddPS.Update();
            UpdatePanel_AddPT.Update();
            UpdatePanel_CheckParameter.Update();



            GridView_Parameter.SelectedIndex = -1;

            string[] al   = e.CommandArgument.ToString().Split(new char[] { ',' });
            string   prid = al[0];
            Label_PRID.Text = prid;
            string ptname = al[1];
            string ptid   = al[2];
            Label_PTP.Text          = ptname;
            Label_PT_ID.Text        = ptid;
            Panel_Parameter.Visible = true;
            if (prid == "")
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('该产品尚未制定工艺路线!')", true);
                return;
            }
            Guid guid_id = new Guid(prid);
            GridView_Parameter.DataSource = ppl.S_ProType_ProcessRoute(guid_id);
            GridView_Parameter.DataBind();
            UpdatePanel_Parameter.Update();
        }
        if (e.CommandName == "Delete_PT")
        {
            GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
            GridView2.SelectedIndex = row.RowIndex;
            GridView2.SelectedIndex = -1;

            //无关信息隐藏

            Panel_AddPS.Visible          = false;
            Panel_AddPT.Visible          = false;
            Panel_Parameter.Visible      = false;
            Panel_CheckParameter.Visible = false;

            UpdatePanel_Parameter.Update();
            UpdatePanel_AddPS.Update();
            UpdatePanel_AddPT.Update();
            UpdatePanel_CheckParameter.Update();

            string id      = e.CommandArgument.ToString();
            Guid   guid_id = new Guid(id);
            ppl.D_ProType(guid_id);
            string condition;
            string psid    = " PS_ID='" + Label_PS.Text.Trim() + "'";
            string pt_name = Txt_PT_Search.Text.Trim() == "" ? "1=1" : "PT_Name like '%" + Txt_PT_Search.Text.Trim() + "%'";
            condition            = psid + " and " + pt_name;
            GridView2.DataSource = ppl.S_ProSeries_ProType(condition);
            GridView2.DataBind();
            UpdatePanel_PT.Update();
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('删除成功!')", true);
        }
        if (e.CommandName == "Edit_PT")
        {
            GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
            GridView2.SelectedIndex = row.RowIndex;

            //无关信息隐藏

            Panel_AddPS.Visible = false;
            // this.Panel_AddPT.Visible = false;
            Panel_Parameter.Visible      = false;
            Panel_CheckParameter.Visible = false;

            UpdatePanel_Parameter.Update();
            UpdatePanel_AddPS.Update();
            // this.UpdatePanel_AddPT.Update();
            UpdatePanel_CheckParameter.Update();

            DropDownList_BOM.DataSource     = ppl.S_BOM_Name();
            DropDownList_BOM.DataTextField  = "BOM_Name";
            DropDownList_BOM.DataValueField = "BOM_ID";
            DropDownList_BOM.DataBind();
            DropDownList_BOM.Items.Insert(0, new ListItem("请选择", ""));

            DropDownList_PR.DataSource     = ppl.S_PR_Name();
            DropDownList_PR.DataTextField  = "PR_Name";
            DropDownList_PR.DataValueField = "PR_ID";
            DropDownList_PR.DataBind();
            DropDownList_PR.Items.Insert(0, new ListItem("请选择", ""));


            string[] a         = e.CommandArgument.ToString().Split(new char[] { ',' });
            string   ptname    = a[0];
            string   ptspecial = a[1];
            string   prid      = a[2];
            string   bomid     = a[3];
            Label_PT_ID.Text = a[4];

            Txt_PT.Text       = ptname;
            Label_ptname.Text = ptname;
            DropDownList_Special.SelectedValue = ptspecial;

            DropDownList_PR.Items.FindByValue(prid.ToString().Trim()).Selected   = true;
            DropDownList_BOM.Items.FindByValue(bomid.ToString().Trim()).Selected = true;
            Label_submitState.Text = "编辑";
            Panel_AddPT.Visible    = true;

            UpdatePanel_AddPT.Update();
        }
    }