Ejemplo n.º 1
0
        public void update_client(BE.Client cli, BE.update t, object obj)
        {
            switch (t)
            {
            case update.vatek:
                if (obj is int)
                {
                    del_client(cli);
                    cli.Vatk = (int)obj;
                }
                else
                {
                    throw new Exception("לא נשלח מספר של וטק");
                }
                break;

            case update.vip:
                if (obj is bool)
                {
                    del_client(cli);
                    cli.isVip = (bool)obj;
                }
                else
                {
                    throw new Exception("האוביקט שנשלח אינו מסוג בוליאן");
                }
                break;

            case update.address:
            {
                if (obj is addres)
                {
                    del_client(cli);
                    cli.Address1 = (addres)obj;
                }
                else
                {
                    throw new Exception("this objet is not an addres");
                }
            }
            break;

            case update.cradit_card:
            {
                if (obj is CreditCard)
                {
                    del_client(cli);
                    cli.Card_dit = (CreditCard)obj;
                }
                else
                {
                    throw new Exception("this objet is not a credit card");
                }
            }
            break;

            case update.age:
            {
                if (obj is int)
                {
                    del_client(cli);
                    cli.Age = (int)obj;
                }
                else
                {
                    throw new Exception("this objet is not a age");
                }
            }
            break;

            case update.rishion_nahg:
                if (obj is rishion)
                {
                    del_client(cli);
                    cli.rishoi = (rishion)obj;
                }
                else
                {
                    throw new Exception("this objet is not a age");
                }
                break;

            default:
                throw new Exception(string.Format("this {0} is not an updat option", t.ToString()));
            }
            add_client(cli);
        }
Ejemplo n.º 2
0
        public void update_rent(BE.Renting rent, BE.update t, object obj)
        {
            switch (t)
            {
            case update.rishion_nahg:
                if (obj is long)
                {
                    del_rent(rent);
                    Drivers dra = new Drivers
                    {
                        first_id    = rent.driver.first_id,
                        first_name  = rent.driver.first_name,
                        second_id   = (long)obj,
                        second_name = ""
                    };
                    rent.driver = dra;
                }
                else
                {
                    throw new Exception("this objet is not a float");
                }
                break;

            case update.date_end:
                if (obj is DateTime)
                {
                    del_rent(rent);
                    rent.end_rent = (DateTime)obj;
                }
                else
                {
                    throw new Exception("this objet is not a float");
                }
                break;

            case update.destance:
                if (obj is float || obj is int)
                {
                    del_rent(rent);
                    rent.number_at_end = (int)obj;
                    rent.number_drove  = rent.number_at_end - rent.number_at_start;
                }
                else
                {
                    throw new Exception("this objet is not a float");
                }
                break;

            case update.defect:
                if (obj is bool)
                {
                    del_rent(rent);
                    rent.is_defcive = (bool)obj;
                }
                else
                {
                    throw new Exception("this objet is not a bool");
                }
                break;

            case update.ended:
                if (obj is bool)
                {
                    del_rent(rent);
                    rent.ended = (bool)obj;
                }
                else
                {
                    throw new Exception("this objet is not a bool");
                }
                break;

            case update.price:
                if (obj is float)
                {
                    del_rent(rent);
                    rent.price = (float)obj;
                }
                else
                {
                    throw new Exception("this objet is not an pepole number");
                }
                break;

            case update.mosif_n:
                if (obj is Drivers)
                {
                    del_rent(rent);
                    rent.number_of_pepole = 2;
                }
                else
                {
                    throw new Exception("this objet is not a \"driver object\"");
                }
                break;

            case update.morid_n:    //-
                if (obj is int)
                {
                    del_rent(rent);
                    rent.number_of_pepole = 1;
                }
                else
                {
                    throw new Exception("this objet is not a \"int object\"");
                }
                break;

            case update.mispar_yamim:
                if (obj is int)
                {
                    del_rent(rent);
                    rent.days = (int)obj;
                }
                else if (obj is DateTime)
                {
                    del_rent(rent);
                    rent.end_rent = (DateTime)obj;
                    rent.days     = (rent.end_rent - rent.start_rent).Days;
                }
                else
                {
                    throw new Exception("this objet is not a \"int object\"");
                }
                break;

            case update.price_horada_achuz:
                if (obj is int)
                {
                    if ((int)obj > 100 || (int)obj < 0)
                    {
                        throw new Exception("המספר שנשלח הוא לא אחוז נדרש מספר בין 0 ל100 ");
                    }

                    del_rent(rent);
                    rent.price = rent.price - (int)obj * rent.price;
                }
                else
                {
                    throw new Exception("צריך לשלוח משתנה מסוג אינטג'ר ");
                }
                break;

            case update.price_horada_shqulim:
                if (obj is int)
                {
                    if ((int)obj > rent.price || (int)obj < 0)
                    {
                        throw new Exception("המספר שנשלח צריך להיות גדול מ0 וקטן מהמחיר המקורי");
                    }

                    del_rent(rent);
                    rent.price = rent.price - (int)obj;
                }
                else
                {
                    throw new Exception("צריך לשלוח משתנה מסוג אינטג'ר ");
                }
                break;

            case update.panuy:
                if (obj is bool)
                {
                    del_rent(rent);
                    rent.panuy = (bool)obj;
                }
                else
                {
                    throw new Exception("this objet is not a \"int object\"");
                }
                break;

            default:
                throw new Exception(string.Format("לא ניתן לעדכן {0} בהשכרה", t.ToString()));
            }
            add_rent(rent);
        }
