Пример #1
0
        /// <summary>
        /// Updates a record in the sol_OrdersDetail table.
        /// </summary>
        public virtual void Update(Sol_OrdersDetail sol_OrdersDetail)
        {
            ValidationUtility.ValidateArgument("sol_OrdersDetail", sol_OrdersDetail);

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@DetailID", sol_OrdersDetail.DetailID),
                new SqlParameter("@OrderID", sol_OrdersDetail.OrderID),
                new SqlParameter("@OrderType", sol_OrdersDetail.OrderType),
                new SqlParameter("@Date", sol_OrdersDetail.Date),
                new SqlParameter("@CategoryID", sol_OrdersDetail.CategoryID),
                new SqlParameter("@ProductID", sol_OrdersDetail.ProductID),
                new SqlParameter("@Description", sol_OrdersDetail.Description),
                new SqlParameter("@Quantity", sol_OrdersDetail.Quantity),
                new SqlParameter("@Price", sol_OrdersDetail.Price),
                new SqlParameter("@Amount", sol_OrdersDetail.Amount),
                new SqlParameter("@Status", sol_OrdersDetail.Status),
                new SqlParameter("@CategoryButtonID", sol_OrdersDetail.CategoryButtonID),
                new SqlParameter("@BagID", sol_OrdersDetail.BagID),
                //new SqlParameter("@IsNew", sol_OrdersDetail.IsNew),
                new SqlParameter("@ConveyorID", sol_OrdersDetail.ConveyorID),
                new SqlParameter("@StageID", sol_OrdersDetail.StageID)
            };

            SqlClientUtility.ExecuteNonQuery(connectionStringName, CommandType.StoredProcedure, "sol_OrdersDetail_Update", parameters);
        }
        private void buttonRemove_Click(object sender, EventArgs e)
        {
            if (currentOrderDetailID < 1)
            {
                MessageBox.Show("Please select an item from the list!");
                return;
            }

            if (MessageBox.Show("Are you sure want to remove this item from the bag?", "Modifying Bag Position Content", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            //update orderdetail
            if (sol_OrdersDetail_Sp == null)
            {
                sol_OrdersDetail_Sp = new Sol_OrdersDetail_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }

            Sol_OrdersDetail od = sol_OrdersDetail_Sp.Select(currentOrderDetailID);

            if (od == null
                //|| od.StageID > 0
                || od.Status != "A")
            {
                MessageBox.Show("Sorry, that item no longer exists.  Please select another item.");
                FillDataListView();
                return;
            }

            od.StageID = 0;
            sol_OrdersDetail_Sp.Update(od);

            //update bagposition
            if (vir_BagPosition_Sp == null)
            {
                vir_BagPosition_Sp = new Vir_BagPosition_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }

            vir_BagPosition.CurrentQuantity -= od.Quantity;
            vir_BagPosition_Sp.Update(vir_BagPosition);


            FillDataListView();

            //if (sol_Stage_Sp == null)
            //    sol_Stage_Sp = new Sol_Stage_Sp(Properties.Settings.Default.WsirDbConnectionString);

            FormatBagPositionText(buttonBagPosition, vir_BagPosition, tagNumber);

            currentOrderDetailID   = 0;
            currentMasterProductID = 0;

            cancelFlag = false;
        }
Пример #3
0
        /// <summary>
        /// Selects all records from the sol_OrdersDetail table.
        /// </summary>
        public virtual List <Sol_OrdersDetail> SelectAll()
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "sol_OrdersDetail_SelectAll"))
            {
                List <Sol_OrdersDetail> sol_OrdersDetailList = new List <Sol_OrdersDetail>();
                while (dataReader.Read())
                {
                    Sol_OrdersDetail sol_OrdersDetail = MakeSol_OrdersDetail(dataReader);
                    sol_OrdersDetailList.Add(sol_OrdersDetail);
                }

                return(sol_OrdersDetailList);
            }
        }
