Example #1
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);
            OfficerTableAdapter ofii   = new OfficerTableAdapter();
            FarmerTableAdapter  farmer = new FarmerTableAdapter();

            if (idf == "F")
            {
                TextBox2.Text   = farmer.GetDataBy3(Session["ID_Login"].ToString()).Rows[0][1].ToString();
                TextBox3.Text   = farmer.GetDataBy3(Session["ID_Login"].ToString()).Rows[0][2].ToString();
                Session["pp_f"] = farmer.GetDataBy3(Session["ID_Login"].ToString()).Rows[0][3].ToString();
                TextBox1.Text   = farmer.GetDataBy3(Session["ID_Login"].ToString()).Rows[0][4].ToString();
            }
            else
            {
                Session["pp_o"] = ofii.GetDataBy3(Session["ID_Login"].ToString()).Rows[0][1].ToString();
                TextBox2.Text   = ofii.GetDataBy3(Session["ID_Login"].ToString()).Rows[0][2].ToString();
                TextBox1.Text   = ofii.GetDataBy3(Session["ID_Login"].ToString()).Rows[0][3].ToString();
                TextBox3.Text   = ofii.GetDataBy3(Session["ID_Login"].ToString()).Rows[0][4].ToString();
            }
        }
Example #2
0
        protected void Button11_Click(object sender, EventArgs e)
        {
            FarmTableAdapter   f1  = new FarmTableAdapter();
            FarmerTableAdapter fr1 = new FarmerTableAdapter();
            string             fr  = fr1.GetDataBy6(Se_F.SelectedItem.Text).Rows[0][0].ToString();
            string             inf = "F" + (Convert.ToInt32(f1.ScalarQuery2()) + 1).ToString("0000");

            f1.InsertQuery(inf, N_f.Text, Adds_farm.Text, fr, Session["ID_Login"].ToString(), FileUpload1.FileName.ToString());
            Page.Response.Redirect(Page.Request.Url.ToString(), true);
        }
Example #3
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    Farmm  = new FarmTableAdapter();
            OfficerTableAdapter ofii   = new OfficerTableAdapter();
            FarmerTableAdapter  farmer = new FarmerTableAdapter();

            //Session.Add("fro","");
            if (idf == "F")
            {
                int numF = Convert.ToInt32(Farmm.ScalarQuery(Session["ID_Login"].ToString()));
                Session["fr"] = numF;
                for (int i = 0; i < numF; i++)
                {
                    Session["Name_Farm" + i] = Farmm.GetDataBy2(Session["ID_Login"].ToString()).Rows[i][1].ToString();
                    Session["Add_Farm" + i]  = Farmm.GetDataBy2(Session["ID_Login"].ToString()).Rows[i][2].ToString();
                    string OFF = Farmm.GetDataBy2(Session["ID_Login"].ToString()).Rows[i][4].ToString();
                    Session["OF_Farm" + i]     = ofii.GetDataBy3(OFF).Rows[0][2].ToString();
                    Session["Name_Farmer" + i] = Session["Name_Login"].ToString();
                    Session["Pic_Farm" + i]    = Farmm.GetDataBy2(Session["ID_Login"].ToString()).Rows[i][5].ToString();
                }
            }
            else
            {
                int numF = Convert.ToInt32(Farmm.ScalarQuery1(Session["ID_Login"].ToString()));
                Session["fr"] = numF;
                for (int i = 0; i < numF; i++)
                {
                    Session["OF_Farm" + i]   = Session["Name_Login"].ToString();
                    Session["Name_Farm" + i] = Farmm.GetDataBy3(Session["ID_Login"].ToString()).Rows[i][1].ToString();
                    Session["Add_Farm" + i]  = Farmm.GetDataBy3(Session["ID_Login"].ToString()).Rows[i][2].ToString();
                    string OFF = Farmm.GetDataBy3(Session["ID_Login"].ToString()).Rows[i][3].ToString();
                    Session["Name_Farmer" + i] = farmer.GetDataBy3(OFF).Rows[0][1].ToString();
                    Session["Pic_Farm" + i]    = Farmm.GetDataBy3(Session["ID_Login"].ToString()).Rows[i][5].ToString();
                }
            }

            FarmerTableAdapter ff = new FarmerTableAdapter();

            for (int i = 0; i < Convert.ToInt32(ff.ScalarQuery().ToString()); i++)
            {
                Se_F.Items.Add(new ListItem(ff.GetDataBy2().Rows[i][1].ToString(), i.ToString()));
            }
        }
