示例#1
0
        private void Treatment_Wizzard_Finish(object sender, EventArgs e)
        {
            int id = Assets.GetNewId("treatments");

            if (id == -1)
            {
                MessageBox.Show(Access.ExplaindError());
                return;
            }
            try
            {
                List <object> list = new List <object>()
                {
                    id,
                    Treatment_Name.Text,
                    Treatment_Decription.Text,
                    int.Parse(Treatment_Price.Text)
                };
                if (Access.Execute(SQL_Queries.Insert("treatments", list)))
                {
                    MessageBox.Show("טיפול חדש נכנס לטיפול");
                    Refresh_Screen();
                }
                else
                {
                    MessageBox.Show(Access.ExplaindError());
                }
            }
            catch
            {
            }
        }
示例#2
0
 public static bool InsertCar()
 {
     bool execute = true;
     foreach(List<object>car in cars)
         execute &= Access.Execute(SQL_Queries.Insert("cars", car));
     return execute;
 }
        public static FidoReturnValues SQLFidoReturnValues(FidoReturnValues lFidoReturnValues, string sSrcIP, string sHostname)
        {
            //go to our sysmgmt data sources in the XML to get SQL queries and strings
            var sSQLSource    = SQL_Queries.GetSqlSources();
            var sLandeskSrcIP = String.Empty;

            foreach (var source in sSQLSource)
            {
                // ReSharper disable once RedundantAssignment
                var    lQuery       = new List <string>();
                var    lHostInfo    = new List <string>();
                string sNewSource   = null;
                var    sSplitSource = source.Split('-');
                sNewSource = sSplitSource.Length > 1 ? sSplitSource[0] : source;

                switch (sNewSource)
                {
                case "landesk":

                    sLandeskSrcIP = SourceLandesk(ref lFidoReturnValues, sSrcIP, sHostname, sNewSource, sLandeskSrcIP, source, lHostInfo);

                    continue;

                case "jamf":

                    //if nmap or ssh is null use IP
                    SetHostInfo(sHostname, sSrcIP, source, lHostInfo);

                    //if return has values assign to lFidoReturnValues
                    if (lHostInfo[0] != "unknown")
                    {
                        if ((lFidoReturnValues.Landesk != null) && !String.IsNullOrEmpty(lFidoReturnValues.Landesk.Hostname))
                        {
                            var LandeskDateTime = Convert.ToDateTime(lFidoReturnValues.Landesk.LastUpdate);
                            var JamfDateTime    = FromEpochTime(lHostInfo[3]);

                            if (LandeskDateTime.ToUniversalTime() > JamfDateTime)
                            {
                                continue;
                            }
                        }
                        lFidoReturnValues.Hostname = lHostInfo[1];
                        lFidoReturnValues.Username = lHostInfo[11];
                        if (lFidoReturnValues.Jamf == null)
                        {
                            lFidoReturnValues.Jamf = new JamfReturnValues();
                        }

                        lFidoReturnValues.Jamf = Jamf2FidoValues.Convert(lFidoReturnValues, lHostInfo);
                    }

                    continue;

                default:
                    continue;
                }
            }
            return(lFidoReturnValues);
        }
示例#4
0
        public static bool updateWorker()
        {
            Row       columes = new Row( );
            Condition con     = new Condition("id", int.Parse(worker.GetColValue("id").ToString()));

            columes.AddColume(new Col("password", worker.GetColValue("password")));
            return(Access.Execute(SQL_Queries.Update("workers", columes.GetColumes(), con)));
        }
示例#5
0
        public static bool InsertCar(List <object> values)
        {
            bool execute = Access.Execute(SQL_Queries.Insert("cars", values));

            if (execute)
            {
                Refresh();
            }
            return(execute);
        }
示例#6
0
        public static bool DeleteCar(int number)
        {
            bool execute = Access.Execute(SQL_Queries.Delete("cars", new Condition("car_number", number)));

            if (execute)
            {
                Refresh();
            }
            return(execute);
        }
示例#7
0
        public static bool DeleteTreatment()
        {
            if (Selected_Treatment == -1)
            {
                return(false);
            }
            Condition condition = new Condition("id", int.Parse(GetValue("id")));

            return(Access.Execute(SQL_Queries.Delete("treatments", condition)));
        }
