Пример #1
0
        /// <summary>
        /// save the inventory item
        /// </summary>
        /// <returns></returns>
        private bool SaveInventoryItem()
        {
            InventoryClasses.InventoryObject io = new InventoryClasses.InventoryObject();
            InventoryClasses.InventoryUtilities iu = new InventoryClasses.InventoryUtilities();

            io.ItemID = txtItemID.Text;
            io.Description = txtDescription.Text;
            decimal dpResult = 0;
            if (decimal.TryParse(txtAskPrice.Text, out dpResult))
            {
                io.Price = dpResult;
            }
            else
            {
                io.Price = dpResult;
            }

            decimal dsResult = 0;
            if (decimal.TryParse(txtSellPrice.Text, out dsResult))
            {
                io.SellPrice = dsResult;
            }
            else
            {
                io.SellPrice = dsResult;
            }

            io.Comment = txtComment.Text;
            io.SoldStatus = cboSoldStatus.SelectedIndex;
            io.Returnable = ckReturn.Checked;

            //CHECK FOR NULL DATES

            DateTime dtResult = DateTime.MinValue;
            if (DateTime.TryParse(txtDateIn.Text, out dtResult))
            {
                io.DateIn = dtResult;
            }
            else
            {
                io.DateIn = DateTime.MinValue;
            }

            if (DateTime.TryParse(txtDateSold.Text, out dtResult))
            {
                io.DateSold = dtResult;
            }
            else
            {
                io.DateSold = DateTime.MinValue;
            }

            if (DateTime.TryParse(txtDatePaid.Text, out dtResult))
            {
                io.DatePaid = dtResult;
            }
            else
            {
                io.DatePaid = DateTime.MinValue;
            }
            decimal pResult = 0;
            if (decimal.TryParse(txtPaidAmount.Text, out pResult))
            {
                io.PaidAmount = pResult;
            }
            else
            {
                io.PaidAmount = pResult;
            }

            bool returnValue = iu.UpdateInventory(io);
            return returnValue;
        }
Пример #2
0
 /// <summary>
 /// Save inventory to the database
 /// </summary>
 /// <returns></returns>
 private bool SaveInventory()
 {
     for (int iRowCount = 0; iRowCount < dgInventory.Rows.Count-1; iRowCount++)
     {
         InventoryClasses.InventoryObject newInventory = new InventoryClasses.InventoryObject();
         newInventory.Consignor = int.Parse(txtConsignerID.Text.ToString());
         newInventory.Description = dgInventory[0, iRowCount].Value.ToString();
         newInventory.Price = decimal.Parse(dgInventory[1, iRowCount].Value.ToString());
         string comment = string.Empty;
         if (dgInventory[2, iRowCount].Value != null)
         {
             comment = dgInventory[2, iRowCount].Value.ToString();
         }
         newInventory.Comment = comment;
         InventoryClasses.InventoryUtilities iu = new InventoryClasses.InventoryUtilities();
         int returnValue = iu.SaveInventory(newInventory);
         if (returnValue == -1)
         {
             return false;
         }
     }
     return true;
 }
Пример #3
0
        /// <summary>
        /// load up the found details for an inventory item
        /// </summary>
        /// <param name="ItemID"></param>
        private void LoadDetails(int ItemID)
        {
            try
            {
                InventoryClasses.InventoryUtilities iu = new InventoryClasses.InventoryUtilities();
                InventoryClasses.InventoryObject io = new InventoryClasses.InventoryObject();
                io = iu.GetInventoryDetails(ItemID.ToString());

                if (io == null)
                {
                    MessageBox.Show("There was a problem retrieving that inventory item", Properties.Settings.Default.MessageBoxTitle, MessageBoxButtons.OK);
                }
                else
                {
                    txtItemID.Text = io.ItemID;
                    txtDescription.Text = io.Description;
                    txtAskPrice.Text = decimal.Round(io.Price, 2).ToString();
                    txtDateIn.Text = io.DateIn.ToString();
                    txtSellPrice.Text = decimal.Round(io.SellPrice, 2).ToString();
                    if (DateTime.Compare(io.DateSold, DateTime.MinValue) == 0)
                    {
                        txtDateSold.Text = string.Empty;
                    }
                    else
                    {
                        txtDateSold.Text = io.DateSold.ToString();
                    }
                    if (DateTime.Compare(io.DatePaid, DateTime.MinValue) == 0)
                    {
                        txtDatePaid.Text = string.Empty;
                    }
                    else
                    {
                        txtDatePaid.Text = io.DatePaid.ToString();
                    }

                    txtPaidAmount.Text = decimal.Round(io.PaidAmount, 2).ToString();
                    txtComment.Text = io.Comment;
                    cboSoldStatus.SelectedIndex = io.SoldStatus;
                    this.ckReturn.Checked = io.Returnable;
                    txtConsignID.Text = io.Consignor.ToString();
                    txtConsignor.Text = io.ConsignorName;

                    if (io.Donate)
                    {
                        lblDonateCheck.Text = "x";
                    }
                    else
                    {
                        lblDonateCheck.Text = "o";
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format("There was an error: {0}", e.Message), Properties.Settings.Default.MessageBoxTitle, MessageBoxButtons.OK);
            }
        }