Example #4
0
        protected void btn_login_Click(object sender, EventArgs e)
        {
            int ll   = 0;
            int log1 = 0;
            FarmerTableAdapter login = new FarmerTableAdapter();

            log1 = Convert.ToInt32(login.ScalarQuery());
            for (int i = 0; i < log1; i++)
            {
                string log2 = login.GetDataBy2().Rows[i][2].ToString();
                if (txt_tel.Text == log2)
                {
                    string logps = login.GetDataBy(txt_tel.Text).Rows[0][3].ToString();
                    if (txt_pwd.Text == logps)
                    {
                        string idf = login.GetDataBy(txt_tel.Text).Rows[0][0].ToString();
                        Session["ID_Login"] = idf;
                        string nf = login.GetDataBy(txt_tel.Text).Rows[0][1].ToString();
                        Session["Name_Login"] = nf;
                        Session["Tel_Login"]  = txt_tel.Text;
                        Response.Redirect("Home.aspx");
                    }
                    else
                    {
                        string message = "เบอร์โทรศัพท์หรือรหัสผ่านไม่ถูกต้อง กรุณาลองอีกครั้ง !";
                        System.Text.StringBuilder sb = new System.Text.StringBuilder();
                        sb.Append("<script type = 'text/javascript'>");
                        sb.Append("window.onload=function(){");
                        sb.Append("alert('");
                        sb.Append(message);
                        sb.Append("')};");
                        sb.Append("</script>");
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
                    }
                }
                else
                {
                    ll++;
                }
            }
            ////////////////////////////////เกษตรกร/////////////////////////////////////
            int llof = 0;
            OfficerTableAdapter logof = new OfficerTableAdapter();

            llof = Convert.ToInt32(logof.ScalarQuery());
            for (int i = 0; i < llof; i++)
            {
                string llof2 = logof.GetDataBy2().Rows[i][4].ToString();
                if (txt_tel.Text == llof2)
                {
                    string llof3 = logof.GetDataBy(txt_tel.Text).Rows[0][1].ToString();
                    if (txt_pwd.Text == llof3)
                    {
                        string ido = logof.GetDataBy(txt_tel.Text).Rows[0][0].ToString();
                        Session["ID_Login"] = ido;
                        string nf = logof.GetDataBy(txt_tel.Text).Rows[0][2].ToString();
                        Session["Name_Login"] = nf;
                        Session["Tel_Login"]  = txt_tel.Text;
                        Response.Redirect("Home.aspx");
                    }
                    else
                    {
                        string message = "เบอร์โทรศัพท์หรือรหัสผ่านไม่ถูกต้อง กรุณาลองอีกครั้ง !";
                        System.Text.StringBuilder sb = new System.Text.StringBuilder();
                        sb.Append("<script type = 'text/javascript'>");
                        sb.Append("window.onload=function(){");
                        sb.Append("alert('");
                        sb.Append(message);
                        sb.Append("')};");
                        sb.Append("</script>");
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
                    }
                }
                else
                {
                    ll++;
                }
            }
            if (ll == (llof + log1))
            {
                string message = "เบอร์โทรศัพท์หรือรหัสผ่านไม่ถูกต้อง กรุณาลองอีกครั้ง !";
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append("<script type = 'text/javascript'>");
                sb.Append("window.onload=function(){");
                sb.Append("alert('");
                sb.Append(message);
                sb.Append("')};");
                sb.Append("</script>");
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
            }
        }
