Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
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);
        }