Example #1
0
        public async void PickupLinesFromFile(List <string> pickupLines)
        {
            foreach (var line in pickupLines)
            {
                string[] splittedLine = line.Split('*');
                string   text         = splittedLine[0];
                string   type         = splittedLine[1];
                string   gender       = splittedLine[2];

                PickupLine newPickupLine = new PickupLine();
                newPickupLine.Text = text;

                PickupLineType pickupLineType;
                if (Enum.TryParse(type, out pickupLineType))
                {
                    newPickupLine.PickupLineType = pickupLineType;
                }
                else
                {
                    throw new Exception("A pickupLineType in the textfile is not correct. maybe somewhere its club instead of Club");
                }

                AttractedGender pickupLineGender;
                if (Enum.TryParse(gender, out pickupLineGender))
                {
                    newPickupLine.AttractedGender = pickupLineGender;
                }
                else
                {
                    throw new Exception("A pickupLineGender in the textfile is not correct. maybe somewhere its club instead of Club");
                }

                await Database.SavePickupLineAsync(newPickupLine);
            }
        }
Example #2
0
        /// <summary>
        /// Eric Walton
        /// 5/10/2017
        /// </summary>
        /// <param name="pickupLine"></param>
        /// <returns></returns>
        public static int CreatePickupLine(PickupLine pickupLine)
        {
            int pickupLineId = 0;

            var conn    = DBConnection.GetConnection();
            var cmdText = @"sp_create_pickup_line";
            var cmd     = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@PICKUP_ID", pickupLine.PickupId);
            cmd.Parameters.AddWithValue("@PRODUCT_ID", pickupLine.ProductId);
            cmd.Parameters.AddWithValue("@QUANTITY", pickupLine.Quantity);
            cmd.Parameters.AddWithValue("PICK_UP_STATUS", pickupLine.PickupStatus);

            try
            {
                conn.Open();
                //int.TryParse(cmd.ExecuteScalar().ToString(), out orderLineID);
                decimal id = (decimal)cmd.ExecuteScalar();
                pickupLineId = (int)id;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }

            return(pickupLineId);
        }
Example #3
0
        /// <summary>
        /// Ryan Spurgetis
        /// 4/29/2017
        ///
        /// Loads the form window based on values from pickup selected
        /// </summary>
        /// <param name="_pickupLine"></param>
        private void SetValuesFromPickupLine(PickupLine _pickupLine)
        {
            _supplierManager = new SupplierManager();
            ProductManager _productManager = new ProductManager();

            btnCreateFromPickup.Visibility = Visibility.Visible;

            try
            {
                Pickup _pickup      = _pickupManager.RetrievePickupById(_pickupLine.PickupId);
                var    supplierName = _supplierManager.RetrieveSupplierBySupplierID((int)_pickup.SupplierId);
                var    productName  = _productManager.RetrieveProductById((int)_pickupLine.ProductId).Name;
                lblSupplierVal.Content          = supplierName;
                cboSupplierIDVal.SelectedIndex  = (int)_pickup.SupplierId;
                cboSupplierIDVal.Visibility     = Visibility.Collapsed;
                lblWarehouseIDVal.Content       = (int)_pickup.WarehouseId;
                cboWarehouseIDVal.SelectedIndex = (int)_pickup.WarehouseId;
                cboWarehouseIDVal.Visibility    = Visibility.Collapsed;
                lblProductVal.Content           = productName;
                cboProductIDVal.SelectedItem    = (int)_pickupLine.ProductId;
                cboProductIDVal.Visibility      = Visibility.Collapsed;
                txtQuantity.Text                 = _pickupLine.Quantity.ToString();
                _locationList                    = (new LocationManager()).ListLocations();
                cboLocationIDVal.ItemsSource     = _locationList;
                cboLocationIDVal.Visibility      = Visibility.Visible;
                lblSupplyManagerID.Visibility    = Visibility.Hidden;
                cboSupplyManagerIDVal.Visibility = Visibility.Hidden;
                dpDateReceived.SelectedDate      = DateTime.Now;
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured" + ex.Message + ex.StackTrace);
            }
        }
