示例#1
0
        public async void LoadSuppliersAsync()
        {
            List <Supplier> suppliers = null;

            try
            {
                suppliers = await PersistencyService.LoadSuppliersAsync();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                throw;
            }

            if (suppliers != null)
            {
                foreach (Supplier supplier in suppliers)
                {
                    SupplierList.Add(supplier);
                }
            }
            else
            {
                throw new ArgumentNullException("Suppliers list null");
            }
        }
        private void AddSupplierExecuted(object obj)
        {
            SupplierData data = new SupplierData(null, obj as string, null, null, null, null, null);

            SupplierList.Add(data);
            _database.InsertSupplier(data);
        }
示例#3
0
 /// <summary>
 /// 显示列表
 /// </summary>
 public void ShowSupplierTable()
 {
     foreach (var model in GetSupplierList())
     {
         SupplierList.Add(model);
     }
     ShowSupplierList();
 }
        //Adds a new supplier to the DB-Grace
        public bool AddNewSupplier(int supplierID, string name, string phoneNum, string email, string street, string city, string county, string additionalInfo)
        {
            SupplierList = DataLayer.getAllSuppliers();
            ISupplier supplier;

            DataLayer.AddNewSupplierToDB(supplierID, name, phoneNum, email, street, city, county, additionalInfo);
            supplier = SupplierFactory.GetSupplier(supplierID, name, phoneNum, email, street, city, county, additionalInfo);   // Using a Factory to create the user entity object. ie seperating object creation from business logic
            SupplierList.Add(supplier);
            // Add a reference to the newly created object to the Models UserList
            //Gets the DataLayer to add the new user to the DB.
            return(true);
        }
