public void createContractorsCSVDocument()
        {
            try
            {
                string cnStr =
               "Provider=Microsoft.Jet.OLEDB.4.0;" +
               "Extended Properties='text;HDR=Yes;FMT=Delimited';" +
               "Data Source=" + dir + ";";

                using (var cn = new OleDbConnection(cnStr))
                {
                    cn.Open();
                    var cmd = new OleDbCommand(
                                "CREATE TABLE contractors.csv ([Name] VARCHAR(30), [Company] VARCHAR(30), [Description] VARCHAR(100), [Date] VARCHAR(10))", cn);

                    cmd.ExecuteNonQuery();
                    cn.Close();
                }
            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
            }
        }
Example #2
0
        public bool create(string xmlRoot, string fileName)
        {
            //create the root elements of the xml document if the dont alreasy exist
            try
            {
                if (!System.IO.File.Exists(fileName))
                {
                    XmlTextWriter xtw;
                    xtw = new XmlTextWriter(fileName, Encoding.UTF8);
                    xtw.WriteStartDocument();
                    xtw.WriteStartElement(xmlRoot);
                    xtw.WriteEndElement();
                    xtw.Close();

                    //if file exists return true
                    return true;
                }
                else { return false; }
            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
                return false;
            }
        }
Example #3
0
        public Form1()
        {
            InitializeComponent();
            try
            {
                AutoUpdater.Start("http://www.matthewmarillac.com/mmm/versioninfo.xml");
            }
            catch (Exception err)
            {
                MessageBox.Show("Updater failed!");
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());

            }
        }
Example #4
0
        public void loadAllTheTasks()
        {
            try
            {

                applicationCore ap = new applicationCore(fileNameDate);
                DataSet ds = new DataSet();

                ds.ReadXml(ap.path + @"tasks/tasklist.xml").ToString();

                dataGridView2.DataSource = ds;
                if (ds.Tables.Count > 0)
                {
                    dataGridView2.DataMember += "task";
                }
            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
            }
        }
        public void generateContractorListsCSVDocument(string fileName, string date, string element)
        {
            try
            {
                string cnStr =
               "Provider=Microsoft.Jet.OLEDB.4.0;" +
               "Extended Properties='text;HDR=Yes;FMT=Delimited';" +
               "Data Source=" + dir + ";";

                using (var cn = new OleDbConnection(cnStr))
                {
                    cn.Open();

                    //define the file layout (a.k.a. the table)

                    //start pumping data

                    XmlDocument xdoc = new XmlDocument();
                    FileStream rfile = new FileStream(fileName, FileMode.Open);
                    xdoc.Load(rfile);

                    XmlNodeList list = xdoc.GetElementsByTagName(element);
                    for (int i = 0; i < list.Count; i++)
                    {

                        var cmd = new OleDbCommand(
                    "INSERT INTO contractorlists.csv ([Name], [Company], [Phone], [Description], [NextVist], [CertNo], [Date]) VALUES (?, ?, ?, ?, ?, ?, ?)", cn);
                        XmlElement name = (XmlElement)xdoc.GetElementsByTagName("name")[i];
                        XmlElement company = (XmlElement)xdoc.GetElementsByTagName("company")[i];
                        XmlElement phone = (XmlElement)xdoc.GetElementsByTagName("phone")[i];
                        XmlElement description = (XmlElement)xdoc.GetElementsByTagName("description")[i];
                        XmlElement visit = (XmlElement)xdoc.GetElementsByTagName("next_visit")[i];
                        XmlElement cert = (XmlElement)xdoc.GetElementsByTagName("certification_no")[i];

                        cmd.Parameters.AddWithValue("?", name.InnerText);
                        cmd.Parameters.AddWithValue("?", company.InnerText + "");
                        cmd.Parameters.AddWithValue("?", phone.InnerText + "");
                        cmd.Parameters.AddWithValue("?", description.InnerText + "");
                        cmd.Parameters.AddWithValue("?", visit.InnerText + "");
                        cmd.Parameters.AddWithValue("?", cert.InnerText + "");
                        cmd.Parameters.AddWithValue("?", DateTime.Now.ToString());
                        cmd.ExecuteNonQuery();

                    }
                    rfile.Close();
                    cn.Close();

                }
            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
            }
        }
        private void createExtraTasks()
        {
            try
            {

                //if extra tasklist has not yet been generated do it now
                dataBase db = new dataBase();

                XmlDocument xdoc = new XmlDocument();
                FileStream rfile = new FileStream(path + @"tasks\tasklist.xml", FileMode.Open);
                xdoc.Load(rfile);

                XmlNodeList list = xdoc.GetElementsByTagName("task");
                for (int i = 0; i <= list.Count; i++)
                {
                    XmlElement taskName = (XmlElement)xdoc.GetElementsByTagName("task_name")[i];
                    XmlElement frequency = (XmlElement)xdoc.GetElementsByTagName("frequency")[i];

                    if (frequency.InnerText == "weekly")
                    {
                        for (int w = 0; w < 4; w++)
                        {
                            ArrayList element = new ArrayList();
                            ArrayList text = new ArrayList();
                            //the name of the xml element to be added
                            element.Add("task");
                            //the text inside the xml element to be added
                            text.Add(taskName.InnerText);
                            //the name of the xml element to be added
                            element.Add("weekly_or_monthly");
                            //the text inside the xml element to be added
                            text.Add("weekly");
                            //the name of the xml element to be added
                            element.Add("completed");
                            //the text inside the xml element to be added
                            text.Add("false");
                            //the name of the xml element to be added
                            element.Add("date_completed");
                            //the text inside the xml element to be added
                            text.Add("");
                            //save each task as an xml element
                            db.write(path + @"extra\" + DateTime.Now.ToString("MMMM-yyyy") + ".xml", element, text, "extra_tasks");
                        }
                    }
                    else if (frequency.InnerText == "two_monthly")
                    {
                        string date = xdoc.GetElementsByTagName("month")[i].InnerText;

                        DateTime startDate = DateTime.Now;

                            if (date == startDate.AddMonths(2).ToString("MMMM")
                             || date == startDate.AddMonths(4).ToString("MMMM")
                             || date == startDate.AddMonths(6).ToString("MMMM")
                             || date == startDate.AddMonths(8).ToString("MMMM")
                             || date == startDate.AddMonths(10).ToString("MMMM")
                             || date == startDate.AddMonths(12).ToString("MMMM"))
                            {

                                ArrayList element = new ArrayList();
                                ArrayList text = new ArrayList();
                                //the name of the xml element to be added
                                element.Add("task");
                                //the text inside the xml element to be added
                                text.Add(taskName.InnerText);
                                //the name of the xml element to be added
                                element.Add("weekly_or_monthly");
                                //the text inside the xml element to be added
                                text.Add(frequency.InnerText);
                                //the name of the xml element to be added
                                element.Add("completed");
                                //the text inside the xml element to be added
                                text.Add("false");
                                //the name of the xml element to be added
                                element.Add("date_completed");
                                //the text inside the xml element to be added
                                text.Add("");
                                //save each task as an xml element
                                db.write(path + @"extra\" + DateTime.Now.ToString("MMMM-yyyy") + ".xml", element, text, "extra_tasks");
                            }

                            else {  }

                    }

                    else if (frequency.InnerText == "three_monthly")
                    {
                        string date = xdoc.GetElementsByTagName("date")[i].ToString();
                        if (getMonthAsInt(date) == getMonthAsInt(date) || getMonthAsInt(date) == getMonthAsInt(date) + 3)
                        {
                            ArrayList element = new ArrayList();
                            ArrayList text = new ArrayList();
                            //the name of the xml element to be added
                            element.Add("task");
                            //the text inside the xml element to be added
                            text.Add(taskName.InnerText);
                            //the name of the xml element to be added
                            element.Add("weekly_or_monthly");
                            //the text inside the xml element to be added
                            text.Add(frequency.InnerText);
                            //the name of the xml element to be added
                            element.Add("completed");
                            //the text inside the xml element to be added
                            text.Add("false");
                            //the name of the xml element to be added
                            element.Add("date_completed");
                            //the text inside the xml element to be added
                            text.Add("");
                            //save each task as an xml element
                        }
                    }
                    else if (frequency.InnerText == "six_monthly")
                    {
                        DateTime startDate = DateTime.Now;
                        string date = xdoc.GetElementsByTagName("month")[i].ToString();
                           if  (date == startDate.AddMonths(6).ToString("MMMM")
                             || date == startDate.AddMonths(12).ToString("MMMM"))

                        {
                            ArrayList element = new ArrayList();
                            ArrayList text = new ArrayList();
                            //the name of the xml element to be added
                            element.Add("task");
                            //the text inside the xml element to be added
                            text.Add(taskName.InnerText);
                            //the name of the xml element to be added
                            element.Add("weekly_or_monthly");
                            //the text inside the xml element to be added
                            text.Add(frequency.InnerText);
                            //the name of the xml element to be added
                            element.Add("completed");
                            //the text inside the xml element to be added
                            text.Add("false");
                            //the name of the xml element to be added
                            element.Add("date_completed");
                            //the text inside the xml element to be added
                            text.Add("");
                            //save each task as an xml element
                        }
                    }
                    else if (frequency.InnerText == "monthly")
                    {
                        ArrayList element = new ArrayList();
                        ArrayList text = new ArrayList();
                        //the name of the xml element to be added
                        element.Add("task");
                        //the text inside the xml element to be added
                        text.Add(taskName.InnerText);
                        //the name of the xml element to be added
                        element.Add("weekly_or_monthly");
                        //the text inside the xml element to be added
                        text.Add(frequency.InnerText);
                        //the name of the xml element to be added
                        element.Add("completed");
                        //the text inside the xml element to be added
                        text.Add("false");
                        //the name of the xml element to be added
                        element.Add("date_completed");
                        //the text inside the xml element to be added
                        text.Add("");
                        //save each task as an xml element

                        db.write(path + @"extra\" + DateTime.Now.ToString("MMMM-yyyy") + ".xml", element, text, "extra_tasks");
                    }
                    else { }

                    rfile.Close();
                }
            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
            }
        }
        public void startUp()
        {
            try
            {
                dataBase db = new dataBase();
                fileFolder ff = new fileFolder();
                //check the core folder database exists - if not create it
                ff.createFolder(path);
                ff.createFolder(path + @"extra\");
                ff.createFolder(path + @"tasks\");
                ff.createFolder(path + @"maintenence\");
                ff.createFolder(path + @"maintenence\inventory\");
                ff.createFolder(path + @"contractors\");
                ff.createFolder(path + @"contractors\lists\");
                ff.createFolder(path + @"\contractors\providers\lists\");
                ff.createFolder(Application.StartupPath + @"\database\config\");
                ff.createFolder(Application.StartupPath + @"\database\temp\");

                db.create("contractor_lists", path + @"\contractors\lists\contractors.xml");
                db.create("contractors_today", path + @"\contractors\" + fileNameDate + ".xml");
                db.create("provider_lists", path + @"\contractors\providers\lists\providers.xml");

                //check if tasks xml datbase exists
                db.create("tasks", path + @"tasks\tasklist.xml");
                if (db.create("extra_tasks", path + @"extra\" + DateTime.Now.ToString("MMMM-yyyy") + ".xml"))
                {
                    createExtraTasks();
                }

                //check if todays tasks xml datbase exists
                if (db.create("root", path + DateTime.Now.ToString("d-MM-yyyy") + ".xml"))
                {
                    //file does not exist returns true - create todays tasks
                    createTodaysTasks();
                }
                db.create("inventory", path + @"maintenence\inventory\list.xml");
                db.create("item_maintenence", path + @"maintenence\"+fileNameDate+".xml");

                //check for update

            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
            }
        }
Example #8
0
        private void exportProvidersToCSV()
        {
            try
            {
                //first step is too check if temp file exists and if it does delete it
                //to start again
                if (File.Exists(Application.StartupPath + @"\database\temp\providers.csv"))
                {
                    File.Delete(Application.StartupPath + @"\database\temp\providers.csv");
                }
                //now we get the value of all input and selection fields and convert them to appropriate data type
                exportToCSV CSV = new exportToCSV();
                CSV.createProvidersCSVDocument();
                string year = textBoxSaveToCSVEndYear.Text;

                try
                {
                    if (File.Exists(Application.StartupPath + @"\database\" + year + @"\contractors\providers\lists\providers.xml"))
                    {

                        CSV.generateProvidersCSVDocument(Application.StartupPath + @"\database\" + year + @"\contractors\providers\lists\providers.xml",
                        DateTime.Now.ToString("d/MM/yyyy"), "provider");
                    }

                }
                catch (Exception err)
                {
                    debugTerminal terminal = new debugTerminal();
                    terminal.output(err.ToString());
                }

                //now we let the user save the temp excel file
                SaveFileDialog save = new SaveFileDialog();
                save.Filter = "Excel|*.CSV";
                save.FileName = "myProvidersList.csv";
                progressBar1.Value = 50;

                save.ShowDialog();
                File.Copy(Application.StartupPath + @"\database\temp\providers.csv", save.FileName);
                //exportCSVValidate.Text = "File Saved";
                //delete temp file
                File.Delete(Application.StartupPath + @"\database\temp\providers.csv");
                progressBar1.Value = 100;

            }
            catch (Exception err)
            {

                exportCSVValidate.Text = "File was not saved";
                progressBar1.Value = 0;
                if (File.Exists(Application.StartupPath + @"\database\temp\providers.csv"))
                {
                    File.Delete(Application.StartupPath + @"\database\temp\providers.csv");
                    debugTerminal terminal = new debugTerminal();
                    terminal.output(err.ToString());
                }

            }
        }
Example #9
0
        private void exportMaintenenceToCSV()
        {
            try
            {
                //first step is too check if temp file exists and if it does delete it
                //to start again
                if (File.Exists(Application.StartupPath + @"\database\temp\maintenence.csv"))
                {
                    File.Delete(Application.StartupPath + @"\database\temp\maintenence.csv");
                }
                //now we get the value of all input and selection fields and convert them to appropriate data type
                int sd = Convert.ToInt32(textBoxSaveToCSVStartDate.Text);
                int fd = Convert.ToInt32(textBoxSaveToCSVEndDay.Text);
                if (sd > 0 && sd < 31 && fd > 0 && fd < 31)
                {
                    string sm = comboBoxSaveToCSVStartMonth.Text;
                    string fm = comboBoxSaveToCSVEndMonth.Text;

                    string sy = textBoxSaveToCSVStartYear.Text;
                    string fy = textBoxSaveToCSVEndYear.Text;
                    applicationCore apc = new applicationCore(fileNameDate);
                    exportToCSV CSV = new exportToCSV();

                    //get selected months as numbers
                    int startMonth = apc.getMonthAsInt(sm);
                    int endMonth = apc.getMonthAsInt(fm);

                    int nsy = Convert.ToInt32(sy);
                    int nfy = Convert.ToInt32(fy);

                    //now we get data from each file between te selected time period
                    //based on its date based file name

                    CSV.createMaintenenceCSVDocument();

                    //loop through years
                    for (int y = nsy; y <= nfy; y++)
                    {
                        //loop through months
                        for (int m = startMonth; m <= endMonth; m++)
                        {

                            //loop through days
                            for (int d = sd; d <= 31; d++)
                            {
                                try
                                {
                                    if (File.Exists(Application.StartupPath + @"\database\" + y + @"\maintenence\" + d + "-" + m + "-" + y + ".xml"))
                                    {

                                        CSV.generateMaintenenceCSVDocument(Application.StartupPath + @"\database\" + y + @"\maintenence\" + d + "-" + m + "-" + y + ".xml",
                                        DateTime.Now.ToString("d/MM/yyyy"), "item");
                                    }

                                }
                                catch (Exception err)
                                {
                                    debugTerminal terminal = new debugTerminal();
                                    terminal.output(err.ToString());
                                }
                            }
                        }
                    }
                    //now we let the user save the temp excel file
                    SaveFileDialog save = new SaveFileDialog();
                    save.Filter = "Excel|*.CSV";
                    save.FileName = "myMaintenenceCheckList.csv";
                    progressBar1.Value = 50;

                    save.ShowDialog();
                    File.Copy(Application.StartupPath + @"\database\temp\maintenence.csv", save.FileName);
                    //exportCSVValidate.Text = "File Saved";
                    //delete temp file
                    File.Delete(Application.StartupPath + @"\database\temp\maintenence.csv");
                    progressBar1.Value = 100;
                }

                else
                {
                    exportCSVValidate.Text = "The days added were not correct month numbers";
                }
            }
            catch (Exception err)
            {

                exportCSVValidate.Text = "File was not saved";
                progressBar1.Value = 0;
                if (File.Exists(Application.StartupPath + @"\database\temp\maintenence.csv"))
                {
                    File.Delete(Application.StartupPath + @"\database\temp\maintenence.csv");
                    debugTerminal terminal = new debugTerminal();
                    terminal.output(err.ToString());
                }
            }
        }
Example #10
0
        private void datasetToXml(string fileName, int dgv)
        {
            try
            {
                DataSet ds = new DataSet();
                switch (dgv)
                {
                    case 1:
                        ds = (DataSet)dataGridView1.DataSource;
                        for (int i = 0; i < ds.Tables.Count; i++)
                        {
                            ds.Tables[i].WriteXml(fileName, System.Data.XmlWriteMode.IgnoreSchema);
                            loadTodaysTasks(selectedDate);
                            labelTodaysTasksUpdate.Text = "Tasks Succesfully Updated";
                        }
                        break;
                    case 2:

                        ds = (DataSet)dataGridView2.DataSource;
                        for (int i = 0; i < ds.Tables.Count; i++)
                        {

                            ds.Tables[i].WriteXml(fileName, System.Data.XmlWriteMode.IgnoreSchema);
                            loadTodaysTasks(selectedDate);
                            labelAddTasksUpdate.Text = "Tasks Succesfully Updated";
                        }
                        break;
                    case 3:
                        ds = (DataSet)dataGridView3.DataSource;
                        for (int i = 0; i < ds.Tables.Count; i++)
                        {
                            ds.Tables[i].WriteXml(fileName, System.Data.XmlWriteMode.IgnoreSchema);
                            loadExtraTasks();
                            labelExtraTasksUpdate.Text = "Tasks Succesfully Updated";
                        }
                        break;
                    case 4:
                        ds = (DataSet)dataGridView4.DataSource;
                        for (int i = 0; i < ds.Tables.Count; i++)
                        {
                            ds.Tables[i].WriteXml(fileName, System.Data.XmlWriteMode.IgnoreSchema);
                            loadAllContractors();
                            labelUpdateContractors.Text = "Contractors Succesfully Updated";
                        }
                        break;
                    case 5:
                        ds = (DataSet)dataGridView5.DataSource;
                        for (int i = 0; i < ds.Tables.Count; i++)
                        {
                            ds.Tables[i].WriteXml(fileName, System.Data.XmlWriteMode.IgnoreSchema);
                            loadAllContractors();
                            labelUpdateTodaysContractors.Text = "Contractors Succesfully Updated";
                        }
                        break;
                    case 6:
                        ds = (DataSet)dataGridView6.DataSource;
                        for (int i = 0; i < ds.Tables.Count; i++)
                        {
                            ds.Tables[i].WriteXml(fileName, System.Data.XmlWriteMode.IgnoreSchema);
                            loadAllMaintenceItems(selectedDate);

                        }
                        break;
                    case 7:
                        ds = (DataSet)dataGridView7.DataSource;
                        for (int i = 0; i < ds.Tables.Count; i++)
                        {
                            ds.Tables[i].WriteXml(fileName, System.Data.XmlWriteMode.IgnoreSchema);
                            loadInventoryItems();

                        }
                        break;
                    case 8:
                        ds = (DataSet)dataGridView8.DataSource;
                        for (int i = 0; i < ds.Tables.Count; i++)
                        {
                            ds.Tables[i].WriteXml(fileName, System.Data.XmlWriteMode.IgnoreSchema);
                            loadAllProviders();

                        }
                        break;
                }
            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
            }
        }
Example #11
0
        private void loadInventoryItems()
        {
            try
            {
                applicationCore ap = new applicationCore(fileNameDate);
                DataSet ds = new DataSet();

                ds.ReadXml(ap.path + @"maintenence\inventory\" + "list.xml").ToString();

                dataGridView7.DataSource = ds;
                if (ds.Tables.Count > 0)
                {
                    dataGridView7.DataMember = "items";
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                //error warning
            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
            }
        }
Example #12
0
        private void loadDailyContractors(string date)
        {
            try
            {
                applicationCore ap = new applicationCore(date);
                DataSet ds1 = new DataSet();

                ds1.ReadXml(ap.path + @"\contractors\lists\contractors.xml");
                //load all created contractors into combo boxs
                comboBox1.DataSource = ds1.Tables["contractor"];
                if (ds1.Tables.Count > 0)
                {
                    comboBox1.DisplayMember = "company";
                }

                //load todays contractors into box
                DataSet ds2 = new DataSet();
                ds2.ReadXml(ap.path + @"\contractors\" + date + ".xml");
                if (ds2.Tables.Count > 0)
                {
                    dataGridView5.DataSource = ds2;
                    dataGridView5.DataMember = "visitor";
                }
                else
                {
                    dataGridView5.DataSource = null;
                    labelUpdateTodaysContractors.Text = "There are no records for this day, add one bellow";
                }

            }
            catch (System.IO.FileNotFoundException)
            {
                //error warning
            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
            }
        }
Example #13
0
 private void addItemMaintenenceItem(object sender, EventArgs e)
 {
     try
     {
         dataBase db = new dataBase();
         applicationCore ap = new applicationCore(fileNameDate);
         ArrayList element = new ArrayList();
         //add the xml elements names
         element.Add("area");
         element.Add("room");
         element.Add("item_name");
         element.Add("description");
         element.Add("next_visit");
         ArrayList text = new ArrayList();
         text.Add(textBoxItemMaintenenceArea.Text);
         text.Add(textBoxAddItemMaintenceRoom.Text);
         text.Add(textBoxAddItemMaintenenceItem.Text);
         text.Add(richTextBoxAddItemMaintenceDescription.Text);
         text.Add(textBoxAddContractorNextVisit.Text);
         db.write(ap.path + @"maintenence\" + selectedDate + ".xml",
                         element, text, "item");
         loadAllMaintenceItems(selectedDate);
     }
     catch (Exception err)
     {
         debugTerminal terminal = new debugTerminal();
         terminal.output(err.ToString());
     }
 }
Example #14
0
        public void generateProvidersCSVDocument(string fileName, string date, string element)
        {
            try
            {
                string cnStr =
               "Provider=Microsoft.Jet.OLEDB.4.0;" +
               "Extended Properties='text;HDR=Yes;FMT=Delimited';" +
               "Data Source=" + dir + ";";

                using (var cn = new OleDbConnection(cnStr))
                {
                    cn.Open();

                    //define the file layout (a.k.a. the table)
                    //start pumping data

                    XmlDocument xdoc = new XmlDocument();
                    FileStream rfile = new FileStream(fileName, FileMode.Open);
                    xdoc.Load(rfile);

                    XmlNodeList list = xdoc.GetElementsByTagName(element);
                    for (int i = 0; i < list.Count; i++)
                    {
                        var cmd = new OleDbCommand(
                    "INSERT INTO providers.csv ([Name], [Date Due], [Date Completed]) VALUES (?, ?, ?)", cn);
                        XmlElement name = (XmlElement)xdoc.GetElementsByTagName("name")[i];
                        XmlElement due = (XmlElement)xdoc.GetElementsByTagName("due_date")[i];
                        XmlElement completed = (XmlElement)xdoc.GetElementsByTagName("date_completed")[i];

                        cmd.Parameters.AddWithValue("?", name.InnerText);
                        cmd.Parameters.AddWithValue("?", due.InnerText + "");
                        cmd.Parameters.AddWithValue("?", completed.InnerText + "");

                        cmd.ExecuteNonQuery();
                    }
                    rfile.Close();
                    cn.Close();

                }
            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
            }
        }
Example #15
0
 private void addItemMaintenence(object sender, EventArgs e)
 {
     try
     {
         dataBase db = new dataBase();
         applicationCore ap = new applicationCore(fileNameDate);
         ArrayList element = new ArrayList();
         //add the xml elements names
         element.Add("item");
         element.Add("area");
         element.Add("quantity");
         ArrayList text = new ArrayList();
         text.Add(textBoxAddInventoryItem.Text);
         text.Add(textBoxAddInventoryArea.Text);
         text.Add(textBoxAddInventoryQuantity.Text);
         labelAddInventoryValidate.Text = textBoxAddInventoryItem.Text + " succesfully added";
         textBoxAddInventoryItem.Clear();
         db.write(ap.path + @"maintenence\inventory\" + "list.xml",
                         element, text, "items");
         loadInventoryItems();
     }
     catch (Exception err)
     {
         debugTerminal terminal = new debugTerminal();
         terminal.output(err.ToString());
     }
 }
Example #16
0
        private void AddContractors(object sender, EventArgs e)
        {
            try
            {
                dataBase db = new dataBase();
                applicationCore ap = new applicationCore(fileNameDate);
                ArrayList element = new ArrayList();
                //add the xml elements names
                element.Add("name");
                element.Add("company");
                element.Add("phone");
                element.Add("description");
                element.Add("next_visit");
                element.Add("certification_no");
                ArrayList text = new ArrayList();
                text.Add(textBoxAddContractorName.Text);
                text.Add(textBoxAddContractorCompany.Text);
                text.Add(textBoxAddContractorPhone.Text);
                text.Add(richTextBoxAddContractorDescription.Text);
                text.Add(textBoxAddContractorNextVisit.Text);
                text.Add(textBoxAddContractorCertNumber.Text);

                //if contractor visits is re-occuring
                if (checkBoxAddContractorEveryXMonths.Checked)
                {
                    element.Add("every");
                    element.Add("frequency");
                    text.Add(textBoxAddContractorAmountOfTimeBetweenVisits.Text);
                    text.Add(comboBoxAddContractorPeriodOfTime.Text);
                }

                db.write(ap.path + @"\contractors\lists\contractors.xml",
                                element, text, "contractor");
                labelAddContractorValidate.Text = "Adding contractor succeded";
                loadAllContractors();
            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
                labelAddContractorValidate.Text = "Adding contractor failed";
            }
        }
Example #17
0
        public void loadTodaysTasks(string date)
        {
            try
            {
                applicationCore ap = new applicationCore(fileNameDate);
                DataSet ds = new DataSet();

                ds.ReadXml(ap.path + date + ".xml").ToString();

                dataGridView1.DataSource = ds;
                if (ds.Tables.Count > 0)
                {
                    dataGridView1.DataMember += "tasks";
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                //error warning
            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
            }
        }
Example #18
0
        public void loadExtraTasks()
        {
            try
            {
                applicationCore ap = new applicationCore(fileNameDate);
                DataSet ds = new DataSet();

                ds.ReadXml(ap.path + @"extra\" + DateTime.Now.ToString("MMMM-yyyy") + ".xml").ToString();

                dataGridView3.DataSource = ds;
                if (ds.Tables.Count > 0)
                {
                    dataGridView3.DataMember = "extra_tasks";
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                //error warning
            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
            }
        }
Example #19
0
 private void removeDeletedRowFromOtherTasks(object sender, DataGridViewRowCancelEventArgs e)
 {
     try
     {
         dataBase db = new dataBase();
         applicationCore ap = new applicationCore(fileNameDate);
         //get the name of the task from the deleted row and the first cell
         string deletedTaskValue = (string)dataGridView2.Rows[e.Row.Index].Cells[1].Value;
         string deletedFreqValue = (string)dataGridView2.Rows[e.Row.Index].Cells[2].Value;
         //delete rows with the same task name from other xml files
         if (deletedFreqValue == "daily")
         {
             db.delete(ap.path + fileNameDate + ".xml", "/root/tasks[task='" + deletedTaskValue + "']");
             loadTodaysTasks(selectedDate);
         }
         if (deletedFreqValue == "weekly" || deletedFreqValue == "monthly")
             for (int w = 0; w < 4; w++)
             {
                 db.delete(ap.path + @"extra\" + DateTime.Now.ToString("MMMM-yyyy") + ".xml", "/extra_tasks/extra_tasks[task='" + deletedTaskValue + "']");
             }
         loadExtraTasks();
         //now we update the table
         datasetToXml(ap.path + @"tasks/tasklist.xml", 2);
     }
     catch (Exception err)
     {
         debugTerminal terminal = new debugTerminal();
         terminal.output(err.ToString());
     }
 }
Example #20
0
        public void generateTasksCSVDocument(string fileName, string date, string element)
        {
            try
            {
                string cnStr =
               "Provider=Microsoft.Jet.OLEDB.4.0;" +
               "Extended Properties='text;HDR=Yes;FMT=Delimited';" +
               "Data Source=" + dir + ";";

                using (var cn = new OleDbConnection(cnStr))
                {
                    cn.Open();

                    //define the file layout (a.k.a. the table)

                    //start pumping data

                    XmlDocument xdoc = new XmlDocument();
                    FileStream rfile = new FileStream(fileName, FileMode.Open);
                    xdoc.Load(rfile);

                    XmlNodeList list = xdoc.GetElementsByTagName(element);
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (element == "tasks")
                        {
                            var cmd = new OleDbCommand(
                        "INSERT INTO data.csv ([Date], [Task], [Completed], [Frequency]) VALUES (?, ?, ?, ?)", cn);
                            XmlElement task = (XmlElement)xdoc.GetElementsByTagName("task")[i];
                            XmlElement completed = (XmlElement)xdoc.GetElementsByTagName("completed")[i];

                            cmd.Parameters.AddWithValue("?", date);
                            cmd.Parameters.AddWithValue("?", task.InnerText + "");
                            cmd.Parameters.AddWithValue("?", completed.InnerText + "");
                            cmd.Parameters.AddWithValue("", "daily task");
                            cmd.ExecuteNonQuery();

                        }
                        else if (element == "extra_tasks")
                        {
                            var cmd = new OleDbCommand(
                        "INSERT INTO data.csv ([Date], [Task], [Completed], [Frequency]) VALUES (?, ?, ?, ?)", cn);
                            XmlElement task = (XmlElement)xdoc.GetElementsByTagName("task")[i];
                            XmlElement completed = (XmlElement)xdoc.GetElementsByTagName("completed")[i];
                            XmlElement frequency = (XmlElement)xdoc.GetElementsByTagName("weekly_or_monthly")[i];
                            cmd.Parameters.AddWithValue("?", date);
                            cmd.Parameters.AddWithValue("?", task.InnerText + "");
                            cmd.Parameters.AddWithValue("?", completed.InnerText + "");
                            cmd.Parameters.AddWithValue("?", frequency.InnerText + " task");
                            cmd.ExecuteNonQuery();
                        }
                        else { }
                    }
                    rfile.Close();
                    cn.Close();

                }
            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
            }
        }
Example #21
0
        private void AddProvider(object sender, EventArgs e)
        {
            try
            {
                dataBase db = new dataBase();
                applicationCore ap = new applicationCore(fileNameDate);
                ArrayList element = new ArrayList();
                //add the xml elements names
                element.Add("name");
                element.Add("due_date");
                element.Add("date_completed");
                ArrayList text = new ArrayList();
                text.Add(textBoxAddProvidersName.Text);
                text.Add(textBoxAddProviderDueDate.Text);
                text.Add(textBoxAddProviderDateCompleted.Text);

                db.write(ap.path + @"\contractors\providers\lists\providers.xml",
                                element, text, "provider");
                labelAddProviderValidate.Text = "Adding provider succeded";
                loadAllProviders();
            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
                labelAddProviderValidate.Text = "Adding provider failed";
            }
        }
Example #22
0
        private void addTask(object sender, EventArgs e)
        {
            try
            {
                if (textBoxFutureName.Text.Length > 3)
                {
                    dataBase db = new dataBase();
                    applicationCore ap = new applicationCore(fileNameDate);
                    ArrayList element = new ArrayList();
                    //add the xml elements names
                    element.Add("task_name");
                    element.Add("description");
                    element.Add("frequency");
                    ArrayList text = new ArrayList();

                    //add the xml elements text values
                    text.Add(textBoxFutureName.Text);
                    text.Add("");
                    if (radioButtonDailyTask.Checked) { text.Add("daily"); }
                    else if (radioButtonWeeklyTask.Checked) { text.Add("weekly"); }
                    else if (radioButtonMonthlyTask.Checked) { text.Add("monthly"); }
                    else if (radioButtonTwoMonthly.Checked)
                    {
                        text.Add("two_monthly");
                        element.Add("month");
                        text.Add(DateTime.Now.ToString("MMMM"));
                    }
                    else if (radioButtonThreeMonthly.Checked)
                    {
                        text.Add("three_monthly");
                        element.Add("month");
                        text.Add(DateTime.Now.ToString("MMMM"));
                    }
                    else if (radioButtonSixMonthly.Checked)
                    {
                        text.Add("six_monthly");
                        element.Add("month");
                        text.Add(DateTime.Now.ToString("MMMM"));
                    }

                    //write new task to tasklist
                    db.write(ap.path + @"tasks/tasklist.xml", element, text, "task");

                    loadAllTheTasks();
                    //add/ write the new task to todays task
                    if (radioButtonDailyTask.Checked)
                    {
                        ArrayList elementName = new ArrayList();
                        elementName.Add("task");
                        elementName.Add("description");
                        elementName.Add("completed");
                        ArrayList textValue = new ArrayList();
                        textValue.Add(textBoxFutureName.Text);
                        textValue.Add("");
                        textValue.Add("false");
                        db.write(ap.path + fileNameDate + ".xml", elementName, textValue, "tasks");
                    }
                    if (radioButtonWeeklyTask.Checked)
                    {
                        for (int w = 0; w < 4; w++)
                        {
                            ArrayList elementNameTwo = new ArrayList();
                            elementNameTwo.Add("date");
                            elementNameTwo.Add("task");
                            elementNameTwo.Add("description");
                            elementNameTwo.Add("weekly_or_monthly");
                            elementNameTwo.Add("completed");
                            elementNameTwo.Add("date_completed");
                            ArrayList textValueTwo = new ArrayList();
                            textValueTwo.Add(fileNameDate);
                            textValueTwo.Add(textBoxFutureName.Text);
                            textValueTwo.Add("");
                            textValueTwo.Add("weekly");

                            textValueTwo.Add("false");
                            textValueTwo.Add("");
                            db.write(ap.path + @"extra\" + DateTime.Now.ToString("MMMM-yyyy") + ".xml",
                                elementNameTwo, textValueTwo, "extra_tasks");
                        }
                    }
                    if (radioButtonMonthlyTask.Checked)
                    {
                        ArrayList elementNameTwo = new ArrayList();
                        elementNameTwo.Add("date");
                        elementNameTwo.Add("task");
                        elementNameTwo.Add("description");
                        elementNameTwo.Add("weekly_or_monthly");
                        elementNameTwo.Add("completed");
                        elementNameTwo.Add("date_completed");
                        ArrayList textValueTwo = new ArrayList();
                        textValueTwo.Add(fileNameDate);
                        textValueTwo.Add(textBoxFutureName.Text);
                        textValueTwo.Add("");

                        textValueTwo.Add("monthly");
                        textValueTwo.Add("false");
                        textValueTwo.Add("");
                        db.write(ap.path + @"extra\" + DateTime.Now.ToString("MMMM-yyyy") + ".xml",
                            elementNameTwo, textValueTwo, "extra_tasks");

                    }
                    loadTodaysTasks(selectedDate);
                    loadExtraTasks();

                    labelAddTaskValidate.Text = "Task added succesfully";
                }
                else { labelAddTaskValidate.Text = "Task must not already exist and has to be over three letters long."; }
            }

            catch (Exception err) { labelAddTaskValidate.Text = "Adding task failed";
            debugTerminal terminal = new debugTerminal();
            terminal.output(err.ToString());
            }
        }
Example #23
0
        private void loadAllProviders()
        {
            try
            {
                applicationCore ap = new applicationCore(fileNameDate);
                DataSet ds = new DataSet();

                ds.ReadXml(ap.path + @"\contractors\providers\lists\providers.xml");

                dataGridView8.DataSource = ds;
                if (ds.Tables.Count > 0)
                {
                    dataGridView8.DataMember = "provider";
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                //error warning
            }
            catch (Exception err)
            {
                debugTerminal terminal = new debugTerminal();
                terminal.output(err.ToString());
            }
        }