Example #4
0
 /// <summary>
 /// Ryan Spurgetis
 /// 4/28/2017
 ///
 /// Initialize product lot window based on pickup selected
 /// </summary>
 /// <param name="pickupManager"></param>
 /// <param name="pickupLine"></param>
 public frmAddProductLot(IPickupManager pickupManager, PickupLine pickupLine, Employee employee)
 {
     InitializeComponent();
     _productLotManager = new ProductLotManager();
     _pickupManager     = pickupManager;
     _pickupLine        = pickupLine;
     _employee          = employee;
     SetValuesFromPickupLine(_pickupLine);
 }
Example #5
0
        private async void Save_Clicked(object sender, EventArgs e)
        {
            PickupLine pickupLineItem = (PickupLine)BindingContext;

            pickupLineItem.PickupLineType = (PickupLineType)Enum.Parse(typeof(PickupLineType), (string)PickUpLineTypePicker.SelectedItem);

            await App.Database.SavePickupLineAsync(pickupLineItem);

            await Navigation.PopAsync();
        }
Example #6
0
        private async void RemoveButton_Clicked(object sender, EventArgs e)
        {
            if (currentPickupLine == null)
            {
                return;
            }

            LblCurrentPickupLine.Text = "Druk op het hartje!";

            await App.Database.DeletePickupLineAsync(currentPickupLine);

            currentPickupLine = null;
        }
        /// <summary>
        /// Eric Walton
        /// 5/10/2017
        /// </summary>
        /// <param name="pickupLine"></param>
        /// <returns></returns>
        public int CreatePickupLine(PickupLine pickupLine)
        {
            int pickupLineId = 0;

            try
            {
                pickupLineId = PickupLineAccessor.CreatePickupLine(pickupLine);
            }
            catch (Exception)
            {
                throw;
            }
            return(pickupLineId);
        }
        /// <summary>
        /// Robert Forbes
        /// Created: 2017/04/19
        /// </summary>
        /// <param name="pickupLineId"></param>
        /// <returns></returns>
        public PickupLine RetrievePickupLineById(int?pickupLineId)
        {
            PickupLine result = null;

            try
            {
                result = PickupLineAccessor.RetrievePickupLine(pickupLineId);
            }
            catch
            {
                throw;
            }
            return(result);
        }
Example #9
0
        private async void EditButton_Clicked(object sender, EventArgs e)
        {
            if (currentPickupLine == null)
            {
                return;
            }

            await Navigation.PushAsync(new PickupLineCreatorPage()
            {
                BindingContext = currentPickupLine
            });

            LblCurrentPickupLine.Text = "Druk op het hartje!";
            currentPickupLine         = null;
        }
        public bool DeletePickupLine(PickupLine pickupLine)
        {
            bool result = false;

            try
            {
                result = (PickupLineAccessor.DeletePickupLine(pickupLine) >= 1);
            }
            catch
            {
                throw;
            }

            return(result);
        }
        /// <summary>
        /// Robert Forbes
        /// Created: 2017/04/19
        /// </summary>
        /// <param name="oldLine"></param>
        /// <param name="newLine"></param>
        /// <returns></returns>
        public bool UpdatePickupLine(PickupLine oldLine, PickupLine newLine)
        {
            bool result = false;

            try
            {
                result = (PickupLineAccessor.UpdatePickupLine(oldLine, newLine) >= 1);
            }
            catch
            {
                throw;
            }

            return(result);
        }
Example #12
0
        private async Task TappedImage()
        {
            Picker picker         = this.FindByName <Picker>("PickUpLineTypePicker");
            string pickupLineType = "";

            if (picker != null && picker.SelectedItem != null)
            {
                pickupLineType = (string)picker.SelectedItem;
            }

            PickupLine filteredPickupLine = await App.Database.GetPickupLineByFilter(pickupLineType);

            if (currentPickupLine != null && filteredPickupLine != null)
            {
                if (filteredPickupLine.Text.ToLower() == currentPickupLine.Text.ToLower())
                {
                    var allPickupLines = await App.Database.GetPickupLinesAsync();

                    var otherPickupLines = allPickupLines.Where(p => p.Text.ToLower() != filteredPickupLine.Text.ToLower()).ToList();

                    if (otherPickupLines != null && otherPickupLines.Count > 0)
                    {
                        if (otherPickupLines.Count() == 1)
                        {
                            filteredPickupLine = otherPickupLines[0];
                        }
                        else
                        {
                            filteredPickupLine = otherPickupLines[random.Next(0, otherPickupLines.Count)];
                        }
                    }
                }
            }

            if (filteredPickupLine != null)
            {
                LblCurrentPickupLine.Text = filteredPickupLine.Text;
                currentPickupLine         = filteredPickupLine;
            }
            else
            {
                LblCurrentPickupLine.Text = "Geen openingszinnen gevonden!";
            }
        }
