Esempio n. 1
0
        /// <summary>
        /// The get companies from database.
        /// </summary>
        /// <returns>
        /// The <see cref="List"/>.
        /// </returns>
        public List<Company> GetCompanies()
        {
            var companylist = new List<Company>();

            using (var db = new Database())
            {
                Company companies = null;
                db.OpenConnection();
                db.CreateCommand("Select * from company");

                MySqlDataReader dr = db.Command.ExecuteReader();

                while (dr.Read())
                {
                    companies = new Company();
                    companies.id = (int)dr["id"];
                    companies.name = (string)dr["name"];
                    companylist.Add(companies);
                }
            }

            return companylist;
        }
Esempio n. 2
0
        /// <summary>
        /// The bt export_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void btExport_Click(object sender, EventArgs e)
        {
            {
                var folderBrowserDialog1 = new FolderBrowserDialog();

                // Set the help text description for the FolderBrowserDialog.
                folderBrowserDialog1.Description = "Selecteer waar u het bestand wilt opslaan.";

                // Do not allow the user to create new files via the FolderBrowserDialog.
                folderBrowserDialog1.ShowNewFolderButton = false;

                // Default to the My Documents folder.
                folderBrowserDialog1.RootFolder = Environment.SpecialFolder.Personal;

                if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                {
                    // Set a variable to the My Documents path.
                    string comboship = this.comboTypeSchip.SelectedItem.ToString();
                    string port = this.comboBestemming.SelectedItem.ToString();
                    var company = new Company();
                    var container = new Container();
                    string date = DateTime.Now.ToString("dd-MM-yyyy"); //sets the date
                    List<Container> containers = BLContainer.GetContainers(comboship, port);
                    string mydocpath = folderBrowserDialog1.SelectedPath;
                    var str = new StringBuilder();

                    containers = containers.OrderBy(o => container.companyname).ToList(); //sorts the list on companyname
                    str.AppendLine("Gemaakt op:  " + date); //sets date in document
                    str.AppendLine();
                    str.AppendLine("Bestemming:  " + port);//sets selected desination
                    str.AppendLine();
                    str.AppendLine("Schip type:  " + comboship); //sets selected ship
                    str.AppendLine();

                    foreach (Container containerlist in containers)
                    {
                        str.AppendLine(
                            string.Format(
                                "{0}: Container ID:{1}  -  X:{2}  Y:{3}  Z:{4}",
                                containerlist.companyname,
                                containerlist.id,
                                containerlist.x,
                                containerlist.y,
                                containerlist.z));
                    }

                    using (var outfile = new StreamWriter(mydocpath + @"\CSC Export.txt"))
                    {
                        outfile.Write(str.ToString());
                    }
                }
            }
        }