예제 #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);
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BuildingTableAdapter    bu  = new BuildingTableAdapter();
            SensorTableAdapter      ss  = new SensorTableAdapter();
            Type_sensorTableAdapter Tys = new Type_sensorTableAdapter();

            if (Request.QueryString["NameFarm"] != null)
            {
                //  Label1.Text = " : " + Request.QueryString["NameFarm"].ToString();
                Label2.Text = Request.QueryString["NameBu"].ToString();
                Label3.Text = "ชื่อเจ้าหน้าที่ : " + Request.QueryString["NameOF"].ToString();

                Session["S_Bu"] = bu.GetDataBy2(Request.QueryString["NameBu"].ToString()).Rows[0][4].ToString();
                string idbu = bu.GetDataBy2(Request.QueryString["NameBu"].ToString()).Rows[0][0].ToString();
                Session["ID_Bu"] = idbu;
                int ns = Convert.ToInt32(ss.ScalarQuery(idbu));
                Session["fr"]      = ns;
                Session["Pic_bui"] = bu.GetDataBy2(Request.QueryString["NameBu"].ToString()).Rows[0][6].ToString();
                for (int i = 0; i < ns; i++)
                {
                    Session["ID_Sensor" + i]   = ss.GetDataBy1(idbu).Rows[i][0].ToString();
                    Session["Name_Sensor" + i] = ss.GetDataBy1(idbu).Rows[i][1].ToString();
                    Session["Type_Sensor" + i] = ss.GetDataBy1(idbu).Rows[i][3].ToString();
                    Session["Unit_Ty" + i]     = Tys.GetDataBy(Session["Type_Sensor" + i].ToString()).Rows[0][2].ToString();
                }
                Session["In_Ch"] = bu.GetDataBy2(Request.QueryString["NameBu"].ToString()).Rows[0][2].ToString();
                Session["ChhhD"] = bu.GetDataBy2(Request.QueryString["NameBu"].ToString()).Rows[0][9].ToString();
                Label1.Text      = bu.GetDataBy2(Request.QueryString["NameBu"].ToString()).Rows[0][9].ToString() + " ตัว";
            }
            else
            {
            }
        }
