/**@author-Surojit Paul
         * Implemented 23.2.2019
         * This button Open the Loaded/selected/file from adrress
         * throws FileNotfound and ArgumentException already hadled by CreatFile Method in XMlContainers class
         * it first check whether the address bar is empty. if true- show a custome pop-up dialog box
         * false-the fileName(without extension) appended by ".xml" then open the file and hide the welcome screen
         *
         * have problem with the ".xml" string.
         * */
        private void OKButton_Click(object sender, EventArgs e)
        {
            Form Mainform = new MainForm();

            MainForm.FileNameOnBar = FileAdress.Text;



            if (FileAdress.Text == String.Empty)
            {
                CustomeDialogBox d1 = new CustomeDialogBox("Load A File Or \nCreate a New...", false, true);
                d1.Location = new Point(this.Location.X + (this.Width - d1.Width) / 2, 12 + this.Location.Y + (this.Height - d1.Height) / 2);


                d1.ShowDialog();
            }

            else if (!FileAdress.Text.Contains(".xml"))
            {
                MainForm.filename = FileAdress.Text + ".xml";
                this.Hide();
                Mainform.Show();
                MainForm.FileNameOnBar = FileAdress.Text;
            }
            else
            {
                MainForm.filename = FileAdress.Text;
                this.Hide();
                Mainform.Show();
                MainForm.FileNameOnBar = FileAdress.Text;
                Console.WriteLine("Surojit" + MainForm.FileNameOnBar);
            }
            //d2.Close();
            d3.Close();
        }
Exemplo n.º 2
0
        private void Save(object Sender, EventArgs e)

        {
            if (txtName.Text == "" | txtNumber.Text == "")
            {
                CustomeDialogBox Caution = new CustomeDialogBox("Please Enter A Number", true);
                Caution.Location = new Point(this.Location.X + (this.Width - Caution.Width) / 2, 12
                                             + this.Location.Y + (this.Height - Caution.Height) / 2);
                Caution.ShowDialog();
            }
            else
            {
                XmlMethods.InsertNewField(filename, txtName.Text, txtNumber.Text, txtWhatsAppNumber.Text);
                //textBox1.Text = XmlMethods.GetXDocument().ToString();
                MessageBox.Show("Saved");
            }
            List <String> names = XmlMethods.getTheNames(filename);

            listBox1.DataSource = names;
            //showDatainDataGrid("contact.xml");


            //number of contact.
            txtNumberOfContact.Text = ShowHowmanyNumbersAreTheir();
            txtContactSearch.AutoCompleteCustomSource.AddRange(names.ToArray <string>());
        }