Example #5
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();

            Session["ID_bu"] = "";
            Session["Of_bu"] = "";
            string inb = "B" + (Convert.ToInt32(bu.ScalarQuery1()) + 1).ToString("0000");

            Session["NewB"] = inb;
            if (Session["ID_Login"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            string idf = Session["ID_Login"].ToString();

            idf = idf.Substring(0, 1);

            if (idf == "F")
            {
                if (Request.QueryString["NameFarm"] != null)
                {
                    string ido = Farmm.GetDataBy4(Request.QueryString["NameFarm"].ToString()).Rows[0][4].ToString();
                    Session["Of_bu"] = ofii.GetDataBy3(ido).Rows[0][2].ToString();
                    string idf1 = Farmm.GetDataBy4(Request.QueryString["NameFarm"].ToString()).Rows[0][0].ToString();
                    Session["NFarm"] = Request.QueryString["NameFarm"].ToString();
                    int iddf = Convert.ToInt32(bu.ScalarQuery(idf1));
                    Session["ID_Ff"] = iddf;
                    for (int i = 0; i < iddf; i++)
                    {
                        Session["Name_bu" + i] = bu.GetDataBy1(idf1).Rows[i][1].ToString();
                        Session["ID_bu" + i]   = bu.GetDataBy1(idf1).Rows[i][0].ToString();
                        Session["In_bu" + i]   = bu.GetDataBy1(idf1).Rows[i][2].ToString();
                        Session["InD_bu" + i]  = bu.GetDataBy1(idf1).Rows[i][3].ToString();
                        Session["Size_bu" + i] = bu.GetDataBy1(idf1).Rows[i][4].ToString();
                        Session["Pic_bu" + i]  = bu.GetDataBy1(idf1).Rows[i][6].ToString();
                    }
                    // DropDownList1.Items.Add(new ListItem(Request.QueryString["NameFarm"].ToString()));
                    ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script language=javascript>myfunction();</script>");
                }
                else
                {
                    if (!IsPostBack)
                    {
                        Session["Of_bu"] = "";
                        Session["NFarm"] = "";
                        //  DropDownList1.Items.Add(new ListItem("----เลือกฟาร์ม----"));
                    }
                }

                int numF = Convert.ToInt32(Farmm.ScalarQuery(Session["ID_Login"].ToString()));
                Session["fr"] = numF;

                if (!IsPostBack)
                {
                    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
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script language=javascript>myfunction();</script>");
                }
            }
            else
            {
                if (Request.QueryString["NameFarm"] != null)
                {
                    if (!IsPostBack)
                    {
                        string ido = Farmm.GetDataBy4(Request.QueryString["NameFarm"].ToString()).Rows[0][3].ToString();
                        Session["Of_bu"] = farmer.GetDataBy3(ido).Rows[0][1].ToString();
                        string idf1 = Farmm.GetDataBy4(Request.QueryString["NameFarm"].ToString()).Rows[0][0].ToString();
                        Session["NFarm"] = Request.QueryString["NameFarm"].ToString();
                        int iddf = Convert.ToInt32(bu.ScalarQuery(idf1));
                        Session["ID_Ff"] = iddf;
                        for (int i = 0; i < iddf; i++)
                        {
                            Session["Name_bu" + i] = bu.GetDataBy1(idf1).Rows[i][1].ToString();
                            Session["ID_bu" + i]   = bu.GetDataBy1(idf1).Rows[i][0].ToString();
                            Session["In_bu" + i]   = bu.GetDataBy1(idf1).Rows[i][2].ToString();
                            Session["InD_bu" + i]  = bu.GetDataBy1(idf1).Rows[i][3].ToString();
                            Session["Size_bu" + i] = bu.GetDataBy1(idf1).Rows[i][4].ToString();
                            Session["Pic_bu" + i]  = bu.GetDataBy1(idf1).Rows[i][6].ToString();
                        }
                        //  DropDownList1.Items.Add(new ListItem(Request.QueryString["NameFarm"].ToString()));
                        ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script language=javascript>myfunction();</script>");
                    }
                }
                else
                {
                    if (!IsPostBack)
                    {
                        Session["Of_bu"] = "";
                        Session["NFarm"] = "";
                        // DropDownList1.Items.Add(new ListItem("----เลือกฟาร์ม----"));
                    }
                }

                int numF = Convert.ToInt32(Farmm.ScalarQuery1(Session["ID_Login"].ToString()));
                Session["fr"] = numF;

                if (!IsPostBack)
                {
                    for (int i = 0; i < numF; i++)
                    {
                        // DropDownList1.Items.Add(new ListItem(Farmm.GetDataBy3(Session["ID_Login"].ToString()).Rows[i][1].ToString(), i.ToString()));
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script language=javascript>myfunction();</script>");
                }
            }

            N_F1.Text = Request.QueryString["NameFarm"].ToString();
        }
Example #6
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();
                        }
                    }
                }
            }
        }