示例#8
0
        public static bool UpdateTreatment(List <Col> values)
        {
            if (Selected_Treatment == -1)
            {
                return(false);
            }
            Condition condition = new Condition("id", int.Parse(GetValue("id")));

            return(Access.Execute(SQL_Queries.Update("treatments", values, condition)));
        }
示例#9
0
 public bool remove_user()
 {
     try
     {
         bool execute = Access.Execute(SQL_Queries.Delete("people", new Condition("id", int.Parse(id))));
         Assets.Refresh();
         return(execute);
     }
     catch
     {
         return(false);
     }
 }
示例#10
0
文件: Assets.cs 项目: alon4551/Garage
        public static int GetNewId(string name)
        {
            List <Row> table = Access.getObjects(SQL_Queries.Select(name));

            if (table != null)
            {
                try
                {
                    return(int.Parse(table[table.Count - 1].GetColValue(0).ToString()) + 1);
                }
                catch (Exception err) { }
            }
            return(-1);
        }
示例#11
0
        public static void Exit(int id)
        {
            string query;

            foreach (Row row in Assets.shifts)
            {
                if (row.GetColValue("end_shift").ToString() == "not")
                {
                    row.UpdateColume(new Col("end_shift", DateTime.Today.ToShortTimeString()));
                    query = SQL_Queries.Update("shifts", row.GetColumes(), new Condition("shift", row.GetColValue("shift")));
                    Access.Execute(query);
                }
            }
        }
        private static List <string> SetHostInfo(string sHostname, string sLandeskSrcIP, string source, List <string> lHostInfo)
        {
            List <string> lQuery;

            //if nmap or ssh is null
            if (String.IsNullOrEmpty(sHostname))
            {
                lQuery = SQL_Queries.GetSqlConfigs(source);
                lHostInfo.AddRange(SQL_Queries.RunMSsqlQuery(lQuery, sLandeskSrcIP, null));
            }
            else
            {
                lQuery = SQL_Queries.GetSqlConfigs(source);
                lHostInfo.AddRange(SQL_Queries.RunMSsqlQuery(lQuery, null, sHostname));
            }

            return(lQuery);
        }
示例#13
0
        public static bool UpdateUser(List <Col> update)
        {
            bool execute = Access.Execute(SQL_Queries.Update("people", update, new Condition("id", user_id)));

            if (execute)
            {
                foreach (Col col in update)
                {
                    if (col.GetField() == "id")
                    {
                        user_id = (int)(col.GetValue());
                        break;
                    }
                }
                user.UpdateColume(update);
                GetUserInfo();
            }
            return(execute);
        }
示例#14
0
        public static bool Enter(int id)
        {
            List <object> list = new List <object>()
            {
                getLastShift() + 1,
                id,
                DateTime.Today.ToShortDateString(),
                DateTime.Today.ToShortTimeString(),
                "not"
            };
            string query = SQL_Queries.Insert("shifts", list);

            if (Access.Execute(query))
            {
                Assets.Reload_Shifts();
                return(true);
            }
            return(false);
        }
示例#15
0
 private void Worker_Register_Finish(object sender, EventArgs e)
 {
     if (Wizzard_Helper.inputValidator(Worker_Profile_Panel) &&
         Wizzard_Helper.inputValidator(Worker_User_panel))
     {
         try
         {
             List <object> profile = new List <object>()
             {
                 int.Parse(Worker_Id.Text),
                 Worker_fname.Text,
                 Worker_lname.Text,
                 Worker_Bdate.Value.ToShortDateString(),
                 Worker_gender.Text,
                 Worker_phone.Text,
                 Worker_email.Text,
             }, user = new List <object>()
             {
                 int.Parse(Worker_Id.Text),
                 Worker_password.Text,
                 Worker_Admin.Checked
             };
             if (Access.Execute(SQL_Queries.Insert("people", profile)) && Access.Execute(SQL_Queries.Insert("workers", user)))
             {
                 Refresh_Screen();
                 MessageBox.Show("inserted");
             }
             else
             {
                 MessageBox.Show(Access.ExplaindError());
                 Access.Execute(SQL_Queries.Delete("people", new Condition("id", int.Parse(Worker_Id.Text))));
             }
         }
         catch
         {
         }
     }
     else
     {
         MessageBox.Show("אנא מלא את השדות החסרים");
     }
 }
