Exemple #1
0
        protected void Button11_Click(object sender, EventArgs e)
        {
            BuildingTableAdapter bu = new BuildingTableAdapter();
            FarmTableAdapter     ff = new FarmTableAdapter();
            SensorTableAdapter   SS = new SensorTableAdapter();
            string nf  = ff.GetDataBy4(N_F1.Text).Rows[0][0].ToString();
            string inb = "B" + (Convert.ToInt32(bu.ScalarQuery1()) + 1).ToString("0000");

            Session["NewB"] = inb;

            bu.InsertQuery(inb, N_B.Text, 0, "-", S_B.Text + " m.", nf, FileUpload1.FileName.ToString(), "0", "-");
            string ins = "S" + (Convert.ToInt32(SS.ScalarQuery1()) + 1).ToString("0000");

            SS.InsertQuery(ins, "วัดอุณหภูมิ", "วัดอุณหภูมิ", "T0001", inb);
            string ins1 = "S" + (Convert.ToInt32(SS.ScalarQuery1()) + 1).ToString("0000");

            SS.InsertQuery(ins1, "วัดแอมโมเนีย", "วัดแอมโมเนีย", "T0002", inb);
            string ins2 = "S" + (Convert.ToInt32(SS.ScalarQuery1()) + 1).ToString("0000");

            SS.InsertQuery(ins2, "วัดความเร็วลม", "วัดความเร็วลม", "T0003", inb);
            string ins3 = "S" + (Convert.ToInt32(SS.ScalarQuery1()) + 1).ToString("0000");

            SS.InsertQuery(ins3, "วัดความชื้น", "วัดความชื้น", "T0004", inb);
            Page.Response.Redirect(Page.Request.Url.ToString(), true);
        }