예제 #3
0
        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            BuildingTableAdapter    buu = new BuildingTableAdapter();
            SensorTableAdapter      ssn = new SensorTableAdapter();
            Type_sensorTableAdapter tys = new Type_sensorTableAdapter();
            string idbu = buu.GetDataBy2(DropDownList2.SelectedItem.Text).Rows[0][0].ToString();
            int    iss  = Convert.ToInt32(ssn.ScalarQuery(idbu));

            Session["iss"] = iss;
            for (int i = 0; i < iss; i++)
            {
                Session["name_sensor" + i] = ssn.GetDataBy1(idbu).Rows[i][1].ToString();
                Session["de_sensor" + i]   = ssn.GetDataBy1(idbu).Rows[i][2].ToString();
                string dd = ssn.GetDataBy1(idbu).Rows[i][3].ToString();
                Session["idtype_sensor" + i] = dd;
                Session["type_sensor" + i]   = tys.GetDataBy(dd).Rows[0][1].ToString();
                Session["unit_sensor" + i]   = tys.GetDataBy(dd).Rows[0][2].ToString();
            }
        }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Name_Login"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            FarmTableAdapter     Fr   = new FarmTableAdapter();
            BuildingTableAdapter bui  = new BuildingTableAdapter();
            SensorTableAdapter   sen  = new SensorTableAdapter();
            OfficerTableAdapter  offi = new OfficerTableAdapter();
            FarmerTableAdapter   ffff = new FarmerTableAdapter();
            string idf = Session["ID_Login"].ToString();

            idf = idf.Substring(0, 1);
            if (idf == "F")
            {
                int nFr1 = Convert.ToInt32(Fr.ScalarQuery(Session["ID_Login"].ToString()));
                Session["nFrNav"] = nFr1;

                for (int ii = 0; ii < nFr1; ii++)
                {
                    Session["idFarmNav" + ii]   = Fr.GetDataBy5(Session["ID_Login"].ToString()).Rows[ii][0].ToString();
                    Session["nameFarmNav" + ii] = Fr.GetDataBy5(Session["ID_Login"].ToString()).Rows[ii][1].ToString();
                    string OFFFf = Fr.GetDataBy5(Session["ID_Login"].ToString()).Rows[ii][4].ToString();
                    Session["nameOfNav" + ii] = offi.GetDataBy3(OFFFf).Rows[0][2].ToString();

                    int nBu1 = Convert.ToInt32(bui.ScalarQuery(Session["idFarmNav" + ii].ToString()));
                    Session["nBuNav" + ii] = nBu1;
                    //string[,] idBuiPro = new string[,] { };
                    //string[,] nameBuiPro = new string[,] { };
                    for (int iii = 0; iii < nBu1; iii++)
                    {
                        Session["idBuiNav[" + ii + "," + iii + "]"]   = bui.GetDataBy1(Session["idFarmNav" + ii].ToString()).Rows[iii][0].ToString();
                        Session["nameBuiNav[" + ii + "," + iii + "]"] = bui.GetDataBy1(Session["idFarmNav" + ii].ToString()).Rows[iii][1].ToString();

                        int nSe1 = Convert.ToInt32(sen.ScalarQuery(Session["idBuiNav[" + ii + "," + iii + "]"].ToString()));
                        // int[,] nSe1 = new int[,] { };
                        Session["nSe1Nav[" + ii + "," + iii + "]"] = nSe1;

                        for (int iiii = 0; iiii < nSe1; iiii++)
                        {
                            Session["idSenNav" + ii + "," + iii + "," + iiii]   = sen.GetDataBy1(Session["idBuiNav[" + ii + "," + iii + "]"].ToString()).Rows[iiii][0].ToString();
                            Session["nameSenNav" + ii + "," + iii + "," + iiii] = sen.GetDataBy1(Session["idBuiNav[" + ii + "," + iii + "]"].ToString()).Rows[iiii][1].ToString();
                        }
                    }
                }
            }
            else
            {
                int nFr1 = Convert.ToInt32(Fr.ScalarQuery1(Session["ID_Login"].ToString()));
                Session["nFrNav"] = nFr1;

                for (int ii = 0; ii < nFr1; ii++)
                {
                    Session["idFarmNav" + ii]   = Fr.GetDataBy3(Session["ID_Login"].ToString()).Rows[ii][0].ToString();
                    Session["nameFarmNav" + ii] = Fr.GetDataBy3(Session["ID_Login"].ToString()).Rows[ii][1].ToString();
                    string OFFFf = Fr.GetDataBy3(Session["ID_Login"].ToString()).Rows[ii][3].ToString();
                    Session["nameFrrNav" + ii] = ffff.GetDataBy3(OFFFf).Rows[0][2].ToString();

                    int nBu1 = Convert.ToInt32(bui.ScalarQuery(Session["idFarmNav" + ii].ToString()));
                    Session["nBuNav" + ii] = nBu1;
                    //string[,] idBuiPro = new string[,] { };
                    //string[,] nameBuiPro = new string[,] { };
                    for (int iii = 0; iii < nBu1; iii++)
                    {
                        Session["idBuiNav[" + ii + "," + iii + "]"]   = bui.GetDataBy1(Session["idFarmNav" + ii].ToString()).Rows[iii][0].ToString();
                        Session["nameBuiNav[" + ii + "," + iii + "]"] = bui.GetDataBy1(Session["idFarmNav" + ii].ToString()).Rows[iii][1].ToString();

                        int nSe1 = Convert.ToInt32(sen.ScalarQuery(Session["idBuiNav[" + ii + "," + iii + "]"].ToString()));
                        // int[,] nSe1 = new int[,] { };
                        Session["nSe1Nav[" + ii + "," + iii + "]"] = nSe1;

                        for (int iiii = 0; iiii < nSe1; iiii++)
                        {
                            Session["idSenNav" + ii + "," + iii + "," + iiii]   = sen.GetDataBy1(Session["idBuiNav[" + ii + "," + iii + "]"].ToString()).Rows[iiii][0].ToString();
                            Session["nameSenNav" + ii + "," + iii + "," + iiii] = sen.GetDataBy1(Session["idBuiNav[" + ii + "," + iii + "]"].ToString()).Rows[iiii][1].ToString();
                        }
                    }
                }
            }
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["ID_Login"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            string idf = Session["ID_Login"].ToString();

            idf = idf.Substring(0, 1);

            FarmTableAdapter     Fr   = new FarmTableAdapter();
            BuildingTableAdapter bui  = new BuildingTableAdapter();
            SensorTableAdapter   sen  = new SensorTableAdapter();
            OfficerTableAdapter  offi = new OfficerTableAdapter();
            FarmerTableAdapter   fff  = new FarmerTableAdapter();

            if (idf == "F")
            {
                int nFr = Convert.ToInt32(Fr.ScalarQuery(Session["ID_Login"].ToString()));
                Session["nFr"] = nFr;
                for (int i = 0; i < nFr; i++)
                {
                    Session["idFarmPro" + i]   = Fr.GetDataBy2(Session["ID_Login"].ToString()).Rows[i][0].ToString();
                    Session["nameFarmPro" + i] = Fr.GetDataBy2(Session["ID_Login"].ToString()).Rows[i][1].ToString();
                    string OFFF = Fr.GetDataBy2(Session["ID_Login"].ToString()).Rows[i][4].ToString();
                    Session["nameOfPro" + i] = offi.GetDataBy3(OFFF).Rows[0][2].ToString();

                    int nBu = Convert.ToInt32(bui.ScalarQuery(Session["idFarmPro" + i].ToString()));
                    Session["nBu" + i] = nBu;
                    //string[,] idBuiPro = new string[,] { };
                    //string[,] nameBuiPro = new string[,] { };
                    for (int i1 = 0; i1 < nBu; i1++)
                    {
                        Session["idBuiPro[" + i + "," + i1 + "]"]   = bui.GetDataBy1(Session["idFarmPro" + i].ToString()).Rows[i1][0].ToString();
                        Session["nameBuiPro[" + i + "," + i1 + "]"] = bui.GetDataBy1(Session["idFarmPro" + i].ToString()).Rows[i1][1].ToString();

                        int nSe = Convert.ToInt32(sen.ScalarQuery(Session["idBuiPro[" + i + "," + i1 + "]"].ToString()));
                        // int[,] nSe1 = new int[,] { };
                        Session["nSe1[" + i + "," + i1 + "]"]     = nSe;
                        Session["Pic_buii[" + i + "," + i1 + "]"] = bui.GetDataBy1(Session["idFarmPro" + i].ToString()).Rows[i1][6].ToString();
                        for (int i2 = 0; i2 < nSe; i2++)
                        {
                            Session["idSenPro" + i + "," + i1 + "," + i2]   = sen.GetDataBy1(Session["idBuiPro[" + i + "," + i1 + "]"].ToString()).Rows[i2][0].ToString();
                            Session["nameSenPro" + i + "," + i1 + "," + i2] = sen.GetDataBy1(Session["idBuiPro[" + i + "," + i1 + "]"].ToString()).Rows[i2][1].ToString();
                        }
                    }
                }
            }
            else
            {
                int nFr = Convert.ToInt32(Fr.ScalarQuery1(Session["ID_Login"].ToString()));
                Session["nFr"] = nFr;
                for (int i = 0; i < nFr; i++)
                {
                    Session["idFarmPro" + i]   = Fr.GetDataBy3(Session["ID_Login"].ToString()).Rows[i][0].ToString();
                    Session["nameFarmPro" + i] = Fr.GetDataBy3(Session["ID_Login"].ToString()).Rows[i][1].ToString();
                    string OFFF = Fr.GetDataBy3(Session["ID_Login"].ToString()).Rows[i][3].ToString();
                    Session["nameOfPro" + i] = fff.GetDataBy3(OFFF).Rows[0][1].ToString();

                    int nBu = Convert.ToInt32(bui.ScalarQuery(Session["idFarmPro" + i].ToString()));
                    Session["nBu" + i] = nBu;
                    //string[,] idBuiPro = new string[,] { };
                    //string[,] nameBuiPro = new string[,] { };
                    for (int i1 = 0; i1 < nBu; i1++)
                    {
                        Session["idBuiPro[" + i + "," + i1 + "]"]   = bui.GetDataBy1(Session["idFarmPro" + i].ToString()).Rows[i1][0].ToString();
                        Session["nameBuiPro[" + i + "," + i1 + "]"] = bui.GetDataBy1(Session["idFarmPro" + i].ToString()).Rows[i1][1].ToString();

                        int nSe = Convert.ToInt32(sen.ScalarQuery(Session["idBuiPro[" + i + "," + i1 + "]"].ToString()));
                        // int[,] nSe1 = new int[,] { };
                        Session["nSe1[" + i + "," + i1 + "]"]     = nSe;
                        Session["Pic_buii[" + i + "," + i1 + "]"] = bui.GetDataBy1(Session["idFarmPro" + i].ToString()).Rows[i1][6].ToString();
                        for (int i2 = 0; i2 < nSe; i2++)
                        {
                            Session["idSenPro" + i + "," + i1 + "," + i2]   = sen.GetDataBy1(Session["idBuiPro[" + i + "," + i1 + "]"].ToString()).Rows[i2][0].ToString();
                            Session["nameSenPro" + i + "," + i1 + "," + i2] = sen.GetDataBy1(Session["idBuiPro[" + i + "," + i1 + "]"].ToString()).Rows[i2][1].ToString();
                        }
                    }
                }
            }
        }