示例#16
0
        public static bool UpdateCar(List <Col> update, int number)
        {
            MessageBox.Show(SQL_Queries.Update("cars", update, new Condition("number", number)));
            bool execute = Access.Execute(SQL_Queries.Update("cars", update, new Condition("car_number", number)));

            if (execute)
            {
                foreach (Row row in cars)
                {
                    if (row.GetColValue("car_number").ToString() == number.ToString())
                    {
                        row.UpdateColume(update);
                        break;
                    }
                }
                Refresh();
            }

            return(execute);
        }
示例#17
0
        public static void FilterOrders(List <CheckBox> boxes, List <object> values)
        {
            List <Condition> conditions = new List <Condition>();
            List <Row>       table      = new List <Row>();

            filter_Orders.Clear();
            conditions.Add(new Condition("customer", user_id));
            bool   num   = false;
            string value = "";

            for (int i = 0; i < boxes.Count; i++)
            {
                if (boxes[i].Name != "recipt")
                {
                    conditions.Add(Create_Condition(boxes[i], values[i]));
                }
                else
                {
                    num   = true;
                    value = values[i].ToString();
                }
            }
            if (num)
            {
                table = Access.getObjects(SQL_Queries.Select("orders", conditions, "and"));
                foreach (Row row in table)
                {
                    if (row.GetColValue("id").ToString().Contains(value))
                    {
                        filter_Orders.Add(row);
                    }
                }
            }
            else
            {
                filter_Orders = Access.getObjects(SQL_Queries.Select("orders", conditions, "and"));
            }
        }
示例#18
0
文件: Assets.cs 项目: alon4551/Garage
 public static void Reload_Orders()
 {
     orders = Access.getObjects(SQL_Queries.Select("orders"));
 }
示例#19
0
文件: Assets.cs 项目: alon4551/Garage
 public static void Reload_Order_Treatments()
 {
     order_treatments = Access.getObjects(SQL_Queries.Select("order_treatment"));
 }
示例#20
0
文件: Assets.cs 项目: alon4551/Garage
 public static void Reload_Shifts()
 {
     shifts = Access.getObjects(SQL_Queries.Select("shifts"));
 }
示例#21
0
文件: Assets.cs 项目: alon4551/Garage
 public static void Reload_Manufactors()
 {
     manufactors = Access.getObjects(SQL_Queries.Select("manfuactors"));
 }
示例#22
0
文件: Assets.cs 项目: alon4551/Garage
 public static void Reload_Models()
 {
     models = Access.getObjects(SQL_Queries.Select("models"));
 }
示例#23
0
文件: Assets.cs 项目: alon4551/Garage
 public static void Reload_Treatments()
 {
     treatments = Access.getObjects(SQL_Queries.Select("treatments"));
 }
示例#24
0
文件: Assets.cs 项目: alon4551/Garage
 public static void Reload_Cars()
 {
     cars = Access.getObjects(SQL_Queries.Select("cars"));
 }
示例#25
0
文件: Assets.cs 项目: alon4551/Garage
 public static void Reload_Workers()
 {
     workers = Access.getObjects(SQL_Queries.Select("workers"));
 }
示例#26
0
文件: Assets.cs 项目: alon4551/Garage
 public static void Reload_People()
 {
     users = Access.getObjects(SQL_Queries.Select("people"));
 }
