protected void Button1_Click(object sender, EventArgs e)
    {
        string[] cart;
        Service1.Service1 ls = new Service1.Service1();
        cart = ls.retrieve_cust_search(userid);
        for (int i = 0; i < cart.Length; i++)
        {
            if (i % 2 == 0)
            {
                TextBox1.Text += "---------------------------------";
            }
            TextBox1.Text += Environment.NewLine;
            TextBox1.Text += cart[i];
            TextBox1.Text += Environment.NewLine;

        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     string[] cart;
     string[] cart1;
     DataTable carttable = new DataTable();
     Service1.Service1 ls = new Service1.Service1();
     cart=ls.retrieve_cartdetails();
     cart1 = ls.retrieve_cartdetails1();
     carttable.Columns.Add("ItemID", typeof(string));
     carttable.Columns.Add("ItemTitle", typeof(string));
     for (int i = 0; i < cart.Length; i++)
     {
         carttable.Rows.Add(cart[i], cart1[i]);
     }
     GridView1.DataSource = carttable;
     GridView1.DataBind();
 }
예제 #3
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            if (Environment.UserInteractive)
            {
                if (!SupportLibrary.UtilityHelpers.IsAdministrator())
                {
                    Console.WriteLine("Error. Please run as Administrator of this process.");
                    Console.Read();
                }
                else
                {
                    if (args.Length > 0)
                    {
                        try
                        {
                            switch (args[0])
                            {
                            case "-install":
                                System.Configuration.Install.ManagedInstallerClass.InstallHelper(new string[] { System.Reflection.Assembly.GetExecutingAssembly().Location });
                                System.Diagnostics.EventLog eventLog1 = new System.Diagnostics.EventLog();
                                var appSettings = System.Configuration.ConfigurationManager.AppSettings;
                                eventLog1.Source = appSettings["EventSourceName"];
                                eventLog1.Log    = appSettings["EventLogName"];
                                eventLog1.WriteEntry("Service installed.");
                                break;

                            case "-uninstall":
                                System.Configuration.Install.ManagedInstallerClass.InstallHelper(new string[] { "/u", System.Reflection.Assembly.GetExecutingAssembly().Location });
                                break;

                            default:
                                break;
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.ToString());
                        }
                    }
                    else
                    {
                        var    appSettings     = System.Configuration.ConfigurationManager.AppSettings;
                        string eventSourceName = appSettings["EventSourceName"];
                        string logName         = appSettings["EventLogName"];
                        if (!System.Diagnostics.EventLog.SourceExists(eventSourceName))
                        {
                            System.Diagnostics.EventLog.CreateEventSource(
                                eventSourceName, logName);
                        }

                        Service1 service = new Service1();
                        service.TestStartupAndStop(args);
                    }
                }
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new Service1()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }