public static void xmlRefeshlst(Mainfrm GetVar)
        {
            GetVar.lstVxmlin.Items.Clear();
            XDocument doc = XDocument.Load("Resources\\SavedReminders.xml");

            foreach (var dm in doc.Descendants("Reminder"))
            {
                ListViewItem item = new ListViewItem(new string[]
                {
                    dm.Element("PlantName").Value,
                    dm.Element("SowInDoorsDate").Value,
                    dm.Element("SowUnderCoverDate").Value,
                    dm.Element("SowOutDoorsDate").Value,
                    dm.Element("PlantOutDoors").Value,
                    dm.Element("HarvestTimeDate").Value,

                });
                if (item == null)
                {
                    MessageBox.Show("Corrupt XML file!", "Green Fingers Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                GetVar.lstVxmlin.Items.Add(item);
            }
        }
        public static void DelXML(Mainfrm GetVar)
        {
            string lstIn;

            try
            {
                int intselectedindex = GetVar.lstVxmlin.SelectedIndices[0];

                if (intselectedindex >= 0)
                {
                    lstIn           = GetVar.lstVxmlin.SelectedItems[0].ToString();
                    GetVar.lstToTxt = GetVar.lstVxmlin.Items[intselectedindex].Text;
                }

                XDocument xdoc = XDocument.Load("Resources\\SavedReminders.xml");
                xdoc.Descendants("Reminder")
                .Where(x => (string)x.Element("PlantName") == GetVar.lstToTxt)
                .Remove();
                xdoc.Save("Resources\\SavedReminders.xml");
                xmlRefeshlst(GetVar);
            }
            catch (ArgumentOutOfRangeException outOfRange)
            {
                MessageBox.Show("Select the plant name from the reminders list below.", "Green Fingers", MessageBoxButtons.OK, MessageBoxIcon.Information);
                outOfRange = null;
            }
        }
        public static bool RegGetReminderVel(Mainfrm open3)
        {
            try
            {
                RegistryKey myKey2 = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\GreenFingers\AppSettings", false);
                {
                    String value = (String)myKey2.GetValue("ReminderSet");

                    if (value == "0")
                    {
                        open3.btnActivate.Visible = true;
                        return(true);
                    }

                    if (value == "1")
                    {
                        open3.btnDeactivate.Visible = true;
                        DatePopupClass open = new DatePopupClass();
                        open.Datechecker();
                        return(true);
                    }
                }
            }
            catch (Exception e)
            {
                ShowErrorMessages(e, "GetReminderVel Error!");
                return(false);
            }
            return(true);
        }
        public static void DelXML(Mainfrm GetVar)
        {
            string lstIn;
            try
            {
                int intselectedindex = GetVar.lstVxmlin.SelectedIndices[0];

                if (intselectedindex >= 0)
                {
                    lstIn = GetVar.lstVxmlin.SelectedItems[0].ToString();
                    GetVar.lstToTxt = GetVar.lstVxmlin.Items[intselectedindex].Text;
                }

                XDocument xdoc = XDocument.Load("Resources\\SavedReminders.xml");
                xdoc.Descendants("Reminder")
                .Where(x => (string)x.Element("PlantName") == GetVar.lstToTxt)
                .Remove();
                xdoc.Save("Resources\\SavedReminders.xml");
                xmlRefeshlst(GetVar);
            }
            catch (ArgumentOutOfRangeException outOfRange)
            {
                MessageBox.Show("Select the plant name from the reminders list below.", "Green Fingers", MessageBoxButtons.OK, MessageBoxIcon.Information);
                outOfRange = null;
            }
        }
 public static void RegActavate(Mainfrm open2)
 {
     SetReminderAndSystemTray(0); //ReminderSet = 1
     SetReminderAndSystemTray(1); //StartInSystemTray = 1
     open2.btnActivate.Visible   = false;
     open2.btnActivate.Enabled   = false;
     open2.btnDeactivate.Visible = true;
     open2.btnDeactivate.Enabled = true;
 }
 public static void RegDeactivate(Mainfrm open1)
 {
     SetReminderAndSystemTray(2); //ReminderSet = 0
     SetReminderAndSystemTray(3); //StartInSystemTray = 0
     open1.btnDeactivate.Visible = false;
     open1.btnDeactivate.Enabled = false;
     open1.btnActivate.Visible   = true;
     open1.btnActivate.Enabled   = true;
 }
        public static void ExtDB(Mainfrm Send)
        {
            /*
             * Created By Matthew Utin. https://github.com/mattu08/Green-Fingers/
            */

            if (System.IO.File.Exists(@"GreenFingersDB_log.ldf")) { File.Delete("GreenFingersDB_log.ldf"); }
            if (System.IO.File.Exists(@"GreenFingersDB.mdf")) { File.Delete("GreenFingersDB.mdf"); }
            File.WriteAllBytes("GreenFingersDB.mdf", Properties.Resources.GreenFingersDB);
        }
        public static void makeNewXmlFile(Mainfrm GetVar)
        {
            System.IO.File.WriteAllText("Resources\\SavedReminders.xml", string.Empty);
            string xml = (@"<?xml version='1.0' encoding='utf-8'?>
<Reminders>
</Reminders>");

            System.IO.File.WriteAllText(@"Resources\SavedReminders.xml", xml);
            xmlRefeshlst(GetVar);
        }
Example #9
0
        public static void ExtDB(Mainfrm Send)
        {
            /*
             * Created By Matthew Utin. https://github.com/mattu08/Green-Fingers/
             */

            if (System.IO.File.Exists(@"GreenFingersDB_log.ldf"))
            {
                File.Delete("GreenFingersDB_log.ldf");
            }
            if (System.IO.File.Exists(@"GreenFingersDB.mdf"))
            {
                File.Delete("GreenFingersDB.mdf");
            }
            File.WriteAllBytes("GreenFingersDB.mdf", Properties.Resources.GreenFingersDB);
        }
        /*
         * Created By Matthew Utin. https://github.com/mattu08/Green-Fingers/
        */

        public static void SQLOutputToXML(Mainfrm GetVar)
        {
            if (GetVar.Plant_Name == null)
            {
                MessageBox.Show("Select a plant! Or if you do not see anything to select add a plant to the database.", "Green Fingers", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                XDocument xdoc = XDocument.Load(@"Resources\SavedReminders.xml");
                XElement root = new XElement("Reminder");
                root.Add(new XElement("PlantName", GetVar.Plant_Name));
                root.Add(new XElement("SowInDoorsDate", GetVar.Sow_In));
                root.Add(new XElement("SowUnderCoverDate", GetVar.Sow_Un));
                root.Add(new XElement("SowOutDoorsDate", GetVar.Sow_Out));
                root.Add(new XElement("PlantOutDoors", GetVar.Plant_Out));
                root.Add(new XElement("HarvestTimeDate", GetVar.Har_Time));
                root.Add(new XElement("Notes", GetVar.Notes));
                root.Add(new XElement("PlotNumber", GetVar.Plt_Num));
                xdoc.Element("Reminders").Add(root);
                xdoc.Save("Resources\\SavedReminders.xml");
                xmlRefeshlst(GetVar);
            }
        }
        /*
         * Created By Matthew Utin. https://github.com/mattu08/Green-Fingers/
         */

        public static void SQLOutputToXML(Mainfrm GetVar)
        {
            if (GetVar.Plant_Name == null)
            {
                MessageBox.Show("Select a plant! Or if you do not see anything to select add a plant to the database.", "Green Fingers", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                XDocument xdoc = XDocument.Load(@"Resources\SavedReminders.xml");
                XElement  root = new XElement("Reminder");
                root.Add(new XElement("PlantName", GetVar.Plant_Name));
                root.Add(new XElement("SowInDoorsDate", GetVar.Sow_In));
                root.Add(new XElement("SowUnderCoverDate", GetVar.Sow_Un));
                root.Add(new XElement("SowOutDoorsDate", GetVar.Sow_Out));
                root.Add(new XElement("PlantOutDoors", GetVar.Plant_Out));
                root.Add(new XElement("HarvestTimeDate", GetVar.Har_Time));
                root.Add(new XElement("Notes", GetVar.Notes));
                root.Add(new XElement("PlotNumber", GetVar.Plt_Num));
                xdoc.Element("Reminders").Add(root);
                xdoc.Save("Resources\\SavedReminders.xml");
                xmlRefeshlst(GetVar);
            }
        }
 public static bool RegGetSysTVel(Mainfrm open4)
 {
     try
     {
         RegistryKey myKeys1 = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\GreenFingers\AppSettings", false);
         {
             String values = (String)myKeys1.GetValue("StartInSystemTray");
             if (values == "1")
             {
                 open4.Visible       = false;
                 open4.ShowInTaskbar = false;
                 open4.Opacity       = 0;
                 return(true);
             }
         }
     }
     catch (Exception e)
     {
         ShowErrorMessages(e, "Could not get system Tray value!");
         return(false);
     }
     return(true);
 }
        public static void xmlRefeshlst(Mainfrm GetVar)
        {
            GetVar.lstVxmlin.Items.Clear();
            XDocument doc = XDocument.Load("Resources\\SavedReminders.xml");

            foreach (var dm in doc.Descendants("Reminder"))
            {
                ListViewItem item = new ListViewItem(new string[]
                {
                    dm.Element("PlantName").Value,
                    dm.Element("SowInDoorsDate").Value,
                    dm.Element("SowUnderCoverDate").Value,
                    dm.Element("SowOutDoorsDate").Value,
                    dm.Element("PlantOutDoors").Value,
                    dm.Element("HarvestTimeDate").Value,
                });
                if (item == null)
                {
                    MessageBox.Show("Corrupt XML file!", "Green Fingers Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                GetVar.lstVxmlin.Items.Add(item);
            }
        }
 public static bool RegGetSysTVel(Mainfrm open4)
 {
     try
     {
         RegistryKey myKeys1 = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\GreenFingers\AppSettings", false);
         {
             String values = (String)myKeys1.GetValue("StartInSystemTray");
             if (values == "1")
             {
                 open4.Visible = false;
                 open4.ShowInTaskbar = false;
                 open4.Opacity = 0;
                 return true;
             }
         }
     }
     catch (Exception e)
     {
         ShowErrorMessages(e, "Could not get system Tray value!");
         return false;
     }
     return true;
 }
 public static void RegDeactivate(Mainfrm open1)
 {
     SetReminderAndSystemTray(2); //ReminderSet = 0
     SetReminderAndSystemTray(3); //StartInSystemTray = 0
     open1.btnDeactivate.Visible = false;
     open1.btnDeactivate.Enabled = false;
     open1.btnActivate.Visible = true;
     open1.btnActivate.Enabled = true;
 }
 public static void RegActavate(Mainfrm open2)
 {
     SetReminderAndSystemTray(0); //ReminderSet = 1
     SetReminderAndSystemTray(1); //StartInSystemTray = 1
     open2.btnActivate.Visible = false;
     open2.btnActivate.Enabled = false;
     open2.btnDeactivate.Visible = true;
     open2.btnDeactivate.Enabled = true;
 }
        public static bool RegGetReminderVel(Mainfrm open3)
        {
            try
            {
                RegistryKey myKey2 = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\GreenFingers\AppSettings", false);
                {
                    String value = (String)myKey2.GetValue("ReminderSet");
                    
                    if (value == "0")
                    {
                        open3.btnActivate.Visible = true;
                        return true;
                    }

                    if (value == "1")
                    {
                        open3.btnDeactivate.Visible = true;
                        DatePopupClass open = new DatePopupClass();
                        open.Datechecker();
                        return true;
                    }
                }
            }
            catch (Exception e)
            {
                ShowErrorMessages(e, "GetReminderVel Error!");
                return false;
            }
            return true;
        }
        public static void ExtGetDB(Mainfrm send)
        {
            /*
             * Created By Matthew Utin. https://github.com/mattu08/Green-Fingers/
            */
            string ConString = Properties.Settings.Default.GreenFingersDBConn;

            try
            {
                using (SqlConnection Conn = new SqlConnection(ConString))
                {
                    string strGf = "SELECT * FROM GreenFingers WHERE [Plant Name] = @List_Var";
                    SqlCommand SqlCmd = new SqlCommand(strGf, Conn);
                    SqlCmd.Parameters.AddWithValue("@List_Var", send.Get_SQL_List_Var);
                    Conn.Open();

                    SqlDataReader GfReader = SqlCmd.ExecuteReader();

                    if (GfReader.HasRows)
                    {
                        while (GfReader.Read())
                        {
                            if (GfReader["ID"] == null) { send.S_Id = "N/A"; }
                            else { send.S_Id = GfReader["ID"].ToString(); }

                            if (GfReader["Plant Name"] == null) { send.Plant_Name = "N/A"; }
                            else { send.Plant_Name = GfReader["Plant Name"].ToString(); }

                            if (GfReader["Sow Indoors"] == null) { send.Sow_In = "N/A"; }
                            else { send.Sow_In = GfReader["Sow Indoors"].ToString(); }

                            if (GfReader["Sow Under Cover"] == null) { send.Sow_Un = "N/A"; }
                            else { send.Sow_Un = GfReader["Sow Under Cover"].ToString(); }

                            if (GfReader["Sow Outdoors"] == null) { send.Sow_Out = "N/A"; }
                            else { send.Sow_Out = GfReader["Sow Outdoors"].ToString(); }

                            if (GfReader["Plant Out"] == null) { send.Plant_Out = "N/A"; }
                            else { send.Plant_Out = GfReader["Plant Out"].ToString(); }

                            if (GfReader["Harvest Time"] == null) { send.Har_Time = "N/A"; }
                            else { send.Har_Time = GfReader["Harvest Time"].ToString(); }

                            if (GfReader["Notes"] == null) { send.Notes = "N/A"; }
                            else { send.Notes = GfReader["Notes"].ToString(); }

                            if (GfReader["Plot Number/Name"] == null) { send.Plt_Num = "N/A"; }
                            else { send.Plt_Num = GfReader["Plot Number/Name"].ToString(); }
                        }
                    }
                    else
                    {
                        //Console.WriteLine("No Rows found.");
                    }
                    GfReader.Close();
                    Conn.Close();
                }
            }
            catch (System.Data.SqlClient.SqlException sqlException)
            {
                System.Windows.Forms.MessageBox.Show(sqlException.Message);
            }
        }
        public static void ExtGetDB(Mainfrm send)
        {
            /*
             * Created By Matthew Utin. https://github.com/mattu08/Green-Fingers/
             */
            string ConString = Properties.Settings.Default.GreenFingersDBConn;

            try
            {
                using (SqlConnection Conn = new SqlConnection(ConString))
                {
                    string     strGf  = "SELECT * FROM GreenFingers WHERE [Plant Name] = @List_Var";
                    SqlCommand SqlCmd = new SqlCommand(strGf, Conn);
                    SqlCmd.Parameters.AddWithValue("@List_Var", send.Get_SQL_List_Var);
                    Conn.Open();

                    SqlDataReader GfReader = SqlCmd.ExecuteReader();

                    if (GfReader.HasRows)
                    {
                        while (GfReader.Read())
                        {
                            if (GfReader["ID"] == null)
                            {
                                send.S_Id = "N/A";
                            }
                            else
                            {
                                send.S_Id = GfReader["ID"].ToString();
                            }

                            if (GfReader["Plant Name"] == null)
                            {
                                send.Plant_Name = "N/A";
                            }
                            else
                            {
                                send.Plant_Name = GfReader["Plant Name"].ToString();
                            }

                            if (GfReader["Sow Indoors"] == null)
                            {
                                send.Sow_In = "N/A";
                            }
                            else
                            {
                                send.Sow_In = GfReader["Sow Indoors"].ToString();
                            }

                            if (GfReader["Sow Under Cover"] == null)
                            {
                                send.Sow_Un = "N/A";
                            }
                            else
                            {
                                send.Sow_Un = GfReader["Sow Under Cover"].ToString();
                            }

                            if (GfReader["Sow Outdoors"] == null)
                            {
                                send.Sow_Out = "N/A";
                            }
                            else
                            {
                                send.Sow_Out = GfReader["Sow Outdoors"].ToString();
                            }

                            if (GfReader["Plant Out"] == null)
                            {
                                send.Plant_Out = "N/A";
                            }
                            else
                            {
                                send.Plant_Out = GfReader["Plant Out"].ToString();
                            }

                            if (GfReader["Harvest Time"] == null)
                            {
                                send.Har_Time = "N/A";
                            }
                            else
                            {
                                send.Har_Time = GfReader["Harvest Time"].ToString();
                            }

                            if (GfReader["Notes"] == null)
                            {
                                send.Notes = "N/A";
                            }
                            else
                            {
                                send.Notes = GfReader["Notes"].ToString();
                            }

                            if (GfReader["Plot Number/Name"] == null)
                            {
                                send.Plt_Num = "N/A";
                            }
                            else
                            {
                                send.Plt_Num = GfReader["Plot Number/Name"].ToString();
                            }
                        }
                    }
                    else
                    {
                        //Console.WriteLine("No Rows found.");
                    }
                    GfReader.Close();
                    Conn.Close();
                }
            }
            catch (System.Data.SqlClient.SqlException sqlException)
            {
                System.Windows.Forms.MessageBox.Show(sqlException.Message);
            }
        }
        public static void makeNewXmlFile(Mainfrm GetVar)
        {
            System.IO.File.WriteAllText("Resources\\SavedReminders.xml", string.Empty);
            string xml = (@"<?xml version='1.0' encoding='utf-8'?>
<Reminders>
</Reminders>");
            System.IO.File.WriteAllText(@"Resources\SavedReminders.xml", xml);
            xmlRefeshlst(GetVar);
        }