将字段从表单传递到网站上的字段

时间:2017-03-22 15:08:17

标签: winforms visual-studio communication

所以我只是一个业余爱好的程序员,自学C#,目前正在设计我自己的应用程序,以减少为我的工作做事所需的步骤数量,我有一些我想要的东西帮助一件事是我想创建更新互联网表格的字段我不确定这是否能够在两种不同的语言之间进行。

Website Elements

//When Button is Pressed Create The New Job In The Specified Location and 
//then create text files to send file attributes to.
//Future: Add the ability to also use these field attributes to update and 
//create the job folder on the website as well.

private void NewJob_Click(object sender, EventArgs e)
    {
        if (!Directory.Exists(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text))
            Directory.CreateDirectory(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text);
        if (!Directory.Exists(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\0-Submittals"))
            Directory.CreateDirectory(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\0-Submittals");
        if (!Directory.Exists(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\1-Pricing"))
            Directory.CreateDirectory(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\1-Pricing");
        if (!Directory.Exists(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\2-Take Off"))
            Directory.CreateDirectory(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\2-Take Off");
        if (!Directory.Exists(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\3-Files"))
            Directory.CreateDirectory(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\3-Files");
        if (!Directory.Exists(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\4-Plans"))
            Directory.CreateDirectory(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\4-Plans");
        if (!Directory.Exists(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\5-Specs"))
            Directory.CreateDirectory(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\5-Specs");
        if (!Directory.Exists(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\6-Emails"))
            Directory.CreateDirectory(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\6-Emails");
        if (!Directory.Exists(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\Properties"))
            Directory.CreateDirectory(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + "\\Properties");

        File.WriteAllText(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + @"\Properties\Contact.txt", lblContact.Text);
        File.WriteAllText(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + @"\Properties\JobName.txt", lblJobName.Text);
        File.WriteAllText(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + @"\Properties\BidDate.txt", lblBidDate.Text);
        File.WriteAllText(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + @"\Properties\Engineer.txt", lblEngineer.Text);
        File.WriteAllText(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + @"\Properties\TakeOff.txt", lblTakeOff.Text);
        File.WriteAllText(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + @"\Properties\Received.txt", lblReceived.Text);
        File.WriteAllText(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + @"\Properties\Vendor.txt", lblVendor.Text);
        File.WriteAllText(@textBox1.Text + "\\" + lblBidDate.Text + " - " + lblJobName.Text + @"\Properties\Notes.txt", lblNotes.Text);

    }

另一个问题是当您右键单击用作文件资源管理器的Web浏览器而不删除防火墙时,如何删除此错误。 Photo of the security Message

提前谢谢。

1 个答案:

答案 0 :(得分:0)

我想通了

private void Generate_Click(object sender,EventArgs e)         {

        if (lblContact.Text.Contains("name0"))
            lblContact.Text.Replace("name0", "7");


        HtmlDocument doc = wbNewProject.Document;
        HtmlElement wbJobName = doc.GetElementById("Name"); //lblcontact.text
        HtmlElement wbEngineer = doc.GetElementById("engineer-lookup"); //
        HtmlElement wbSalesEng = doc.GetElementById("SalesEngineerUserId");
        HtmlElement wbLocation = doc.GetElementById("Location");
        HtmlElement wbBidDate = doc.GetElementById("BidDate");
        HtmlElement wbPriorApproval = doc.GetElementById("PriorApproval"); //True or False
        HtmlElement wbTakeOff = doc.GetElementById("TakeOffComplete"); //True or False
        HtmlElement wbProject = doc.GetElementById("RoleType"); //Design/Build or Plan/Spec
        wbJobName.SetAttribute("value", lblJobName.Text);

        if (lblContact.Text.Contains("Name1"))
            wbSalesEng.SetAttribute("value", "2");
        if (lblContact.Text.Contains("name2"))
            wbSalesEng.SetAttribute("value", "3");
        if (lblContact.Text.Contains("name3"))
            wbSalesEng.SetAttribute("value", "4");
        if (lblContact.Text.Contains("name4"))
            wbSalesEng.SetAttribute("value", "5");
        if (lblContact.Text.Contains("name5"))
            wbSalesEng.SetAttribute("value", "6");
        if (lblContact.Text.Contains("name6"))
            wbSalesEng.SetAttribute("value", "7");
        if (lblContact.Text.Contains("name7"))
            wbSalesEng.SetAttribute("value", "10");
        if (lblContact.Text.Contains("name8"))
            wbSalesEng.SetAttribute("value", "11");
        if (lblContact.Text.Contains("name9"))
            wbSalesEng.SetAttribute("value", "12");

        wbLocation.SetAttribute("value", lblLocation.Text);
        wbBidDate.SetAttribute("value", lblBidDate.Text);

        if (lblPriorApp.Text.Contains("Yes"))
        wbPriorApproval.SetAttribute("value", "true");
        if (lblPriorApp.Text.Contains("No"))
            wbPriorApproval.SetAttribute("value", "false");
        if (lblTakeOff.Text.Contains("Done"))
        wbTakeOff.SetAttribute("value", "true");
        if (lblTakeOff.Text.Contains("Not Done"))
            wbTakeOff.SetAttribute("value", "false");

        wbEngineer.SetAttribute("value", lblEngineer.Text);
        wbProject.SetAttribute("value", lblProject.Text);
    }