示例#27
0
        public static FidoReturnValues SQLFidoReturnValues(FidoReturnValues lFidoReturnValues, string sSrcIP, string sHostname)
        {
            //go to our sysmgmt data sources in the XML to get SQL queries and strings
            var sSQLSource    = SQL_Queries.GetSqlSources();
            var sLandeskSrcIP = String.Empty;

            foreach (var source in sSQLSource)
            {
                // ReSharper disable once RedundantAssignment
                var    lQuery       = new List <string>();
                var    lHostInfo    = new List <string>();
                string sNewSource   = null;
                var    sSplitSource = source.Split('-');
                sNewSource = sSplitSource.Length > 1 ? sSplitSource[0] : source;

                switch (sNewSource)
                {
                case "landesk":

                    //this is a hack needed to reformat the srcip if Landesk is used
                    //because landesk stores IPs in 000.000.000.000 format Where each
                    //octet needs 3 numbers.
                    if ((sNewSource.ToLower() == "landesk") && (!String.IsNullOrEmpty(sSrcIP)))
                    {
                        sLandeskSrcIP = SysmgmtLandesk.FormatIP(sSrcIP);
                    }


                    //if nmap or ssh is null
                    if (String.IsNullOrEmpty(sHostname))
                    {
                        lQuery = SQL_Queries.GetSqlConfigs(source);
                        lHostInfo.AddRange(SQL_Queries.RunMSsqlQuery(lQuery, sLandeskSrcIP, null));
                    }
                    else
                    {
                        lQuery = SQL_Queries.GetSqlConfigs(source);
                        lHostInfo.AddRange(SQL_Queries.RunMSsqlQuery(lQuery, null, sHostname));
                    }

                    //if return has values assign to lFidoReturnValues
                    if (lHostInfo[0] != "unknown")
                    {
                        lFidoReturnValues.Hostname = lHostInfo[0];
                        if (lFidoReturnValues.Landesk == null)
                        {
                            lFidoReturnValues.Landesk = new LandeskReturnValues();
                        }

                        //format return from Landesk to Fido object
                        lFidoReturnValues = Landesk2FidoValues.LandesklFidoValues(lFidoReturnValues, lHostInfo);

                        //query Landesk to get more system information
                        lFidoReturnValues = SysmgmtLandesk.GetHostOsInfo(lFidoReturnValues, lQuery[0]);

                        //query to get total # of vulns for the machine
                        lFidoReturnValues.Landesk.Patches = SysmgmtLandesk.GetVulns(lFidoReturnValues.Hostname, lQuery[0]);

                        //query to get if Bit9 was installed\
                        if (lFidoReturnValues.Bit9 == null)
                        {
                            lFidoReturnValues.Bit9 = new Bit9ReturnValues();
                        }
                        lFidoReturnValues.Bit9.IsBit9 = IsBit9Installed();
                        lFidoReturnValues             = SysmgmtLandesk.GetBit9Status(lFidoReturnValues, lQuery[0]);
                        if (lFidoReturnValues.Landesk.Bit9Running == null)
                        {
                            lFidoReturnValues.Landesk.Bit9Running = String.Empty;
                        }
                        if (lFidoReturnValues.Landesk.Bit9Version == null)
                        {
                            lFidoReturnValues.Landesk.Bit9Version = String.Empty;
                        }
                    }

                    continue;

                case "jamf":

                    //if nmap or ssh is null use IP
                    if (String.IsNullOrEmpty(sHostname))
                    {
                        lQuery = SQL_Queries.GetSqlConfigs(source);
                        lHostInfo.AddRange(SQL_Queries.RunMysqlQuery(lQuery, sSrcIP, null));
                    }
                    //if hostname is not null use IP instead
                    else
                    {
                        lQuery = SQL_Queries.GetSqlConfigs(source);
                        lHostInfo.AddRange(SQL_Queries.RunMysqlQuery(lQuery, null, sHostname));
                    }

                    //if return has values assign to lFidoReturnValues
                    if (lHostInfo[0] != "unknown")
                    {
                        if ((lFidoReturnValues.Landesk != null) && !String.IsNullOrEmpty(lFidoReturnValues.Landesk.Hostname))
                        {
                            var LandeskDateTime = Convert.ToDateTime(lFidoReturnValues.Landesk.LastUpdate);
                            var JamfDateTime    = FromEpochTime(lHostInfo[3]);

                            if (LandeskDateTime.ToUniversalTime() > JamfDateTime)
                            {
                                continue;
                            }
                        }
                        lFidoReturnValues.Hostname = lHostInfo[1];
                        lFidoReturnValues.Username = lHostInfo[11];
                        if (lFidoReturnValues.Jamf == null)
                        {
                            lFidoReturnValues.Jamf = new JamfReturnValues();
                        }

                        lFidoReturnValues.Jamf = Jamf2FidoValues.Convert(lFidoReturnValues, lHostInfo);
                    }

                    continue;

                default:
                    continue;
                }
            }
            return(lFidoReturnValues);
        }
示例#28
0
 public static bool RemoveUser(int id)
 {
     return Access.Execute(SQL_Queries.Delete("people", new Condition("id",id)));
 }
示例#29
0
 public static bool InsertPerson(List<object> values)
 {
     return Access.Execute(SQL_Queries.Insert("people", values));
 }
示例#30
0
 public static bool DeleteUser()
 {
     return(Access.Execute(SQL_Queries.Delete("people", new Condition("id", user_id))));
 }