コード例 #1
0
        protected void Button4_Click(object sender, EventArgs e)
        {
            if (role != 1)
            {
                List <Reservation> reservations = new List <Reservation>();
                WebService1        webService   = new WebService1();
                DataTable          dt           = webService.GetReservationByReceptionistId(Convert.ToInt32(Session["valor1"]));
                foreach (DataRow dr in dt.Rows)
                {
                    reservations.Add(new Reservation(Convert.ToInt32(dr[0]), Convert.ToInt32(dr[1]), Convert.ToInt32(dr[2]), Convert.ToInt32(dr[3]), Convert.ToInt32(dr[4]), Convert.ToInt32(dr[5]), Convert.ToInt32(dr[6])));
                }
                string JSONObject = JsonConvert.SerializeObject(reservations);
                webService.ClearClientList();

                TextBox1.Text = JSONObject;
                System.IO.File.WriteAllText(Server.MapPath("~/JsonData/jsondataReservations.txt"), JSONObject);
            }
            else
            {
                List <Reservation> reservations = new List <Reservation>();
                WebService1        webService   = new WebService1();
                DataTable          dt           = webService.GetAllReservations();
                foreach (DataRow dr in dt.Rows)
                {
                    reservations.Add(new Reservation(Convert.ToInt32(dr[0]), Convert.ToInt32(dr[1]), Convert.ToInt32(dr[2]), Convert.ToInt32(dr[3]), Convert.ToInt32(dr[4]), Convert.ToInt32(dr[5]), Convert.ToInt32(dr[6])));
                }
                string JSONObject = JsonConvert.SerializeObject(reservations);
                webService.ClearClientList();

                TextBox1.Text = JSONObject;
                System.IO.File.WriteAllText(Server.MapPath("~/JsonData/jsondataReservations.txt"), JSONObject);
            }
        }
コード例 #2
0
        protected void Button6_Click(object sender, EventArgs e)
        {
            List <Recepcionist> recepcionists = new List <Recepcionist>();
            List <LoginC>       loginCs       = new List <LoginC>();
            WebService1         webService    = new WebService1();
            DataTable           dt            = webService.GetAllReceptionists();

            foreach (DataRow dr in dt.Rows)
            {
                recepcionists.Add(new Recepcionist(Convert.ToInt32(dr[0]), dr[1].ToString(), dr[2].ToString(), dr[4].ToString(), Convert.ToInt32(dr[3])));
                DataTable dtLogins = webService.GetLoginByReceptionistId(Convert.ToInt32(dr["id"]));
                foreach (DataRow drLogin in dtLogins.Rows)
                {
                    loginCs.Add(new LoginC(Convert.ToInt32(drLogin[0]), drLogin[1].ToString(), drLogin[2].ToString(), drLogin[3].ToString(), Convert.ToInt32(drLogin[4])));
                }
            }
            string JSONObject       = JsonConvert.SerializeObject(recepcionists);
            string JSONObjectLogins = JsonConvert.SerializeObject(loginCs);

            JSONObject += "\n" + JSONObjectLogins;
            webService.ClearClientList();

            TextBox1.Text = JSONObject;
            System.IO.File.WriteAllText(Server.MapPath("~/JsonData/jsondataReceptionists.txt"), JSONObject);
        }
コード例 #3
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            if (role != 1)
            {
                List <Client> clients    = new List <Client>();
                List <LoginC> loginCs    = new List <LoginC>();
                WebService1   webService = new WebService1();
                DataTable     dt         = webService.GetClientByReceptionistId(Convert.ToInt32(Session["valor1"]));
                foreach (DataRow dr in dt.Rows)
                {
                    clients.Add(new Client(Convert.ToInt32(dr["id"]), dr["name"].ToString(), dr["lastName"].ToString(), Convert.ToInt32(dr["cardNumber"]), Convert.ToInt32(dr["phone"]), dr["password"].ToString(), Convert.ToInt32(dr["RecepcionistId"])));
                    DataTable dtLogins = webService.GetLoginByClientId(Convert.ToInt32(dr["id"]));
                    foreach (DataRow drLogin in dtLogins.Rows)
                    {
                        loginCs.Add(new LoginC(Convert.ToInt32(drLogin[0]), drLogin[1].ToString(), drLogin[2].ToString(), drLogin[3].ToString(), Convert.ToInt32(drLogin[4])));
                    }
                }
                string JSONObject       = JsonConvert.SerializeObject(clients);
                string JSONObjectLogins = JsonConvert.SerializeObject(loginCs);

                JSONObject += "\n" + JSONObjectLogins;
                webService.ClearClientList();

                TextBox1.Text = JSONObject;
                System.IO.File.WriteAllText(Server.MapPath("~/JsonData/jsondataClients.txt"), JSONObject);
            }
            else
            {
                List <Client> clients    = new List <Client>();
                List <LoginC> loginCs    = new List <LoginC>();
                WebService1   webService = new WebService1();
                DataTable     dt         = webService.GetAllClients();
                foreach (DataRow dr in dt.Rows)
                {
                    clients.Add(new Client(Convert.ToInt32(dr["id"]), dr["name"].ToString(), dr["lastName"].ToString(), Convert.ToInt32(dr["cardNumber"]), Convert.ToInt32(dr["phone"]), dr["password"].ToString(), Convert.ToInt32(dr["RecepcionistId"])));
                    DataTable dtLogins = webService.GetLoginByClientId(Convert.ToInt32(dr["id"]));
                    foreach (DataRow drLogin in dtLogins.Rows)
                    {
                        loginCs.Add(new LoginC(Convert.ToInt32(drLogin[0]), drLogin[1].ToString(), drLogin[2].ToString(), drLogin[3].ToString(), Convert.ToInt32(drLogin[4])));
                    }
                }
                string JSONObject       = JsonConvert.SerializeObject(clients);
                string JSONObjectLogins = JsonConvert.SerializeObject(loginCs);

                JSONObject += "\n" + JSONObjectLogins;
                webService.ClearClientList();

                TextBox1.Text = JSONObject;
                System.IO.File.WriteAllText(Server.MapPath("~/JsonData/jsondataClients.txt"), JSONObject);
            }
        }
コード例 #4
0
        protected void Button5_Click(object sender, EventArgs e)
        {
            List <Room> rooms      = new List <Room>();
            WebService1 webService = new WebService1();
            DataTable   dt         = webService.GetAllRoom();

            foreach (DataRow dr in dt.Rows)
            {
                rooms.Add(new Room(Convert.ToInt32(dr[0]), Convert.ToInt32(dr[0]), dr[2].ToString(), dr[3].ToString(), dr[4].ToString(), Convert.ToInt32(dr[5])));
            }
            string JSONObject = JsonConvert.SerializeObject(rooms);

            webService.ClearClientList();
            TextBox1.Text = JSONObject;
            System.IO.File.WriteAllText(Server.MapPath("~/JsonData/jsondataRooms.txt"), JSONObject);
        }