示例#1
0
        private static void addingCustomerFeature()
        {
            Cust ck = new Cust();

            Console.WriteLine("enter cust id:");
            ck.CustID = int.Parse(Console.ReadLine());

            Console.WriteLine("enter cust name:");

            ck.CustName = Console.ReadLine();
            Console.WriteLine("enter cust address:");

            ck.CustAddress = Console.ReadLine();
            Console.WriteLine("enter cust salary:");

            ck.CustSalary = int.Parse(Console.ReadLine());
            try
            {
                bool result = mgr.AddNewCustomer(ck);
                if (!result)
                {
                    Console.WriteLine("No more customers could be added");
                }
                else
                {
                    Console.WriteLine($"Customer by Name {ck.CustName} is added successfully to the database");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#2
0
        private static void updatingCustomerFeature()
        {
            Cust ck = new Cust();

            Console.WriteLine("enter Book id:");
            ck.CustID = int.Parse(Console.ReadLine());

            Console.WriteLine("enter Book name:");

            ck.CustName = Console.ReadLine();
            Console.WriteLine("enter cust address:");

            ck.CustAddress = Console.ReadLine();
            Console.WriteLine("enter cust salary:");

            ck.CustSalary = int.Parse(Console.ReadLine());
            bool result = mgr.UpdateCustomer(ck);

            if (!result)
            {
                Console.WriteLine($"No Customer by this id {ck.CustID} found to update");
            }
            else
            {
                Console.WriteLine($"Customer by ID {ck.CustID} is updated successfully to the database");
            }
        }
示例#3
0
 public override bool Equals(object obj)
 {
     if (obj is Cust)
     {
         Cust temp = obj as Cust;
         if ((this.CustID == temp.CustID) && (this.CustName == temp.CustName) && (this.CustSalary == temp.CustSalary))
         {
             return(true);
         }
     }
     return(false);
 }
示例#4
0
 public bool UpdateCustomer(Cust ck)
 {
     for (int i = 0; i < allcust.Length; i++)
     {
         if ((allcust[i] != null) && (allcust[i].CustID == ck.CustID))
         {
             allcust[i].CustName    = ck.CustName;
             allcust[i].CustAddress = ck.CustAddress;
             allcust[i].CustSalary  = ck.CustSalary;
             return(true);
         }
     }
     return(false);
 }
示例#5
0
 public bool UpdateCustomer(Cust ck)
 {
     for (int i = 0; i < allcust.Length; i++)
     {
         //find the first occurance of null in the array...
         if ((allBooks[i] != null) && (allBooks[i].BookID == bk.BookID))
         {
             allBooks[i].Title  = bk.Title;
             allBooks[i].Author = bk.Author;
             allBooks[i].Price  = bk.Price;
             return(true);
         }
     }
     return(false);
 }
示例#6
0
        public Cust[] GetAllCustomers(string name)
        {
            Cust[] copy = new Cust[allcust.Length];

            int index = 0;

            foreach (Cust ck in allcust)
            {
                if ((ck != null) && (ck.CustName.Contains(name)))
                {
                    copy[index] = ck;
                    index++;
                }
            }


            return(copy);
        }
示例#7
0
        public bool AddNewCustomer(Cust ck)
        {
            bool available = hasCust(ck.CustID);

            if (available)
            {
                throw new Exception("Customer by this ID already exists");
            }
            for (int i = 0; i < allcust.Length; i++)
            {
                if (allcust[i] == null)
                {
                    allcust[i]             = new Cust();
                    allcust[i].CustID      = ck.CustID;
                    allcust[i].CustName    = ck.CustName;
                    allcust[i].CustAddress = ck.CustAddress;
                    allcust[i].CustSalary  = ck.CustSalary;
                    return(true);
                }
            }
            return(false);
        }
示例#8
0
        public bool AddNewCustomer(Cust ck)
        {
            bool available = hasCustomer(ck.CustId);

            if (available)
            {
                throw new Exception("Customer by this ID already exists");
            }
            for (int i = 0; i < allcust.Length; i++)
            {
                //find the first occurance of null in the array...
                if (allcust[i] == null)
                {
                    allcust[i]             = new Book();
                    allcust[i].CustId      = ck.CustId;
                    allcust[i].CustName    = ck.CustName;
                    allcust[i].CustAddress = ck.Address;
                    allcust[i].CustSalryt  = ck.CustSalary;
                    return(true);
                }
            }
            return(false);
        }