Beispiel #1
0
        public static bool DeleteSalesMan(int SalesManCode)
        {
            bool         SalesManDeleted     = true;
            JMS_Entities salesmanToBeDeleted = null;

            try
            {
                //Search customer in the records
                salesmanToBeDeleted = JMS_DAL.SearchSalesMan(SalesManCode);

                //If Guest is not null delete customer otherwise raise exception
                if (salesmanToBeDeleted != null)
                {
                    SalesManDeleted = JMS_DAL.DeleteSalesMan(salesmanToBeDeleted);
                }
                else
                {
                    SalesManDeleted = false;
                    throw new JMS_Exceptions("SalesMan Info does not exists to delete");
                }
            }
            catch (JMS_Exceptions p)
            {
                throw;
            }
            catch (SystemException e)
            {
                Console.WriteLine(e.Message);
            }

            return(SalesManDeleted);
        }
Beispiel #2
0
        public static JMS_Entities SearchSalesMan(int SalesManCode)
        {
            JMS_Entities SalesManSearched = null;

            try
            {
                //Searching Customer
                SalesManSearched = JMS_DAL.SearchSalesMan(SalesManCode);

                //If searched Customer is null raise exception
                if (SalesManSearched == null)
                {
                    throw new JMS_Exceptions("SalesMan Info does not exist!");
                }
            }
            catch (JMS_Exceptions p)
            {
                throw;
            }
            catch (SystemException e)
            {
                Console.WriteLine(e.Message);
            }

            return(SalesManSearched);
        }
Beispiel #3
0
 public static bool DeleteSalesMan(JMS_Entities salesmanToBeDeleted)
 {
     try
     {
         //Removing Customer from the list
         SMS.Remove(salesmanToBeDeleted);
         return(true);
     }
     catch (SystemException e)
     {
         throw;
     }
 }
Beispiel #4
0
        private static bool ValidateSalesMan(JMS_Entities SalesMan)
        {
            StringBuilder sb = new StringBuilder();

            bool ValidSalesMan = true;

            if (SalesMan.SalesManCode <= 0)
            {
                ValidSalesMan = false;
                sb.Append(Environment.NewLine + "Invalid Guest ID");
            }

            return(ValidSalesMan);
        }
Beispiel #5
0
        //public int CustomerID { get; set; }
        //public string CusotmerPhNo { get; set; }

        public static bool AddSalesMan(JMS_Entities SalesManName)
        {
            bool SalesManAdded = false;

            try
            {
                SMS.Add(SalesManName);
                SalesManAdded = true;
            }
            catch (JMS_Exceptions ex)
            {
                throw ex;
            }
            return(SalesManAdded);
        }
Beispiel #6
0
        public static bool UpdateSalesMan(JMS_Entities SalesManToBeUpdated)
        {
            bool SalesManUpdated = false;

            for (var i = 0; i < SMS.Count; i++)
            {
                //Find the Customer to be updated & update record
                if (SMS[i].SalesManCode == SalesManToBeUpdated.SalesManCode)
                {
                    SMS[i].SalesManName = SalesManToBeUpdated.SalesManName;
                    SMS[i].Region2      = SalesManToBeUpdated.Region2;
                    SalesManUpdated     = true;
                }
            }

            return(SalesManUpdated);
        }
Beispiel #7
0
            //Method to Add a Customer and calling the validation methods from the CustomerBal class
            public static void AddSalesMan()
            {
                try
                {
                    //Creating object of Customer class to access the values being stored through the properties
                    JMS_Entities newSalesMan = new JMS_Entities();

                    //User Inputs
                    //Console.Write("Enter SalesManCode ID : ");
                    //newSalesMan.SalesManCode = Convert.ToInt32(Console.ReadLine());
                    Console.Write("Enter SalesManName  : ");
                    newSalesMan.SalesManName = Console.ReadLine();
                    Console.Write(" Enter the Region: (1- East, 2- West, 3- North, 4-south) ");
                    newSalesMan.Region2 = (Region)Enum.Parse(typeof(Region), Console.ReadLine());
                    Console.Write("Enter TargetSet  (0% - 100%): ");
                    newSalesMan.TargetSet = float.Parse(Console.ReadLine());
                    Console.Write("Enter Actualtarget 0% - 100% : ");
                    newSalesMan.ActualSales = float.Parse(Console.ReadLine());

                    //Checking if all validations by calling the CustomerBL class to use it's function AND using are true AND using NAMED ARGUMENTS
                    bool SalesManAdded = JMS_BAL.AddSalesMan(newSalesMan);
                    if (SalesManAdded == true)
                    {
                        Console.WriteLine("SalesMan Added Successfully!");
                    }
                    else
                    {
                        throw new JMS_Exceptions("SalesMan not added! Please try again following the validations mentioned!");
                    }
                    JMS_BAL.SerializeData();
                }
                //Catching user defined exception
                catch (JMS_Exceptions p)
                {
                    Console.WriteLine(p.Message);
                }

                //Catching System exception
                catch (SystemException e)
                {
                    Console.WriteLine(e.Message);
                }
            }