예제 #6
0
        protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
        {
            Chicken_raisingTableAdapter        chh = new Chicken_raisingTableAdapter();
            Detail_Chicken_raisingTableAdapter dch = new Detail_Chicken_raisingTableAdapter();
            SensorTableAdapter sen = new SensorTableAdapter();

            if (DropDownList3.SelectedItem.Text != "รอบการเลี้ยงปัจจุบัน")
            {
                string idChh = chh.GetDataBy4(DropDownList3.SelectedItem.Text).Rows[0][0].ToString();

                Session["N_F_R"] = chh.GetDataBy4(DropDownList3.SelectedItem.Text).Rows[0][4].ToString();
                Session["A_F_R"] = chh.GetDataBy4(DropDownList3.SelectedItem.Text).Rows[0][5].ToString();

                Session["N_Fr_R"] = chh.GetDataBy4(DropDownList3.SelectedItem.Text).Rows[0][2].ToString();
                Session["N_Of_R"] = chh.GetDataBy4(DropDownList3.SelectedItem.Text).Rows[0][3].ToString();

                Session["N_B_R"]   = chh.GetDataBy4(DropDownList3.SelectedItem.Text).Rows[0][6].ToString();
                Session["Nm_Ch_R"] = chh.GetDataBy4(DropDownList3.SelectedItem.Text).Rows[0][8].ToString();
                Session["T_Ch_R"]  = chh.GetDataBy4(DropDownList3.SelectedItem.Text).Rows[0][9].ToString();
                Session["S_B_R"]   = chh.GetDataBy4(DropDownList3.SelectedItem.Text).Rows[0][7].ToString();
                Session["D_Ch_R"]  = chh.GetDataBy4(DropDownList3.SelectedItem.Text).Rows[0][10].ToString();
                Session["S_Ch_R"]  = chh.GetDataBy4(DropDownList3.SelectedItem.Text).Rows[0][11].ToString();
                Session["T_D_R"]   = chh.GetDataBy4(DropDownList3.SelectedItem.Text).Rows[0][12].ToString();
                int numA1 = 0;
                //int numA2 = 0;
                //int numA3 = 0;
                //int numA4 = 0;
                //int numA5 = 0;
                //int numA6 = 0;
                //int numA7 = 0;
                for (int ii = 1; ii <= 42; ii++)
                {
                    if (dch.ScalarQuery(idChh, ii.ToString()).ToString() != "")
                    {
                        numA1 = Convert.ToInt32(dch.ScalarQuery(idChh, ii.ToString()).ToString());
                        Session["A1" + ii.ToString()] = numA1;
                        for (int i = 0; i < numA1; i++)
                        {
                            string idspr = dch.GetDataBy3(idChh, ii.ToString()).Rows[i][2].ToString();
                            Session["N_S_RP1" + ii.ToString() + "," + i] = sen.GetDataBy3(idspr).Rows[0][1].ToString();
                            Session["P_P_RP1" + ii.ToString() + "," + i] = dch.GetDataBy3(idChh, ii.ToString()).Rows[i][3].ToString();
                            Session["T_P_RP1" + ii.ToString() + "," + i] = dch.GetDataBy3(idChh, ii.ToString()).Rows[i][4].ToString();
                            Session["R_P_RP1" + ii.ToString() + "," + i] = dch.GetDataBy3(idChh, ii.ToString()).Rows[i][5].ToString();
                            Session["S_P_RP1" + ii.ToString() + "," + i] = dch.GetDataBy3(idChh, ii.ToString()).Rows[i][7].ToString();
                            Session["D_P_RP1" + ii.ToString() + "," + i] = dch.GetDataBy3(idChh, ii.ToString()).Rows[i][9].ToString();
                        }
                    }
                }

                //if (dch.ScalarQuery(idChh, "2").ToString() != "")
                //{
                //    numA2 = Convert.ToInt32(dch.ScalarQuery(idChh, "2").ToString());
                //    Session["A2"] = numA2;

                //    for (int i1 = 0; i1 < numA2; i1++)
                //    {
                //        string idspr1 = dch.GetDataBy3(idChh, "1").Rows[i1][2].ToString();
                //        Session["N_S_RP2" + i1] = sen.GetDataBy3(idspr1).Rows[0][1].ToString();
                //        Session["P_P_RP2" + i1] = dch.GetDataBy3(idChh, "2").Rows[i1][3].ToString();
                //        Session["T_P_RP1" + i1] = dch.GetDataBy3(idChh, "2").Rows[i1][4].ToString();
                //        Session["R_P_RP1" + i1] = dch.GetDataBy3(idChh, "2").Rows[i1][5].ToString();
                //        Session["S_P_RP1" + i1] = dch.GetDataBy3(idChh, "2").Rows[i1][7].ToString();
                //        Session["D_P_RP1" + i1] = dch.GetDataBy3(idChh, "2").Rows[i1][9].ToString();
                //    }
                //}
                //if (dch.ScalarQuery(idChh, "3").ToString() != "")
                //{
                //    numA3 = Convert.ToInt32(dch.ScalarQuery(idChh, "3").ToString());
                //}
                //if (dch.ScalarQuery(idChh, "4").ToString() != "")
                //{
                //    numA4 = Convert.ToInt32(dch.ScalarQuery(idChh, "4").ToString());
                //}
                //if (dch.ScalarQuery(idChh, "5").ToString() != "")
                //{
                //    numA5 = Convert.ToInt32(dch.ScalarQuery(idChh, "5").ToString());
                //}
                //if (dch.ScalarQuery(idChh, "6").ToString() != "")
                //{
                //    numA6 = Convert.ToInt32(dch.ScalarQuery(idChh, "6").ToString());
                //}
                //if (dch.ScalarQuery(idChh, "7").ToString() != "")
                //{
                //    numA7 = Convert.ToInt32(dch.ScalarQuery(idChh, "7").ToString());
                //}
                ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script language=javascript>myfunction1();</script>");
            }
            else
            {
                BuildingTableAdapter          bu     = new BuildingTableAdapter();
                FarmTableAdapter              Farmm  = new FarmTableAdapter();
                FarmerTableAdapter            farmer = new FarmerTableAdapter();
                OfficerTableAdapter           ofii   = new OfficerTableAdapter();
                Problem_recommendTableAdapter pro    = new Problem_recommendTableAdapter();

                Session["N_F_R"] = Farmm.GetDataBy4(DropDownList1.SelectedItem.Text).Rows[0][1].ToString();
                Session["A_F_R"] = Farmm.GetDataBy4(DropDownList1.SelectedItem.Text).Rows[0][2].ToString();
                string idfr = Farmm.GetDataBy4(DropDownList1.SelectedItem.Text).Rows[0][3].ToString();
                string idof = Farmm.GetDataBy4(DropDownList1.SelectedItem.Text).Rows[0][4].ToString();
                Session["N_Fr_R"] = farmer.GetDataBy3(idfr).Rows[0][1].ToString();
                Session["N_Of_R"] = ofii.GetDataBy3(idof).Rows[0][2].ToString();
                string idb = bu.GetDataBy2(DropDownList2.SelectedItem.Text).Rows[0][0].ToString();
                Session["N_B_R"]   = bu.GetDataBy2(DropDownList2.SelectedItem.Text).Rows[0][1].ToString();
                Session["Nm_Ch_R"] = bu.GetDataBy2(DropDownList2.SelectedItem.Text).Rows[0][2].ToString();
                Session["T_Ch_R"]  = bu.GetDataBy2(DropDownList2.SelectedItem.Text).Rows[0][3].ToString();
                Session["S_B_R"]   = bu.GetDataBy2(DropDownList2.SelectedItem.Text).Rows[0][4].ToString();
                int numA1 = 0;
                //int numA2 = 0;
                //int numA3 = 0;
                //int numA4 = 0;
                //int numA5 = 0;
                //int numA6 = 0;
                //int numA7 = 0;
                for (int ii = 1; ii <= 42; ii++)
                {
                    if (pro.ScalarQuery2(ii.ToString()).ToString() != "")
                    {
                        numA1 = Convert.ToInt32(pro.ScalarQuery2(ii.ToString()).ToString());
                        Session["A1" + ii.ToString()] = numA1;
                        for (int i = 0; i < numA1; i++)
                        {
                            string idspr = pro.GetDataBy5(ii.ToString()).Rows[i][1].ToString();
                            Session["N_S_RP1" + ii.ToString() + "," + i] = sen.GetDataBy3(idspr).Rows[0][1].ToString();
                            Session["P_P_RP1" + ii.ToString() + "," + i] = pro.GetDataBy5(ii.ToString()).Rows[i][2].ToString();
                            Session["T_P_RP1" + ii.ToString() + "," + i] = pro.GetDataBy5(ii.ToString()).Rows[i][3].ToString();
                            Session["R_P_RP1" + ii.ToString() + "," + i] = pro.GetDataBy5(ii.ToString()).Rows[i][4].ToString();
                            Session["S_P_RP1" + ii.ToString() + "," + i] = pro.GetDataBy5(ii.ToString()).Rows[i][6].ToString();
                            Session["D_P_RP1" + ii.ToString() + "," + i] = pro.GetDataBy5(ii.ToString()).Rows[i][8].ToString();
                        }
                    }
                }
                //if (pro.ScalarQuery2("2").ToString() != "")
                //{
                //    numA2 = Convert.ToInt32(pro.ScalarQuery2("2").ToString());
                //    Session["A2"] = numA2;

                //    for (int i1 = 0; i1 < numA2; i1++)
                //    {
                //        string idspr1 = pro.GetDataBy5("2").Rows[i1][1].ToString();
                //        Session["N_S_RP2" + i1] = sen.GetDataBy3(idspr1).Rows[0][1].ToString();
                //        Session["P_P_RP2" + i1] = pro.GetDataBy5("2").Rows[i1][2].ToString();
                //        Session["T_P_RP2" + i1] = pro.GetDataBy5("2").Rows[i1][3].ToString();
                //        Session["R_P_RP2" + i1] = pro.GetDataBy5("2").Rows[i1][4].ToString();
                //        Session["S_P_RP2" + i1] = pro.GetDataBy5("2").Rows[i1][6].ToString();
                //        Session["D_P_RP2" + i1] = pro.GetDataBy5("2").Rows[i1][8].ToString();
                //    }
                //}
                //if (pro.ScalarQuery2("3").ToString() != "")
                //{
                //    numA3 = Convert.ToInt32(pro.ScalarQuery2("3").ToString());
                //}
                //if (pro.ScalarQuery2("4").ToString() != "")
                //{
                //    numA4 = Convert.ToInt32(pro.ScalarQuery2("4").ToString());
                //}
                //if (pro.ScalarQuery2("5").ToString() != "")
                //{
                //    numA5 = Convert.ToInt32(pro.ScalarQuery2("5").ToString());
                //}
                //if (pro.ScalarQuery2("6").ToString() != "")
                //{
                //    numA6 = Convert.ToInt32(pro.ScalarQuery2("6").ToString());
                //}
                //if (pro.ScalarQuery2("7").ToString() != "")
                //{
                //    numA7 = Convert.ToInt32(pro.ScalarQuery2("7").ToString());
                //}
                ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script language=javascript>myfunction();</script>");
            }
        }