Example #7
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string idf = Session["ID_Login"].ToString();

            idf = idf.Substring(0, 1);
            OfficerTableAdapter ofii   = new OfficerTableAdapter();
            FarmerTableAdapter  farmer = new FarmerTableAdapter();

            if (idf == "F")
            {
                if (TextBox4.Text != "")
                {
                    if (Session["pp_f"].ToString() == TextBox4.Text)
                    {
                        if (TextBox5.Text == TextBox6.Text)
                        {
                            farmer.UpdateQuery1(Session["ID_Login"].ToString(), TextBox5.Text, Session["ID_Login"].ToString());
                            string message5 = "บันทึกรหัสผ่านเรียบร้อย";
                            System.Text.StringBuilder sb5 = new System.Text.StringBuilder();
                            sb5.Append("<script type = 'text/javascript'>");
                            sb5.Append("window.onload=function(){");
                            sb5.Append("alert('");
                            sb5.Append(message5);
                            sb5.Append("')};");
                            sb5.Append("</script>");
                            ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb5.ToString());
                        }
                        else
                        {
                            string message = "รหัสผ่านใหม่ไม่ตรงกัน !!!";
                            System.Text.StringBuilder sb = new System.Text.StringBuilder();
                            sb.Append("<script type = 'text/javascript'>");
                            sb.Append("window.onload=function(){");
                            sb.Append("alert('");
                            sb.Append(message);
                            sb.Append("')};");
                            sb.Append("</script>");
                            ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
                        }
                    }
                    else
                    {
                        string message = "รหัสผ่านเดิมผิด !!!";
                        System.Text.StringBuilder sb = new System.Text.StringBuilder();
                        sb.Append("<script type = 'text/javascript'>");
                        sb.Append("window.onload=function(){");
                        sb.Append("alert('");
                        sb.Append(message);
                        sb.Append("')};");
                        sb.Append("</script>");
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
                    }
                }
                farmer.UpdateQuery(Session["ID_Login"].ToString(), TextBox2.Text, TextBox3.Text, TextBox1.Text, Session["ID_Login"].ToString());
                string message6 = "บันทึกข้อมูลส่วนตัวเรียนร้อย";
                System.Text.StringBuilder sb6 = new System.Text.StringBuilder();
                sb6.Append("<script type = 'text/javascript'>");
                sb6.Append("window.onload=function(){");
                sb6.Append("alert('");
                sb6.Append(message6);
                sb6.Append("')};");
                sb6.Append("</script>");
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb6.ToString());
            }
            else
            {
                if (TextBox4.Text != "")
                {
                    if (Session["pp_o"].ToString() == TextBox4.Text)
                    {
                        if (TextBox5.Text == TextBox6.Text)
                        {
                            ofii.UpdateQuery1(Session["ID_Login"].ToString(), TextBox5.Text, Session["ID_Login"].ToString());
                            string message1 = "บันทึกรหัสผ่านเรียบร้อย";
                            System.Text.StringBuilder sb1 = new System.Text.StringBuilder();
                            sb1.Append("<script type = 'text/javascript'>");
                            sb1.Append("window.onload=function(){");
                            sb1.Append("alert('");
                            sb1.Append(message1);
                            sb1.Append("')};");
                            sb1.Append("</script>");
                            ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb1.ToString());
                        }
                        else
                        {
                            string message3 = "รหัสผ่านใหม่ไม่ตรงกัน !!!";
                            System.Text.StringBuilder sb3 = new System.Text.StringBuilder();
                            sb3.Append("<script type = 'text/javascript'>");
                            sb3.Append("window.onload=function(){");
                            sb3.Append("alert('");
                            sb3.Append(message3);
                            sb3.Append("')};");
                            sb3.Append("</script>");
                            ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb3.ToString());
                        }
                    }
                    else
                    {
                        string message2 = "รหัสผ่านเดิมผิด !!!";
                        System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
                        sb2.Append("<script type = 'text/javascript'>");
                        sb2.Append("window.onload=function(){");
                        sb2.Append("alert('");
                        sb2.Append(message2);
                        sb2.Append("')};");
                        sb2.Append("</script>");
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb2.ToString());
                    }
                }
                ofii.UpdateQuery(Session["ID_Login"].ToString(), TextBox2.Text, TextBox1.Text, TextBox3.Text, Session["ID_Login"].ToString());
                string message = "บันทึกข้อมูลส่วนตัวเรียบร้อย ";
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append("<script type = 'text/javascript'>");
                sb.Append("window.onload=function(){");
                sb.Append("alert('");
                sb.Append(message);
                sb.Append("')};");
                sb.Append("</script>");
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
            }
        }
Example #8
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();
                        }
                    }
                }
            }
        }
Example #9
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>");
            }
        }
Example #10
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()));
                        }
                    }
                }
            }
        }