Пример #4
0
        /// <summary>
        /// Selects all records from the sol_OrdersDetail table by a foreign key.
        /// </summary>
        public virtual List <Sol_OrdersDetail> _SelectAllByCategoryID(int categoryID)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@CategoryID", categoryID)
            };

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "sol_OrdersDetail_SelectAllByCategoryID", parameters))
            {
                List <Sol_OrdersDetail> sol_OrdersDetailList = new List <Sol_OrdersDetail>();
                while (dataReader.Read())
                {
                    Sol_OrdersDetail sol_OrdersDetail = MakeSol_OrdersDetail(dataReader);
                    sol_OrdersDetailList.Add(sol_OrdersDetail);
                }

                return(sol_OrdersDetailList);
            }
        }
Пример #5
0
        /// <summary>
        /// Creates a new instance of the sol_OrdersDetail class and populates it with data from the specified SqlDataReader.
        /// </summary>
        protected virtual Sol_OrdersDetail MakeSol_OrdersDetail(SqlDataReader dataReader)
        {
            Sol_OrdersDetail sol_OrdersDetail = new Sol_OrdersDetail();

            sol_OrdersDetail.DetailID         = SqlClientUtility.GetInt32(dataReader, "DetailID", 0);
            sol_OrdersDetail.OrderID          = SqlClientUtility.GetInt32(dataReader, "OrderID", 0);
            sol_OrdersDetail.OrderType        = SqlClientUtility.GetString(dataReader, "OrderType", String.Empty);
            sol_OrdersDetail.Date             = SqlClientUtility.GetDateTime(dataReader, "Date", new DateTime(0));
            sol_OrdersDetail.CategoryID       = SqlClientUtility.GetInt32(dataReader, "CategoryID", 0);
            sol_OrdersDetail.ProductID        = SqlClientUtility.GetInt32(dataReader, "ProductID", 0);
            sol_OrdersDetail.Description      = SqlClientUtility.GetString(dataReader, "Description", String.Empty);
            sol_OrdersDetail.Quantity         = SqlClientUtility.GetInt32(dataReader, "Quantity", 0);
            sol_OrdersDetail.Price            = SqlClientUtility.GetDecimal(dataReader, "Price", Decimal.Zero);
            sol_OrdersDetail.Amount           = SqlClientUtility.GetDecimal(dataReader, "Amount", Decimal.Zero);
            sol_OrdersDetail.Status           = SqlClientUtility.GetString(dataReader, "Status", String.Empty);
            sol_OrdersDetail.CategoryButtonID = SqlClientUtility.GetInt32(dataReader, "CategoryButtonID", 0);
            sol_OrdersDetail.BagID            = SqlClientUtility.GetInt32(dataReader, "BagID", 0);
            //sol_OrdersDetail.IsNew = SqlClientUtility.GetBoolean(dataReader, "IsNew", false);
            sol_OrdersDetail.ConveyorID = SqlClientUtility.GetInt32(dataReader, "ConveyorID", 0);
            sol_OrdersDetail.StageID    = SqlClientUtility.GetInt32(dataReader, "StageID", 0);

            return(sol_OrdersDetail);
        }