예제 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            FarmTableAdapter     Farmm  = new FarmTableAdapter();
            OfficerTableAdapter  ofii   = new OfficerTableAdapter();
            FarmerTableAdapter   farmer = new FarmerTableAdapter();
            BuildingTableAdapter bu     = new BuildingTableAdapter();

            if (Session["ID_Login"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            for (int ii = 1; ii <= 42; ii++)
            {
                Session["A1" + ii.ToString()] = "0";
            }
            Session["A2"]     = "0";
            Session["N_F_R"]  = "";
            Session["A_F_R"]  = "";
            Session["N_Fr_R"] = "";
            Session["N_Of_R"] = "";

            Session["N_B_R"]   = "";
            Session["Nm_Ch_R"] = "";
            Session["T_Ch_R"]  = "";
            Session["S_B_R"]   = "";
            Session["D_Ch_R"]  = "";
            Session["S_Ch_R"]  = "";
            Session["T_D_R"]   = "";
            if (Request.QueryString["NameFarm"] != null)
            {
                if (!IsPostBack)
                {
                    string idf2 = Session["ID_Login"].ToString();
                    idf2 = idf2.Substring(0, 1);
                    if (idf2 == "F")
                    {
                        int numF = Convert.ToInt32(Farmm.ScalarQuery(Session["ID_Login"].ToString()));
                        Session["fr"] = numF;
                        if (!IsPostBack)
                        {
                            DropDownList1.Items.Add(new ListItem(Request.QueryString["NameFarm"].ToString()));
                            for (int i = 0; i < numF; i++)
                            {
                                DropDownList1.Items.Add(new ListItem(Farmm.GetDataBy2(Session["ID_Login"].ToString()).Rows[i][1].ToString(), i.ToString()));
                            }
                        }
                    }
                    else
                    {
                        int numF = Convert.ToInt32(Farmm.ScalarQuery1(Session["ID_Login"].ToString()));
                        Session["fr"] = numF;
                        if (!IsPostBack)
                        {
                            DropDownList1.Items.Add(new ListItem(Request.QueryString["NameFarm"].ToString()));
                            for (int i = 0; i < numF; i++)
                            {
                                DropDownList1.Items.Add(new ListItem(Farmm.GetDataBy3(Session["ID_Login"].ToString()).Rows[i][1].ToString(), i.ToString()));
                            }
                        }
                    }
                    string idf  = Farmm.GetDataBy4(DropDownList1.SelectedItem.Text).Rows[0][0].ToString();
                    int    numB = Convert.ToInt32(bu.ScalarQuery(idf));
                    DropDownList2.Items.Clear();
                    DropDownList2.Items.Add(new ListItem(Request.QueryString["NameBu"].ToString()));
                    for (int i = 0; i < numB; i++)
                    {
                        DropDownList2.Items.Add(new ListItem(bu.GetDataBy1(idf).Rows[i][1].ToString(), i.ToString()));
                    }
                    Problem_recommendTableAdapter pro = new Problem_recommendTableAdapter();
                    SensorTableAdapter            sen = new SensorTableAdapter();
                    Chicken_raisingTableAdapter   chh = new Chicken_raisingTableAdapter();
                    Session["N_F_R"] = Farmm.GetDataBy4(Request.QueryString["NameFarm"].ToString()).Rows[0][1].ToString();
                    Session["A_F_R"] = Farmm.GetDataBy4(Request.QueryString["NameFarm"].ToString()).Rows[0][2].ToString();
                    string idfr = Farmm.GetDataBy4(Request.QueryString["NameFarm"].ToString()).Rows[0][3].ToString();
                    string idof = Farmm.GetDataBy4(Request.QueryString["NameFarm"].ToString()).Rows[0][4].ToString();
                    Session["N_Fr_R"] = farmer.GetDataBy3(idfr).Rows[0][1].ToString();
                    Session["N_Of_R"] = ofii.GetDataBy3(idof).Rows[0][2].ToString();
                    string idb = bu.GetDataBy2(Request.QueryString["NameBu"].ToString()).Rows[0][0].ToString();
                    Session["N_B_R"]   = bu.GetDataBy2(Request.QueryString["NameBu"].ToString()).Rows[0][1].ToString();
                    Session["Nm_Ch_R"] = bu.GetDataBy2(Request.QueryString["NameBu"].ToString()).Rows[0][2].ToString();
                    Session["T_Ch_R"]  = bu.GetDataBy2(Request.QueryString["NameBu"].ToString()).Rows[0][3].ToString();
                    Session["S_B_R"]   = bu.GetDataBy2(Request.QueryString["NameBu"].ToString()).Rows[0][4].ToString();
                    Session["D_Ch_R"]  = bu.GetDataBy2(Request.QueryString["NameBu"].ToString()).Rows[0][9].ToString();
                    int numA1 = 0;
                    //int numA2 = 0;
                    //int numA3 = 0;
                    //int numA4 = 0;
                    //int numA5 = 0;
                    //int numA6 = 0;
                    //int numA7 = 0;
                    for (int ii = 1; ii <= 42; ii++)
                    {
                        if (pro.ScalarQuery2(ii.ToString()).ToString() != "")
                        {
                            numA1 = Convert.ToInt32(pro.ScalarQuery2(ii.ToString()).ToString());
                            Session["A1" + ii.ToString()] = numA1;
                            for (int i = 0; i < numA1; i++)
                            {
                                string idspr = pro.GetDataBy5(ii.ToString()).Rows[i][1].ToString();
                                Session["N_S_RP1" + ii.ToString() + "," + i] = sen.GetDataBy3(idspr).Rows[0][1].ToString();
                                Session["P_P_RP1" + ii.ToString() + "," + i] = pro.GetDataBy5(ii.ToString()).Rows[i][2].ToString();
                                Session["T_P_RP1" + ii.ToString() + "," + i] = pro.GetDataBy5(ii.ToString()).Rows[i][3].ToString();
                                Session["R_P_RP1" + ii.ToString() + "," + i] = pro.GetDataBy5(ii.ToString()).Rows[i][4].ToString();
                                Session["S_P_RP1" + ii.ToString() + "," + i] = pro.GetDataBy5(ii.ToString()).Rows[i][6].ToString();
                                Session["D_P_RP1" + ii.ToString() + "," + i] = pro.GetDataBy5(ii.ToString()).Rows[i][8].ToString();
                            }
                        }
                    }

                    //if (pro.ScalarQuery2("2").ToString() != "")
                    //{
                    //    numA2 = Convert.ToInt32(pro.ScalarQuery2("2").ToString());
                    //    Session["A2"] = numA2;

                    //    for (int i1 = 0; i1 < numA2; i1++)
                    //    {
                    //        string idspr1 = pro.GetDataBy5("2").Rows[i1][1].ToString();
                    //        Session["N_S_RP2" + i1] = sen.GetDataBy3(idspr1).Rows[0][1].ToString();
                    //        Session["P_P_RP2" + i1] = pro.GetDataBy5("2").Rows[i1][2].ToString();
                    //        Session["T_P_RP2" + i1] = pro.GetDataBy5("2").Rows[i1][3].ToString();
                    //        Session["R_P_RP2" + i1] = pro.GetDataBy5("2").Rows[i1][4].ToString();
                    //        Session["S_P_RP2" + i1] = pro.GetDataBy5("2").Rows[i1][6].ToString();
                    //        Session["D_P_RP2" + i1] = pro.GetDataBy5("2").Rows[i1][8].ToString();
                    //    }
                    //}
                    //if (pro.ScalarQuery2("3").ToString() != "")
                    //{
                    //    numA3 = Convert.ToInt32(pro.ScalarQuery2("3").ToString());
                    //}
                    //if (pro.ScalarQuery2("4").ToString() != "")
                    //{
                    //    numA4 = Convert.ToInt32(pro.ScalarQuery2("4").ToString());
                    //}
                    //if (pro.ScalarQuery2("5").ToString() != "")
                    //{
                    //    numA5 = Convert.ToInt32(pro.ScalarQuery2("5").ToString());
                    //}
                    //if (pro.ScalarQuery2("6").ToString() != "")
                    //{
                    //    numA6 = Convert.ToInt32(pro.ScalarQuery2("6").ToString());
                    //}
                    //if (pro.ScalarQuery2("7").ToString() != "")
                    //{
                    //    numA7 = Convert.ToInt32(pro.ScalarQuery2("7").ToString());
                    //}



                    ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script language=javascript>myfunction();</script>");
                    if (chh.ScalarQuery1(idb).ToString() != "")
                    {
                        DropDownList3.Items.Clear();
                        DropDownList3.Items.Add(new ListItem("รอบการเลี้ยงปัจจุบัน"));
                        for (int i = 0; i < Convert.ToInt32(chh.ScalarQuery1(idb).ToString()); i++)
                        {
                            DropDownList3.Items.Add(new ListItem(chh.GetDataBy2(idb).Rows[i][9].ToString(), i.ToString()));
                        }
                    }
                    else
                    {
                        DropDownList3.Items.Clear();
                        DropDownList3.Items.Add(new ListItem("รอบการเลี้ยงปัจจุบัน"));
                    }
                }
            }
            else
            {
                string idf2 = Session["ID_Login"].ToString();
                idf2 = idf2.Substring(0, 1);
                if (idf2 == "F")
                {
                    int numF = Convert.ToInt32(Farmm.ScalarQuery(Session["ID_Login"].ToString()));
                    Session["fr"] = numF;
                    if (!IsPostBack)
                    {
                        DropDownList1.Items.Add(new ListItem("----เลือกฟาร์ม----"));
                        for (int i = 0; i < numF; i++)
                        {
                            DropDownList1.Items.Add(new ListItem(Farmm.GetDataBy2(Session["ID_Login"].ToString()).Rows[i][1].ToString(), i.ToString()));
                        }
                    }
                }
                else
                {
                    int numF = Convert.ToInt32(Farmm.ScalarQuery1(Session["ID_Login"].ToString()));
                    Session["fr"] = numF;
                    if (!IsPostBack)
                    {
                        DropDownList1.Items.Add(new ListItem("----เลือกฟาร์ม----"));
                        for (int i = 0; i < numF; i++)
                        {
                            DropDownList1.Items.Add(new ListItem(Farmm.GetDataBy3(Session["ID_Login"].ToString()).Rows[i][1].ToString(), i.ToString()));
                        }
                    }
                }
            }
        }