//操作Gridview的命令行
 protected void Grid_CFRoute_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Delete_CFRoute")
     {
         GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
         Grid_CFCraft.SelectedIndex = row.RowIndex;
         Guid guid = new Guid(e.CommandArgument.ToString());
         try
         {
             iQCBasicDataL.Delete_PRDetail_RZR(guid);
         }
         catch (Exception exc)
         {
             ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('删除失败!" + exc + "')", true);
         }
         ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('删除成功!')", true);
         BindGrid2(id3);
         UpdatePanel_CFRoute.Update();
         BindGrid4(id4);
         UpdatePanel_SearchCraft.Update();
     }
 }
 //关闭
 protected void Btn_ClsCFCFRoute_Click(object sender, EventArgs e)
 {
     Panel_CFRoute.Visible = false;
     UpdatePanel_CFRoute.Update();
     if (Panel_GridCFCraft.Visible == false)
     {
         Panel_SearchCraft.Visible = false;
         UpdatePanel_SearchCraft.Update();
     }
     else if (Panel_GridCFCraft.Visible == true)
     {
         ((BoundField)Grid_Craft.Columns[1]).ReadOnly = false;
         ((BoundField)Grid_Craft.Columns[2]).ReadOnly = true;
         LblState.Text = "认证";
         //TxtOrder.Text = "";
         //TxtName.Text = "";
         id4 = id2;
         IQCBasicDataInfo IQC = new IQCBasicDataInfo();
         IQC             = iQCBasicDataL.Search_ProType_ID(id2)[0];
         LblSCState.Text = IQC.PT_Name;
         BindGrid4(id4);
         UpdatePanel_SearchCraft.Update();
     }
 }
    //更新
    protected void GridView_Craft_Updating(object sender, GridViewUpdateEventArgs e)
    {
        if (LblGongxuState.Text == "认证")
        {
            Guid id = new Guid(Grid_Craft.DataKeys[e.RowIndex].Values["PRD_ID"].ToString());
            int  PRD_RenZhengOrder, m1;
            if (((TextBox)(Grid_Craft.Rows[e.RowIndex].Cells[1].Controls[0])).Text.Trim().ToString() == "")
            {
                try
                {
                    if (iQCBasicDataL.Insert_PRDetail_RZ(id) <= 0)
                    {
                        ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('请输入工序或者确认认证工艺路线工序中没有该工序!')", true);
                        return;
                    }
                    //  ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "alert", "alert('编辑成功!')", true);
                }
                catch (Exception exc)
                {
                    ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('编辑失败!" + exc + "')", true);
                }
            }
            else
            {
                if (int.TryParse(((TextBox)(Grid_Craft.Rows[e.RowIndex].Cells[1].Controls[0])).Text.Trim().ToString(), out m1))
                {
                    PRD_RenZhengOrder = m1;
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('序号请输入整数!')", true);
                    return;
                }
                try
                {
                    if (iQCBasicDataL.Update_PRDetail_RZ(id, PRD_RenZhengOrder) <= 0)
                    {
                        ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('请输入新工序或者确认认证工艺路线工序中没有该工序!')", true);
                        return;
                    }
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('编辑成功!')", true);
                }
                catch (Exception)
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('排序必须是整数!')", true);
                    return;
                }
            }
            BindGrid2(id2);
            UpdatePanel_GridCFCraft.Update();
            BindGrid4(id4);
            UpdatePanel_SearchCraft.Update();
        }
        else if (LblGongxuState.Text == "工艺")
        {
            Guid id = new Guid(Grid_Craft.DataKeys[e.RowIndex].Values["PRD_ID"].ToString());
            int  PRD_RouteOrder, m1;

            if (((TextBox)(Grid_Craft.Rows[e.RowIndex].Cells[2].Controls[0])).Text.Trim().ToString() == "")
            {
                try
                {
                    if (iQCBasicDataL.Insert_PRDetail_RZR(id) <= 0)
                    {
                        ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('请输入工序或者确认认证工序中没有该工序!')", true);
                        return;
                    }
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('编辑成功!')", true);
                }
                catch (Exception exc)
                {
                    ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('编辑失败!" + exc + "')", true);
                }
            }
            else
            {
                if (int.TryParse(((TextBox)(Grid_Craft.Rows[e.RowIndex].Cells[2].Controls[0])).Text.Trim().ToString(), out m1))
                {
                    PRD_RouteOrder = m1;
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('序号请输入整数!')", true);
                    return;
                }
                try
                {
                    if (iQCBasicDataL.Update_PRDetail_RZR(id, PRD_RouteOrder) <= 0)
                    {
                        ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('请输入新工序或者确认认证工序中没有该工序!')", true);
                        return;
                    }
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('编辑成功!')", true);
                }
                catch (Exception)
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('排序必须是整数!')", true);
                    return;
                }
            }
            BindGrid3(id3);
            UpdatePanel_CFRoute.Update();
            BindGrid4(id4);
            UpdatePanel_SearchCraft.Update();
        }
        Grid_Craft.SelectedIndex = -1;
        Grid_Craft.EditIndex     = -1;
        BindGrid4(id4);
        UpdatePanel_SearchCraft.Update();
    }
    //检索栏检索其他按钮
    //protected void BtnSearchElse_Click(object sender, EventArgs e)
    //{
    //    Grid_ProType.Columns[3].Visible = false;
    //    Grid_ProType.Columns[4].Visible = false;
    //    Grid_ProType.Columns[5].Visible = false;
    //    Grid_ProType.Columns[6].Visible = true;
    //    LblGridProType.Text = "其他产品型号表";
    //    condSearch.Text = "QT";//以此变量存储检索栏是否处于检索其他的状态
    //    if (TxtProSeries.Text != "")
    //    {
    //        PS_Name = TxtProSeries.Text;
    //    }
    //    if (TxtProType.Text != "")
    //    {
    //        PT_Name = TxtProType.Text;
    //    }
    //    BindGrid1QT(PS_Name, PT_Name);
    //    this.UpdatePanel_GridProType.Update();
    //}

    #endregion

    #region 产品型号表Grid1
    //操作Gridview的命令行
    protected void Grid_ProType_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Edt_CFCraft")
        {
            GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
            Grid_ProType.SelectedIndex = row.RowIndex;
            GridViewRow gvr = ((GridViewRow)(((LinkButton)(e.CommandSource)).Parent.Parent));
            id2 = new Guid(e.CommandArgument.ToString());
            IQCBasicDataInfo IQC = new IQCBasicDataInfo();
            IQC             = iQCBasicDataL.Search_ProType_ID(id2)[0];
            LblRZState.Text = IQC.PT_Name;
            BindGrid2(id2);
            Panel_GridCFCraft.Visible = true;
            UpdatePanel_GridCFCraft.Update();
            Panel_CFRoute.Visible = false;
            UpdatePanel_CFRoute.Update();
            condSearch4         = "";
            LblState.Text       = "认证";                           //用“认证”标识grid4处于认证工序检索,“工艺”标识处于认证工艺路线检索
            LblGongxuState.Text = "认证";                           //用“认证”标识grid4处于认证工序编辑,“工艺”标识处于认证工艺路线编辑

            ((BoundField)Grid_Craft.Columns[1]).ReadOnly = false; //注意类型转换,你所操作的列的类型是BoundField

            ((BoundField)Grid_Craft.Columns[2]).ReadOnly = true;

            id4 = id2;
            IQCBasicDataInfo IQC1 = new IQCBasicDataInfo();
            IQC1            = iQCBasicDataL.Search_ProType_ID(id2)[0];
            LblSCState.Text = IQC1.PT_Name;
            BindGrid4(id4);
            UpdatePanel_SearchCraft.Update();
        }
        if (e.CommandName == "Edt_CFRoute")
        {
            GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
            Grid_ProType.SelectedIndex = row.RowIndex;
            GridViewRow gvr = ((GridViewRow)(((LinkButton)(e.CommandSource)).Parent.Parent));
            id3 = new Guid(e.CommandArgument.ToString());
            IQCBasicDataInfo IQC = new IQCBasicDataInfo();
            IQC             = iQCBasicDataL.Search_ProType_ID(id3)[0];
            LblRTState.Text = IQC.PT_Name;
            BindGrid3(id3);
            Panel_CFRoute.Visible = true;
            UpdatePanel_CFRoute.Update();
            Panel_GridCFCraft.Visible = false;
            UpdatePanel_GridCFCraft.Update();
            condSearch4         = "";
            LblState.Text       = "工艺";                          //用“认证”标识grid4处于认证工序检索,“工艺”标识处于认证工艺路线检索
            LblGongxuState.Text = "工艺";                          //用“认证”标识grid4处于认证工序编辑,“工艺”标识处于认证工艺路线编辑
            ((BoundField)Grid_Craft.Columns[1]).ReadOnly = true; //注意类型转换,你所操作的列的类型是BoundField

            ((BoundField)Grid_Craft.Columns[2]).ReadOnly = false;

            id4 = id3;
            IQCBasicDataInfo IQC1 = new IQCBasicDataInfo();
            IQC1            = iQCBasicDataL.Search_ProType_ID(id3)[0];
            LblSCState.Text = IQC1.PT_Name;
            BindGrid4(id4);
            UpdatePanel_SearchCraft.Update();
        }
        if (e.CommandName == "Delete_ProType")
        {
            GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
            Grid_ProType.SelectedIndex = row.RowIndex;
            Guid guid = new Guid(e.CommandArgument.ToString());
            try
            {
                iQCBasicDataL.Delete_ProType_RZ(guid);
            }
            catch (Exception exc)
            {
                ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('删除失败!" + exc + "')", true);
            }
            ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('删除成功!')", true);
            BindGrid1RZ(PS_Name, PT_Name);
            UpdatePanel_GridProType.Update();
        }
        if (e.CommandName == "Chs_ProType")
        {
            GridViewRow row = ((LinkButton)e.CommandSource).Parent.Parent as GridViewRow;
            Grid_ProType.SelectedIndex = row.RowIndex;
            Guid guid = new Guid(e.CommandArgument.ToString());
            try
            {
                iQCBasicDataL.Insert_ProType_RZ(guid);
            }
            catch (Exception exc)
            {
                ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('新增失败!" + exc + "')", true);
            }
            ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "alert", "alert('新增成功!')", true);
            BindGrid1QT(PS_Name, PT_Name);
            UpdatePanel_GridProType.Update();
        }
    }