Beispiel #8
0
        public static bool AddSalesMan(JMS_Entities newSalesMan)
        {
            bool SalesManAdded = false;

            try
            {
                if (ValidateSalesMan(newSalesMan))
                {
                    SalesManAdded = JMS_DAL.AddSalesMan(newSalesMan);
                }
            }
            catch (JMS_Exceptions)
            {
                throw;
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
            return(SalesManAdded);
        }
Beispiel #9
0
            //Method to Update a Customer and calling the validation methods from the CustomerBiz class
            public static void UpdateSalesMan()
            {
                JMS_Entities SalesManToBeUpdated = new JMS_Entities();
                bool         SalesManUpdated;

                try
                {
                    //User inputs
                    Console.Write("Enter SalesManCode for which you would like to update the record : ");
                    SalesManToBeUpdated.SalesManCode = Convert.ToInt32(Console.ReadLine());
                    Console.Write("Enter SalesManName to be updated : ");
                    SalesManToBeUpdated.SalesManName = Console.ReadLine();
                    Console.Write("Enter SalesMan Region to be updated : ");
                    SalesManToBeUpdated.Region2 = (Region)Enum.Parse(typeof(Region), Console.ReadLine());
                    //Checking if all validations by calling the customerBL class to use it's function AND using are true AND using NAMED ARGUMENTS
                    SalesManUpdated = JMS_BAL.UpdateSalesMan(SalesManToBeUpdated);

                    //Checking if validations are true or not
                    if (SalesManUpdated == true)
                    {
                        Console.WriteLine("SalesMan Updated Successfully!");
                    }
                    else
                    {
                        throw new JMS_Exceptions("SalesMan not updated!");
                    }
                }
                //Catching User defined exception
                catch (JMS_Exceptions p)
                {
                    Console.WriteLine(p.Message);
                }
                //Catching System exception
                catch (SystemException e)
                {
                    Console.WriteLine(e.Message);
                }
            }
Beispiel #10
0
        public static bool UpdateSalesMan(JMS_Entities SalesManToBeUpdated)
        {
            bool SalesManUpdated = true;

            try
            {
                //Searching customer, if found update or raise exception
                if (JMS_DAL.SearchSalesMan(SalesManToBeUpdated.SalesManCode) != null)
                {
                    //validating customer, if valid update o.w. raise exception
                    if (ValidateSalesMan(SalesManToBeUpdated))
                    {
                        SalesManUpdated = JMS_DAL.UpdateSalesMan(SalesManToBeUpdated);
                    }
                    else
                    {
                        SalesManUpdated = false;
                        throw new JMS_Exceptions("SalesMan Info is not updated because it is not valid!");
                    }
                }
                else
                {
                    SalesManUpdated = false;
                    throw new JMS_Exceptions("SalesMan id not exists for update!");
                }
            }
            catch (JMS_Exceptions e)
            {
                throw;
            }
            catch (SystemException e)
            {
                Console.WriteLine(e.Message);
            }

            return(SalesManUpdated);
        }
Beispiel #11
0
        //public static bool DeleteCustomer(JMS_Entities SalesManToBeDeleted)
        //{
        //    try
        //    {
        //        //Removing SalesMan from the list
        //        SMS.Remove(SalesManToBeDeleted);
        //        return true;
        //    }
        //    catch (SystemException e)
        //    {
        //        throw e;
        //    }
        //}
        public static JMS_Entities SearchSalesMan(int SalesManCode)
        {
            try
            {
                JMS_Entities searchedSalesMan = null;

                //foreach (var JMS_Entities in SMS)
                //{
                //   // Cheking the SalesManCode
                //      if (JMS_Entities.SalesManCode == SalesManCode)
                //    {
                //        //If guest found store the guest details to searchedguest
                //        searchedSalesMan = SalesMan;
                //    }
                //}
                searchedSalesMan = SMS.Find(p => p.SalesManCode == SalesManCode);//null;

                return(searchedSalesMan);
            }
            catch (JMS_Exceptions e)
            {
                throw e;
            }
        }