//新建物料名称明细,打开对应panel
 protected void CreateMatBasicData(object sender, EventArgs e)
 {
     try
     {
         if (Label17.Text == "检索的")
         {
             ScriptManager.RegisterClientScriptBlock(UpdatePanel_MaterBasicData, GetType(), "alert", "alert('在检索结果的情况下无法新建物料名称明细,请从物料类型表中点击 查看具体物料名称 进行操作!')", true);
         }
         else
         {
             label1_PanelMatBasicState.Text = "新建";
             Panel_MatBasicDataNew.Visible  = true;
             DropDownList2.SelectedValue    = label_mattypeid.Text.ToString();
             DropDownList2.Enabled          = false;
             TextBox_matnamenew.Text        = "";
             TextBox_matmodelnew.Text       = "";
             TextBox_safenew.Text           = "";
             //this.DropDownList4.SelectedValue = "";
             TextBox14.Text    = "1";
             TextBox14.Enabled = false;
             TextBox3.Text     = "";
             TextBox1.Text     = "";
             UpdatePanel_MatBasicDataNew.Update();
         }
     }
     catch (Exception)
     {
         Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('you make some mistakes ');</script>");
     }
 }
 //点击gridview链接的操作。
 protected void GridView_MatBasicData_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Edit2")
     //编辑
     {
         Panel_MatBasicDataNew.Visible  = true;
         label1_PanelMatBasicState.Text = "修改";
         Label19.Text = "修改";
         UpdatePanel_MatBasicDataNew.Update();
         label1_BasicID.Text = e.CommandArgument.ToString();
         Guid      id = new Guid(label1_BasicID.Text.ToString());
         DataSet   ds = mat.Select_IMMaterialBasicData_One(id);
         DataTable dt = ds.Tables[0];
         BindDropDownList2();
         BindDropdownList();
         //this.DropDownList2.SelectedItem.Text = dt.Rows[0][0].ToString();
         DropDownList2.SelectedValue = dt.Rows[0][0].ToString();
         TextBox14.Text              = "1";
         TextBox14.Enabled           = true;
         TextBox_matnamenew.Text     = dt.Rows[0][1].ToString();
         TextBox_matmodelnew.Text    = dt.Rows[0][2].ToString();
         TextBox_safenew.Text        = dt.Rows[0][3].ToString();
         DropDownList4.SelectedValue = dt.Rows[0][9].ToString();
         TextBox3.Text = dt.Rows[0][5].ToString();
         TextBox5.Text = dt.Rows[0][10].ToString();
         TextBox8.Text = dt.Rows[0][13].ToString();
         TextBox6.Text = dt.Rows[0][11].ToString();
         TextBox7.Text = dt.Rows[0][12].ToString();
         //this.DropDownList3.SelectedItem.Text = dt.Rows[0][6].ToString();
         if (dt.Rows[0][6].ToString() == "")
         {
             DropDownList3.SelectedValue = "否";
         }
         else
         {
             DropDownList3.SelectedValue = dt.Rows[0][6].ToString();
         }
         TextBox1.Text       = dt.Rows[0][7].ToString();
         TextBox4.Text       = dt.Rows[0][8].ToString();
         label1_BasicID.Text = e.CommandArgument.ToString();
         //ScriptManager.RegisterClientScriptBlock(this.UpdatePanel_MatBasicDataNew, this.GetType(), "alert", "alert('必须重新选择物料类型和有害物质选项!')", true);
     }
     if (e.CommandName == "Delete2")
     //删除物料明细
     {
         string iid = e.CommandArgument.ToString();
         Guid   id  = new Guid(iid);
         mat.Delete_MaterialBasicData(id);
         if (Label_BasicData_Source.Text == "Gridview数据源")
         {
             BindGridView_MatBasicData_Gridview(label_mattypeid.ToString());
         }
         if (Label_BasicData_Source.Text == "模糊查询数据源")
         {
             BindGridView_MatBasicData_Serarch(GetCondition());
         }
         UpdatePanel_MaterBasicData.Update();
     }
 }
 //关闭对应的新建物料明细panel、
 protected void CanelMatBasicDataNew(object sender, EventArgs e)
 {
     try
     {
         Panel_MatBasicDataNew.Visible = false;
         UpdatePanel_MatBasicDataNew.Update();
     }
     catch (Exception)
     {
         Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('you make some mistakes ');</script>");
     }
 }
    //新建物料类型-确认
    protected void ConfirmMatTypeNew(object sender, EventArgs e)
    {
        //try
        //{
        string mattypename = TextBox_NewTypeName.Text.ToString();
        string comment     = TextArea1.InnerText.ToString();

        if (TextBox_NewTypeName.Text.ToString() == "")
        {
            ScriptManager.RegisterClientScriptBlock(UpdatePanel_MatTypeNew, GetType(), "alert", "alert('必须填写物料名称')", true);
            return;
        }
        int temp = mat.Select_IMMaterialTypeRepeat(mattypename);

        if (temp != 0)
        {
            ScriptManager.RegisterClientScriptBlock(UpdatePanel_MatTypeNew, GetType(), "alert", "alert('物料类型名称重复,不可以添加!')", true);
            return;
        }
        mat.Insert_MaterialType(mattypename, comment);
        BindGridView_MatType();
        UpdatePanel_MatType.Update();
        TextBox_NewTypeName.Text = "";
        TextArea1.InnerText      = "";
        Panel_MatTypeNew.Visible = false;
        UpdatePanel_MatTypeNew.Update();
        BindDropDownList1();
        BindDropDownList2();
        UpdatePanel_Search.Update();
        UpdatePanel_MatBasicDataNew.Update();
        ScriptManager.RegisterClientScriptBlock(UpdatePanel_MatTypeNew, GetType(), "alert", "alert('提交成功!')", true);
        //}
        //catch (Exception)
        //{
        //    Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('you make some mistakes ');</script>");
        //}
    }
    //新建物料名称-确认
    protected void ConfirmMatBasicDataNew(object sender, EventArgs e)
    {
        try
        {
            string id = label1_BasicID.Text.ToString();
            Guid   matid;
            if (DropDownList2.SelectedItem.Text == "选择物料类型")
            {
                ScriptManager.RegisterClientScriptBlock(UpdatePanel_MatBasicDataNew, GetType(), "alert", "alert('请选择对应的物料类别!')", true);
                return;
            }

            if (TextBox_matnamenew.Text.ToString() == "")
            {
                ScriptManager.RegisterClientScriptBlock(UpdatePanel_MatBasicDataNew, GetType(), "alert", "alert('请填写物料名称!')", true);
                return;
            }

            Guid    mattypeid = new Guid(DropDownList2.SelectedValue.ToString());
            string  matname   = TextBox_matnamenew.Text.ToString();
            string  model     = TextBox_matmodelnew.Text.ToString();
            decimal safe;

            if (TextBox_safenew.Text == "")
            {
                safe = Convert.ToDecimal(0);
            }
            else
            {
                safe = Convert.ToDecimal(TextBox_safenew.Text.ToString());
            }
            int storageday;
            if (TextBox3.Text.ToString() == "")
            {
                storageday = Convert.ToInt32(null);
            }
            else
            {
                storageday = Convert.ToInt32(TextBox3.Text.ToString());
            }
            int pianshu;
            if (TextBox8.Text == "")
            {
                pianshu = 0;
            }
            else
            {
                pianshu = Convert.ToInt32(TextBox8.Text.ToString());
            }
            decimal zhuanrate;
            if (TextBox6.Text == "")
            {
                zhuanrate = 0;
            }
            else
            {
                zhuanrate = Convert.ToDecimal(TextBox6.Text.ToString());
            }
            decimal peiweight;

            if (TextBox7.Text == "")
            {
                peiweight = 0;
            }
            else
            {
                peiweight = Convert.ToDecimal(TextBox7.Text.ToString());
            }

            string  harm    = DropDownList3.SelectedItem.ToString();
            Guid    unit    = new Guid(DropDownList4.SelectedValue.ToString());
            string  comment = TextBox4.Text.ToString();
            string  para    = TextBox1.Text.ToString();
            decimal rate    = Convert.ToDecimal(TextBox14.Text.ToString());
            string  code    = TextBox5.Text.ToString();
            if (label1_PanelMatBasicState.Text == "新建")
            {
                int temp = mat.Select_IMMaterialBasicRepeat(matname, model);
                if (temp != 0)
                {
                    ScriptManager.RegisterClientScriptBlock(UpdatePanel_MatBasicDataNew, GetType(), "alert", "alert('物料名称和规格型号重复,不可以添加!')", true);
                    return;
                }
            }
            if (label1_PanelMatBasicState.Text == "新建")
            {
                mat.Insert_MaterialBasicData(mattypeid, matname, model, safe, storageday, harm, unit, comment, para, code, pianshu, zhuanrate, peiweight);
            }
            if (label1_PanelMatBasicState.Text == "修改")
            {
                matid = new Guid(label1_BasicID.Text.ToString());
                mat.Update_MaterialBasicData(matid, mattypeid, matname, model, safe, storageday, harm, unit, comment, para, rate, code, pianshu, zhuanrate, peiweight);
            }
            if (Label_BasicData_Source.Text == "Gridview数据源")
            {
                BindGridView_MatBasicData_Gridview(label_mattypeid.Text.ToString());
            }
            if (Label_BasicData_Source.Text == "模糊查询数据源")
            {
                BindGridView_MatBasicData_Serarch(labelcodition.Text.ToString());
            }
            UpdatePanel_MaterBasicData.Update();
            Panel_MatBasicDataNew.Visible = false;
            TextBox_matnamenew.Text       = "";
            TextBox_matmodelnew.Text      = "";
            TextBox_safenew.Text          = "";
            TextBox3.Text = "";
            TextBox1.Text = "";
            TextBox4.Text = "";
            UpdatePanel_MatBasicDataNew.Update();
            ScriptManager.RegisterClientScriptBlock(UpdatePanel_MatBasicDataNew, GetType(), "alert", "alert('提交成功!')", true);
        }
        catch (Exception)
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('you make some mistakes ');</script>");
        }
    }