Ejemplo n.º 1
0
    protected void Button34_Click(object sender, EventArgs e)
    {
        string fuse = DropDownList4.SelectedValue;

        if (TextBox14.Text == "" || TextBox15.Text == "" || TextBox17.Text == "")
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('标记*的为必填项,请填写完整!')", true);
            return;
        }

        if (Label35.Text == "请选择工序" || Label36.Text == "请选择物料")
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('物料或工序还未选择。')", true);
        }
        else
        {
            Guid pid = new Guid(Label34.Text);
            Guid mid = new Guid(Label38.Text);

            decimal use   = decimal.Parse(TextBox14.Text);
            decimal ruse  = decimal.Parse(TextBox15.Text);
            Guid    uid   = new Guid(DropDownList3.SelectedValue);
            Guid    bomid = new Guid(Label3.Text);
            string  note  = TextBox17.Text;
            if (Label31.Text == "新增")
            {
                //try
                //{
                string man = Session["UserName"].ToString();
                int    a   = bom.Insert_BOMDetail(bomid, pid, uid, mid, use, ruse, note, man);
                TextBox14.Text = "";
                TextBox15.Text = "";
                TextBox17.Text = "";
                Label35.Text   = "未选择工序";
                if (a == 1)
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('增加成功.')", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('已存在该BOM,新增失败.')", true);
                }
                Panel41.Visible      = false;
                GridView3.DataSource = bom.Query_BOMDetail(new Guid(Label3.Text));
                GridView3.DataBind();
                //}
                //catch
                //{
                //    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "alert", "alert('增加失败')", true);
                //}
            }
            if (Label31.Text == "修改")
            {
                //try
                //{
                FuseText.Visible      = false;
                DropDownList4.Visible = false;
                Guid   bdid = new Guid(Label33.Text);
                string man  = Session["UserName"].ToString();
                bom.Update_BOMDetail(bdid, pid, uid, mid, use, ruse, note, man);
                TextBox14.Text = "";
                TextBox15.Text = "";
                TextBox17.Text = "";
                Label35.Text   = "未选择工序";
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('修改成功')", true);
                Panel41.Visible      = false;
                GridView3.DataSource = bom.Query_BOMDetail(new Guid(Label3.Text));
                GridView3.DataBind();
                UpdatePanel4.Update();
                //}
                //catch
                //{
                //    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "alert", "alert('修改失败')", true);
                //}
            }
            if (Label31.Text == "新增可替用物料")
            {
                Guid   mateid = new Guid(Label33.Text);
                string man    = Session["UserName"].ToString();
                int    a      = bom.Insert_BOMDetailMate(bomid, mateid, pid, uid, mid, use, ruse, note, fuse, Guid.Empty, man);
                TextBox14.Text = "";
                TextBox15.Text = "";
                TextBox17.Text = "";
                Label35.Text   = "未选择工序";
                if (a > 0)
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('增加成功.')", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('已存在该BOM,新增失败.')", true);
                }
                Panel41.Visible      = false;
                GridView3.DataSource = bom.Query_BOMDetail(new Guid(Label3.Text));
                GridView3.DataBind();
                UpdatePanel4.Update();
            }
            if (Label31.Text == "新增组合物料成员")
            {
                //try
                //{
                Guid   mateid = new Guid(MateID.Text);
                Guid   fuseid = new Guid(FuseID.Text);
                string man    = Session["UserName"].ToString();
                int    a      = bom.Insert_BOMDetailMate(bomid, mateid, pid, uid, mid, use, ruse, note, fuse, fuseid, man);
                TextBox14.Text = "";
                TextBox15.Text = "";
                TextBox17.Text = "";
                Label35.Text   = "未选择工序";
                if (a > 0)
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('增加成功.')", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", "alert('已存在该BOM,新增失败.')", true);
                }
                Panel41.Visible      = false;
                GridView3.DataSource = bom.Query_BOMDetail(new Guid(Label3.Text));
                GridView3.DataBind();
                UpdatePanel4.Update();
                //}
                //catch
                //{
                //    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "alert", "alert('增加失败')", true);
                //}
            }
        }
    }