Пример #6
0
        private void UpdateOrders()
        {
            //bool firstTime = true;
            int    orderId   = 0;
            string orderType = "";

            Sol_Order               sol_Order            = new Sol_Order();
            Sol_Order_Sp            sol_Order_Sp         = new Sol_Order_Sp(Properties.Settings.Default.WsirDbConnectionString);
            Sol_OrdersDetail        sol_OrdersDetail     = new Sol_OrdersDetail();
            Sol_OrdersDetail_Sp     sol_OrdersDetail_Sp  = new Sol_OrdersDetail_Sp(Properties.Settings.Default.WsirDbConnectionString);
            List <Sol_OrdersDetail> sol_OrdersDetailList = new List <Sol_OrdersDetail>();

            //items
            ListView.ListViewItemCollection Items = listView1.Items;
            foreach (ListViewItem item in Items)
            {
                if (!Int32.TryParse(item.SubItems[0].Text, out orderId))
                {
                    MessageBox.Show("We couldn't parse Order " + item.SubItems[0].Text);
                    continue;
                }

                orderType = item.SubItems[4].Text;

                //read order
                sol_Order = sol_Order_Sp.Select(orderId, orderType);

                //not found?
                if (sol_Order == null)
                {
                    MessageBox.Show(String.Format("Order #{0} not found!", orderId));
                    continue;
                }

                //search for customer data if its on account
                //Sol_Customer_Sp sol_Customer_Sp = new Sol_Customer_Sp(Properties.Settings.Default.WsirDbConnectionString);
                //Sol_Customer  sol_Customer = sol_Customer_Sp.Select(customerId);
                //sol_Order.CustomerID = customerId;
                //sol_Order.Name = sol_Customer.Name;
                //sol_Order.Address1 = sol_Customer.Address1;
                //sol_Order.Address2 = sol_Customer.Address2;
                //sol_Order.City = sol_Customer.City;
                //sol_Order.Province = sol_Customer.Province;
                //sol_Order.Country = sol_Customer.Country;
                //sol_Order.PostalCode = sol_Customer.PostalCode;

                //check number
                if (radioButtonCheckNumber.Checked)
                {
                    sol_Order.Reference     = textBoxCheckNumber.Text;
                    sol_Order.PaymentTypeID = 1;
                }
                else
                {
                    sol_Order.Reference = textBoxReference.Text;
                    //sol_Order.Status = "P"; //paid, cash  //we know is paid by checking datepaid field
                    sol_Order.CashTrayID    = (int)comboBoxCashTray.SelectedValue;
                    sol_Order.PaymentTypeID = 2;
                }

                ////close order if it is not
                //if (sol_Order.DateClosed < sol_Order.Date)
                //    sol_Order.DateClosed = Main.rc.FechaActual;

                sol_Order.DatePaid = Main.rc.FechaActual;

                sol_Order_Sp.Update(sol_Order);

                //close order if it is not
                if (sol_Order.DateClosed < sol_Order.Date)
                {
                    sol_Order_Sp.UpdateDates(sol_Order.OrderID, sol_Order.OrderType, "", "DateClosed");
                }

                sol_Order_Sp.UpdateDates(sol_Order.OrderID, sol_Order.OrderType, "", "DatePaid");


                //mark details if paid with cash
                if (radioButtonCashTray.Checked)
                {
                    sol_OrdersDetailList = sol_OrdersDetail_Sp._SelectAllByOrderID_OrderType(orderId, orderType);
                    foreach (Sol_OrdersDetail od in sol_OrdersDetailList)
                    {
                        sol_OrdersDetail        = sol_OrdersDetail_Sp.Select(od.DetailID);
                        sol_OrdersDetail.Status = sol_Order.Status;
                        sol_OrdersDetail_Sp.Update(sol_OrdersDetail);
                    }
                }
            }
        }