示例#5
0
 public Boolean addnewSupplier(string SupplierID, string CompanyName, string Email, string Phone, string Street, string City, string County, string Country)
 {
     try
     {
         ISupplier theSupplier = SupplierFactory.GetSupplier(SupplierID, CompanyName, Email, Phone, Street, City, County, Country); // Using a Factory to create the user entity object. ie seperating object creation from business logic
         SupplierList.Add(theSupplier);                                                                                             // Add a reference to the newly created object to the Models UserList
         DataLayer.addNewSupplierToDB(theSupplier);                                                                                 //Gets the DataLayer to add the new user to the DB.
         return(true);
     }
     catch (System.Exception excep)
     {
         return(false);
     }
 }
        /// <summary>
        /// Fetch SupplierList.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public SupplierList Fetch(SupplierCriteria criteria)
        {
            SupplierList item = (SupplierList)Activator.CreateInstance(typeof(SupplierList), true);

            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return(item);
            }

            // Fetch Child objects.
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Supplier_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_NameHasValue", criteria.NameHasValue);
                    command.Parameters.AddWithValue("@p_Addr1HasValue", criteria.Addr1HasValue);
                    command.Parameters.AddWithValue("@p_Addr2HasValue", criteria.Addr2HasValue);
                    command.Parameters.AddWithValue("@p_CityHasValue", criteria.CityHasValue);
                    command.Parameters.AddWithValue("@p_StateHasValue", criteria.StateHasValue);
                    command.Parameters.AddWithValue("@p_ZipHasValue", criteria.ZipHasValue);
                    command.Parameters.AddWithValue("@p_PhoneHasValue", criteria.PhoneHasValue);
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            do
                            {
                                item.Add(new SupplierFactory().Map(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            MarkOld(item);
            MarkAsChild(item);
            OnFetched();
            return(item);
        }
示例#7
0
        //constructor
        public ManageSupplierList()
        {
            //loading supplier list
            SupplierManager supplierManager = new SupplierManager();

            for (Iterator i = supplierManager.getAllSuppliers().iterator(); i.hasNext();)
            {
                SupplierInfo   supplierInfo   = (SupplierInfo)i.next();
                SupplierInfoNJ supplierInfoNJ = new SupplierInfoNJ();
                supplierInfoNJ.ProfileInfoNJ.Id        = supplierInfo.getProfileInfo().getId();
                supplierInfoNJ.ProfileInfoNJ.FirstName = supplierInfo.getProfileInfo().getFirstName();
                supplierInfoNJ.ProfileInfoNJ.LastName  = supplierInfo.getProfileInfo().getLastName();
                supplierInfoNJ.ProfileInfoNJ.Phone     = supplierInfo.getProfileInfo().getPhone();
                supplierInfoNJ.ProfileInfoNJ.Fax       = supplierInfo.getProfileInfo().getFax();
                supplierInfoNJ.ProfileInfoNJ.Email     = supplierInfo.getProfileInfo().getEmail();
                supplierInfoNJ.ProfileInfoNJ.Website   = supplierInfo.getProfileInfo().getWebsite();
                supplierInfoNJ.Remarks = supplierInfo.getRemarks();
                SupplierList.Add(supplierInfoNJ);
            }
        }
示例#8
0
        /*
         * This method will search supplier info
         * @author A.K.M. Nazmul Islam on 30th january 2016
         */
        private void OnSearch()
        {
            SupplierManager supplierManager = new SupplierManager();

            SupplierList.Clear();
            for (Iterator i = supplierManager.searchSuppliers(SearchSupplierByPhone).iterator(); i.hasNext();)
            {
                SupplierInfo   supplierInfo   = (SupplierInfo)i.next();
                SupplierInfoNJ supplierInfoNJ = new SupplierInfoNJ();
                supplierInfoNJ.ProfileInfoNJ.Id        = supplierInfo.getProfileInfo().getId();
                supplierInfoNJ.ProfileInfoNJ.FirstName = supplierInfo.getProfileInfo().getFirstName();
                supplierInfoNJ.ProfileInfoNJ.LastName  = supplierInfo.getProfileInfo().getLastName();
                supplierInfoNJ.ProfileInfoNJ.Phone     = supplierInfo.getProfileInfo().getPhone();
                supplierInfoNJ.ProfileInfoNJ.Fax       = supplierInfo.getProfileInfo().getFax();
                supplierInfoNJ.ProfileInfoNJ.Email     = supplierInfo.getProfileInfo().getEmail();
                supplierInfoNJ.ProfileInfoNJ.Website   = supplierInfo.getProfileInfo().getWebsite();
                supplierInfoNJ.Remarks = supplierInfo.getRemarks();
                SupplierList.Add(supplierInfoNJ);
            }
        }
示例#9
0
        public void CreateSupplierList()
        {
            SupplierList.Clear();

            SqlConnection  con      = Methods.AccessDatabase();
            SqlDataAdapter autoNode = new SqlDataAdapter("SELECT * From [SUPPLIER]", con);
            DataTable      dt       = new DataTable();

            autoNode.Fill(dt);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                SUPPLIER newSupplier = new SUPPLIER();

                newSupplier.SupplierID      = Convert.ToInt16(dt.Rows[i]["Supplier_ID"]);
                newSupplier.SupplierName    = dt.Rows[i]["Supplier_Name"].ToString();
                newSupplier.SupplierDetails = dt.Rows[i]["Supplier_Details"].ToString();

                SupplierList.Add(newSupplier);
            }
        }
示例#10
0
        /// <summary>
        /// Fetch SupplierList.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public SupplierList Fetch(SupplierCriteria criteria)
        {
            SupplierList item = (SupplierList)Activator.CreateInstance(typeof(SupplierList), true);

            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return(item);
            }

            // Fetch Child objects.
            string commandText = String.Format("SELECT [SuppId], [Name], [Status], [Addr1], [Addr2], [City], [State], [Zip], [Phone] FROM [dbo].[Supplier] {0}", ADOHelper.BuildWhereStatement(criteria.StateBag));

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            do
                            {
                                item.Add(new SupplierFactory().Map(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            MarkOld(item);
            MarkAsChild(item);
            OnFetched();
            return(item);
        }
示例#11
0
        /*
         * This method will add/update a supplier
         * @author nazmul hasan on 5th january 2016
         */
        private void OnAdd()
        {
            if (!ValidateSupplier())
            {
                MessageBox.Show(ErrorMessage);
                return;
            }
            ProfileInfo profileInfo = new ProfileInfo();

            profileInfo.setId(SupplierInfoNJ.ProfileInfoNJ.Id);
            profileInfo.setFirstName(SupplierInfoNJ.ProfileInfoNJ.FirstName);
            profileInfo.setLastName(SupplierInfoNJ.ProfileInfoNJ.LastName);
            profileInfo.setEmail(SupplierInfoNJ.ProfileInfoNJ.Email);
            profileInfo.setPhone(SupplierInfoNJ.ProfileInfoNJ.Phone);
            profileInfo.setFax(SupplierInfoNJ.ProfileInfoNJ.Fax);
            profileInfo.setWebsite(SupplierInfoNJ.ProfileInfoNJ.Website);

            SupplierInfo supplierInfo = new SupplierInfo();

            supplierInfo.setProfileInfo(profileInfo);
            SupplierManager supplierManager = new SupplierManager();

            SupplierInfoNJ supplierInfoNJ = new SupplierInfoNJ();

            supplierInfoNJ.ProfileInfoNJ.Id        = SupplierInfoNJ.ProfileInfoNJ.Id;
            supplierInfoNJ.ProfileInfoNJ.FirstName = SupplierInfoNJ.ProfileInfoNJ.FirstName;
            supplierInfoNJ.ProfileInfoNJ.LastName  = SupplierInfoNJ.ProfileInfoNJ.LastName;
            supplierInfoNJ.ProfileInfoNJ.Email     = SupplierInfoNJ.ProfileInfoNJ.Email;
            supplierInfoNJ.ProfileInfoNJ.Phone     = SupplierInfoNJ.ProfileInfoNJ.Phone;
            supplierInfoNJ.ProfileInfoNJ.Fax       = SupplierInfoNJ.ProfileInfoNJ.Fax;
            supplierInfoNJ.ProfileInfoNJ.Website   = SupplierInfoNJ.ProfileInfoNJ.Website;
            supplierInfoNJ.Remarks = supplierInfo.getRemarks();

            ResultEvent resultEvent = new ResultEvent();

            if (SupplierInfoNJ.ProfileInfoNJ.Id > 0)
            {
                resultEvent = supplierManager.updateSupplier(supplierInfo);
            }
            else
            {
                resultEvent = supplierManager.createSupplier(supplierInfo);
            }
            if (resultEvent.getResponseCode() == Responses.RESPONSE_CODE_SUCCESS)
            {
                if (SupplierInfoNJ.ProfileInfoNJ.Id > 0)
                {
                    for (int counter = 0; counter < SupplierList.Count; counter++)
                    {
                        SupplierInfoNJ tempSupplierInfoNJ = SupplierList.ElementAt(counter);

                        if (tempSupplierInfoNJ.ProfileInfoNJ.Id == SupplierInfoNJ.ProfileInfoNJ.Id)
                        {
                            SupplierList.RemoveAt(counter);
                            SupplierList.Insert(counter, supplierInfoNJ);
                        }
                    }
                }
                else
                {
                    SupplierInfo responseSupplierInfo = (SupplierInfo)resultEvent.getResult();
                    SupplierInfoNJ.ProfileInfoNJ.Id = responseSupplierInfo.getProfileInfo().getId();
                    supplierInfoNJ.ProfileInfoNJ.Id = SupplierInfoNJ.ProfileInfoNJ.Id;
                    if (SupplierList.Count == 0)
                    {
                        SupplierList.Add(supplierInfoNJ);
                    }
                    else
                    {
                        SupplierList.Insert(0, supplierInfoNJ);
                    }
                }
            }
            MessageBox.Show(resultEvent.getMessage());
            //resetting supplier info fields
            OnReset();
        }