Example #13
0
        /// <summary>
        /// Robert Forbes
        /// Created:
        /// 2017/04/19
        /// </summary>
        ///
        /// <remarks>
        /// Aaron Usher
        /// Updated:
        /// 2017/04/21
        ///
        /// Standardized method.
        /// </remarks>
        ///
        /// <param name="pickupLineId">The id of the pickup line to retrieve.</param>
        /// <returns>The pickup line.</returns>
        public static PickupLine RetrievePickupLine(int?pickupLineId)
        {
            PickupLine line = null;

            var conn    = DBConnection.GetConnection();
            var cmdText = @"sp_retrieve_pickup_line";
            var cmd     = new SqlCommand(cmdText, conn);

            cmd.Parameters.AddWithValue("@PICKUP_LINE_ID", pickupLineId);

            cmd.CommandType = CommandType.StoredProcedure;

            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();
                    line = new PickupLine()
                    {
                        PickupLineId = reader.GetInt32(0),
                        PickupId     = reader.GetInt32(1),
                        ProductId    = reader.GetInt32(2),
                        Quantity     = reader.GetInt32(3),
                        PickupStatus = reader.GetBoolean(4)
                    };
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }

            return(line);
        }
Example #14
0
        /// <summary>
        /// Ryan Spurgetis
        /// 4/29/2017
        ///
        /// Removes PickupLine from database
        /// </summary>
        /// <param name="pickupLine"></param>
        /// <returns></returns>
        public static int DeletePickupLine(PickupLine pickupLine)
        {
            int result = 0;

            var conn    = DBConnection.GetConnection();
            var cmdText = @"sp_delete_pickup_line";
            var cmd     = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@PICKUP_LINE_ID", pickupLine.PickupLineId);

            try
            {
                conn.Open();
                result = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
Example #15
0
        /// <summary>
        /// Robert Forbes
        /// Created:
        /// 2017/04/19
        ///
        /// Updates a pickup line in the database.
        /// </summary>
        ///
        /// <remarks>
        /// Aaron Usher
        /// Updated:
        /// 2017/04/21
        ///
        /// Standardized method.
        /// </remarks>
        ///
        /// <param name="oldPickupLine">The pickup line as it was in the database.</param>
        /// <param name="newPickupLine">The pickup line as it should be.</param>
        /// <returns>Rows affected.</returns>
        public static int UpdatePickupLine(PickupLine oldPickupLine, PickupLine newPickupLine)
        {
            int rows = 0;

            var cmdText = @"sp_update_pickup_line";
            var conn    = DBConnection.GetConnection();
            var cmd     = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@old_PICKUP_LINE_ID", oldPickupLine.PickupLineId);
            cmd.Parameters.AddWithValue("@old_PICKUP_ID", oldPickupLine.PickupId);
            cmd.Parameters.AddWithValue("@old_PRODUCT_ID", oldPickupLine.ProductId);
            cmd.Parameters.AddWithValue("@old_QUANTITY", oldPickupLine.Quantity);
            cmd.Parameters.AddWithValue("@old_PICK_UP_STATUS", oldPickupLine.PickupStatus);
            cmd.Parameters.AddWithValue("@new_PICKUP_ID", newPickupLine.PickupId);
            cmd.Parameters.AddWithValue("@new_PRODUCT_ID", newPickupLine.ProductId);
            cmd.Parameters.AddWithValue("@new_QUANTITY", newPickupLine.Quantity);
            cmd.Parameters.AddWithValue("@new_PICK_UP_STATUS", newPickupLine.PickupStatus);

            try
            {
                conn.Open();
                rows = cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }

            return(rows);
        }