Ejemplo n.º 3
0
 public void update_Fault(BE.Fault Fault_number, BE.update t, object obj)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 4
0
        public void update_car(BE.car ca, BE.update t, object obj)
        {
            switch (t)
            {
            case update.date_test:
                if (obj is DateTime?)
                {
                    del_car(ca);
                    ca.date_of_fix = (DateTime)obj;
                }
                else
                {
                    throw new Exception("this objet is not a DateTime");
                }
                break;

            case update.destance:
                if (obj is int)
                {
                    del_car(ca);
                    ca.total_distance += float.Parse(obj.ToString());
                }
                else
                {
                    throw new Exception("this objet is not a bool");
                }
                break;

            case update.rishion_rachav:
                if (obj is rishion_rachav)
                {
                    del_car(ca);
                    ca.rishion = (rishion_rachav)obj;
                }
                else
                {
                    throw new Exception("this objet is not an rishion rachav");
                }
                break;

            case update.takin:
                if (obj is bool)
                {
                    del_car(ca);
                    ca.takin = (bool)obj;
                }
                else
                {
                    throw new Exception("this objet is not an boolean");
                }
                break;

            case update.panuy:
                if (obj is bool)
                {
                    del_car(ca);
                    ca.moosker = (bool)obj;
                }
                else
                {
                    throw new Exception("this objet is not an boolean");
                }
                break;

            case update.mirchk:
                if (obj is float)
                {
                    del_car(ca);
                    ca.total_distance += (float)obj;
                }
                else
                {
                    throw new Exception("this objet is not an mailage");
                }
                break;

            case update.address:
            {
                if (obj is addres)
                {
                    del_car(ca);
                    ca.snif_address = (addres)obj;
                }
                else
                {
                    throw new Exception("this objet is not an addres");
                }
            }
            break;

            case update.mosif_n:
                if (obj is int)
                {
                    del_car(ca);
                    ca.car_people_able += (int)obj;
                }
                else
                {
                    throw new Exception("this objet is not an pepole number");
                }
                break;

            case update.morid_n:
                if (obj is int)
                {
                    del_car(ca);
                    ca.car_people_able -= (int)obj;
                }
                else
                {
                    throw new Exception("this objet is not an pepole number");
                }
                break;

            case update.ids:
            {
                del_car(ca);
                if (obj is int || obj is long || obj is decimal)
                {
                    if (ca.car_number > 10m || ca.car_number < 1m)
                    {
                        ca.car_number = create_new_license_number();
                    }
                    else
                    {
                        ca.car_number = (int)obj;
                    }
                }
                else
                {
                    throw new Exception("this objet is not an id");
                }
            }
            break;

            default:
                throw new Exception(string.Format("this {0} is not an update option", t.ToString()));
            }
            add_car(ca);
        }