Пример #7
0
        private void CreateAdjustemnt()
        {
            bool flagDone = false;

            //classes of tables
            sol_Order           = new Sol_Order();
            sol_Order_Sp        = new Sol_Order_Sp(Properties.Settings.Default.WsirDbConnectionString);
            sol_OrdersDetail    = new Sol_OrdersDetail();
            sol_OrdersDetail_Sp = new Sol_OrdersDetail_Sp(Properties.Settings.Default.WsirDbConnectionString);


            //if (MessageBox.Show("Do you want to continue", "Closing Voucher", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != System.Windows.Forms.DialogResult.Yes)
            //    return;

            //int totalqty = 0;
            decimal totalamt = 0.00M;
            int     nrows    = listViewUnstagedProducts.Items.Count;

            sol_Order.OrderType     = "A";  // R = Returns, S = Sales, A = Adjustment
            sol_Order.WorkStationID = -1;   // Main.Sol_ControlInfo.WorkStationID;

            //computer name
            string c = Properties.Settings.Default.SettingsWsWorkStationName.Trim();

            if (String.IsNullOrEmpty(c))
            {
                c = Main.myHostName;
            }
            sol_Order.ComputerName = c;  //

            MembershipUser membershipUser = membershipUser = Membership.GetUser(Properties.Settings.Default.UsuarioNombre);

            if (membershipUser == null)
            {
                MessageBox.Show("User does not exits, cannot create Adjustment!");
                return;
            }
            Guid userId = (Guid)membershipUser.ProviderUserKey;

            sol_Order.UserID     = userId;
            sol_Order.Date       = Main.rc.FechaActual; // ;// Properties.Settings.Default.FechaActual;
            sol_Order.CustomerID = 0;                   // (none)
            sol_Order.Status     = "A";                 //Applied

            //?? we close it below again with sqlserver getdate funtion
            sol_Order.DateClosed = sol_Order.Date;  //DateTime.Parse("1753-1-1 12:00:00");

            sol_Order.DatePaid = DateTime.Parse("1753-1-1 12:00:00");
            //sol_Order.IsNew = true;
            sol_Order_Sp.Insert(sol_Order);

            //close order
            sol_Order_Sp.UpdateDates(sol_Order.OrderID, sol_Order.OrderType, "", "DateClosed");


            //int detailID
            //int orderID
            sol_OrdersDetail.OrderID = sol_Order.OrderID;
            //string orderType
            sol_OrdersDetail.OrderType = sol_Order.OrderType;
            //date
            sol_OrdersDetail.Date = sol_Order.Date;
            //string status
            sol_OrdersDetail.Status = sol_Order.Status;

            for (int i = 0; i < nrows; i++)
            {
                //int quantity
                c = listViewUnstagedProducts.Items[i].SubItems[1].Text;
                c = c.Replace("$", "");
                c = c.Replace("(", "");
                c = c.Replace(")", "");
                c = c.Replace(",", "");

                int quantity = 0;
                try
                {
                    quantity = Convert.ToInt32(c);
                }
                catch
                {
                    string m = String.Format("Error found in quantity: {0} ", c);
                    MessageBox.Show(m, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    continue;
                }

                c = this.arrayListViewQuantity[i].ToString();

                int oldQuantity = (int)this.arrayListViewQuantity[i];
                if (oldQuantity == quantity)
                {
                    continue;
                }

                int adjustmenQuantity = quantity - oldQuantity;
                sol_OrdersDetail.Quantity = adjustmenQuantity;

                //totalqty = totalqty + (adjustmenQuantity);

                //int categoryID
                sol_OrdersDetail.CategoryID = (int)this.arrayListViewCategoryId[i];

                //int productID
                //string description
                sol_OrdersDetail.Description = listViewUnstagedProducts.Items[i].SubItems[0].Text;

                //decimal price
                sol_OrdersDetail.Price = (decimal)arrayListViewRefundAmount[i];

                //decimal amount
                //c = listViewUnstagedProducts.Items[i].SubItems[3].Text;
                //c = c.Replace('$', ' ');
                decimal amount = sol_OrdersDetail.Quantity * sol_OrdersDetail.Price;
                sol_OrdersDetail.Amount = amount;
                totalamt = totalamt + amount;


                //add row
                //sol_OrdersDetail.IsNew = true;
                sol_OrdersDetail_Sp.Insert(sol_OrdersDetail);

                flagDone = true;
            }

            if (flagDone)
            {
                //update TotalAmount
                sol_Order.TotalAmount = totalamt;
                //?? we close it again below with getdate()
                sol_Order.DateClosed = Main.rc.FechaActual; // ; // Properties.Settings.Default.FechaActual;;
                sol_Order_Sp.Update(sol_Order);

                //close order
                sol_Order_Sp.UpdateDates(sol_Order.OrderID, sol_Order.OrderType, "", "DateClosed");
            }
            else
            {
                sol_Order_Sp.Delete(sol_Order.OrderID, sol_Order.OrderType);
                MessageBox.Show("No adjustment created.");
            }
        }
Пример #8
0
        private void UpdateOrders()
        {
            //bool firstTime = true;
            int    orderId   = 0;
            string orderType = "";

            totalPaidOrders = 0;

            Sol_Order_Sp            sol_Order_Sp         = new Sol_Order_Sp(Properties.Settings.Default.WsirDbConnectionString);
            Sol_OrdersDetail        sol_OrdersDetail     = new Sol_OrdersDetail();
            Sol_OrdersDetail_Sp     sol_OrdersDetail_Sp  = new Sol_OrdersDetail_Sp(Properties.Settings.Default.WsirDbConnectionString);
            List <Sol_OrdersDetail> sol_OrdersDetailList = new List <Sol_OrdersDetail>();

            //items
            ListView.ListViewItemCollection Items = listView1.Items;
            foreach (ListViewItem item in Items)
            {
                if (!Int32.TryParse(item.SubItems[0].Text, out orderId))
                {
                    MessageBox.Show("We couldn't parse Order " + item.SubItems[0].Text);
                    continue;
                }

                orderType = item.SubItems[4].Text;


                //read order
                Sol_Order sol_Order = sol_Order_Sp.Select(orderId, orderType);

                //not found?
                if (sol_Order == null)
                {
                    MessageBox.Show(String.Format("Order #{0} not found!", orderId));
                    continue;
                }


                //marked as paid
                if (onAccount)
                {
                    //search for customer data if its on account
                    Sol_Customer    sol_Customer    = new Sol_Customer();
                    Sol_Customer_Sp sol_Customer_Sp = new Sol_Customer_Sp(Properties.Settings.Default.WsirDbConnectionString);
                    sol_Customer         = sol_Customer_Sp.Select(customerId);
                    sol_Order.CustomerID = customerId;
                    //sol_Order.Name = sol_Customer.Name;
                    //sol_Order.Address1 = sol_Customer.Address1;
                    //sol_Order.Address2 = sol_Customer.Address2;
                    //sol_Order.City = sol_Customer.City;
                    //sol_Order.Province = sol_Customer.Province;
                    //sol_Order.Country = sol_Customer.Country;
                    //sol_Order.PostalCode = sol_Customer.PostalCode;

                    sol_Order.Status = "O"; //O = On account
                    //sol_Order_Sp.Update(sol_Order);
                }
                else
                {
                    sol_Order.DatePaid = Main.rc.FechaActual;
                    sol_Order.Status   = "P"; //paid, processed
                }

                //close order if it is not
                if (sol_Order.DateClosed < sol_Order.Date)
                {
                    sol_Order.DateClosed = Main.rc.FechaActual;
                }


                sol_Order_Sp.Update(sol_Order);

                totalPaidOrders = totalPaidOrders + sol_Order.TotalAmount - sol_Order.FeeAmount;

                //close order if it is not
                if (sol_Order.DateClosed < sol_Order.Date)
                {
                    sol_Order_Sp.UpdateDates(sol_Order.OrderID, sol_Order.OrderType, "", "DateClosed");
                }

                //paid
                if (!onAccount)
                {
                    sol_Order_Sp.UpdateDates(sol_Order.OrderID, sol_Order.OrderType, "", "DatePaid");
                }


                //mark details
                sol_OrdersDetailList = sol_OrdersDetail_Sp._SelectAllByOrderID_OrderType(orderId, orderType);
                foreach (Sol_OrdersDetail od in sol_OrdersDetailList)
                {
                    sol_OrdersDetail        = sol_OrdersDetail_Sp.Select(od.DetailID);
                    sol_OrdersDetail.Status = sol_Order.Status;
                    sol_OrdersDetail_Sp.Update(sol_OrdersDetail);
                }


                if (Main.CardReader_Enabled)
                {
                    UpdateOrderCardLink(orderId);
                }
            }
        }