Ejemplo n.º 1
0
        public static void CompleteOrder(
            int orderID
            , string orderType
            , ref List <int> listOfBagsCounted
            , ref List <int> listOfBagsNotCounted
            )
        {
            if (listOfBagsNotCounted.Count < 1)
            {
                return;
            }

            //set the status of the rest of the bags to MISSING
            Qds_Drop_Sp qds_Drop_Sp = new Qds_Drop_Sp(Properties.Settings.Default.WsirDbConnectionString);

            List <Qds_Drop> dl         = qds_Drop_Sp._SelectAllByOrderID_OrderType(orderID, orderType);
            Qds_Drop        qds_Drop   = dl[0];
            Qds_Bag_Sp      qds_Bag_Sp = new Qds_Bag_Sp(Properties.Settings.Default.WsirDbConnectionString);

            List <Qds_Bag> bl = qds_Bag_Sp._SelectAllByDropID(qds_Drop.DropID);
            //create new drop for missing bags
            Qds_Drop nd = new Qds_Drop();

            //nd.DropID = 0;
            nd.CustomerID      = qds_Drop.CustomerID;
            nd.NumberOfBags    = listOfBagsNotCounted.Count; // od.NumberOfBags;
            nd.PaymentMethodID = qds_Drop.PaymentMethodID;
            nd.DepotID         = qds_Drop.DepotID;
            nd.OrderID         = 0;
            nd.OrderType       = "M"; //missing
            qds_Drop_Sp.Insert(nd);

            //move missing bags to new drop
            //foreach(ComboBoxItem i in comboBoxBagId.Items)

            foreach (int id in listOfBagsNotCounted)
            {
                //move missing bag
                Qds_Bag mb = qds_Bag_Sp.Select(id); //bagIdFromComboBox);
                mb.DropID = nd.DropID;
                qds_Bag_Sp.Update(mb);
            }

            //change numer of bags of the original drop
            qds_Drop.NumberOfBags -= listOfBagsNotCounted.Count();
            qds_Drop_Sp.Update(qds_Drop);

            //close order
            Sol_Order_Sp sol_Order_Sp = new Sol_Order_Sp(Properties.Settings.Default.WsirDbConnectionString);
            Sol_Order    sol_Order    = sol_Order_Sp.Select(orderID, orderType);

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

            //is drop ready for payment?
            if (qds_Drop_Sp.IsReady(qds_Drop.DropID))
            {
                string status = String.Empty;
                if (qds_Drop.PaymentMethodID == 1)
                {
                    status = "A";
                }
                else
                {
                    status = "O";
                }
                sol_Order_Sp.UpdateStatus(sol_Order.OrderID, sol_Order.OrderType, status);
            }

            //update customerID
            //sol_Order_Sp._UpdateCustomerID(sol_Order.OrderID, sol_Order.OrderType, qds_Drop.CustomerID);
        }
Ejemplo n.º 2
0
        private void CustomerOrders_Load(object sender, EventArgs e)
        {
            //disable form resizing
            this.FormBorderStyle = FormBorderStyle.FixedSingle;

            if (Properties.Settings.Default.TouchOriented)
            {
                this.Height            = this.Height + (OK.Height) + 150;
                OK.Height              = OK.Height * 2;
                buttonSelectAll.Height = buttonSelectAll.Height * 2;
                buttonRefresh.Height   = buttonRefresh.Height * 2;
                Cancel.Height          = Cancel.Height * 2;

                double substract = dataGridView1.Height / 2.2;

                dataGridView1.Height = dataGridView1.Height + (int)substract;


                toolStripButtonVirtualKb.Visible = true;
                this.radioButtonShowAll.Font     = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                this.radioButtonUnpaidOnly.Font  = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                this.CenterToParent();
            }

            //listview with headers
            listView1.View = View.Details;
            listView1.Columns.Add("Order #", 185, HorizontalAlignment.Right);
            listView1.Columns.Add("Amount", 140, HorizontalAlignment.Right);
            listView1.Columns.Add("Station", 150, HorizontalAlignment.Left);
            listView1.Columns.Add("Employee", 157, HorizontalAlignment.Left);
            listView1.Columns.Add("T", 50, HorizontalAlignment.Center);
            listView1.Columns.Add("Fee", 124, HorizontalAlignment.Right);
            ////6
            //listView1.Columns.Add("Open Time", 210, HorizontalAlignment.Center);
            //7 -> 6
            listView1.Columns.Add("Submit Date", 200, HorizontalAlignment.Center);
            //8 -> 7
            listView1.Columns.Add("Status", 110, HorizontalAlignment.Center);
            //9 -> 8
            listView1.Columns.Add("CashTray", 200, HorizontalAlignment.Center);
            //10 -> 9
            listView1.Columns.Add("Date Paid", 200, HorizontalAlignment.Center);
            //11 -> 10
            listView1.Columns.Add("Reference", 400, HorizontalAlignment.Center);

            listView1.FullRowSelect = true;
            listView1.CheckBoxes    = true;
            listView1.GridLines     = true;
            //listView1.Activation = ItemActivation.OneClick;


            if (sol_CashTray_Sp == null)
            {
                sol_CashTray_Sp = new Sol_CashTray_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }

            if (sol_Order_Sp == null)
            {
                sol_Order_Sp = new Sol_Order_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }


            buttonSolum.Visible      = true;
            buttonVoidOrders.Visible = true;

            if (Main.Sol_ControlInfo.State == "AB" &&
                Main.QuickDrop_DepotID != null && Main.QuickDrop_DepotID.Length == 6)
            {
                //buttonShowAllOrders.Visible = false;
                //buttonSolum.Visible = true;
                buttonQuickDrop.Visible = true;
                buttonDrops.Visible     = true;
                buttonBags.Visible      = true;
                //buttonVoidOrders.Visible = true;

                //buttonSolum.PerformClick();
            }
            else
            {
                //buttonShowAllOrders.Visible = false;
                //buttonSolum.Visible = false;
                this.buttonSolum.Text = "Orders";

                buttonQuickDrop.Visible = false;
                buttonDrops.Visible     = false;
                buttonBags.Visible      = false;
                //buttonVoidOrders.Visible = false;

                this.buttonVoidOrders.Location = new System.Drawing.Point(162, 95);


                //strOrderType = "R";  //R = Returns, S = Sales, A = Adjustment. Q=QuickDrop
                //radioButtonUnpaidOnly.Checked = true;
                //viewType = ViewType.SolumOrders;
            }


            buttonSolum.PerformClick();
            //buttonRefresh.PerformClick();
        }
Ejemplo n.º 3
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.");
            }
        }
Ejemplo n.º 4
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);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        //private void SelectItems(bool select)
        //{
        //    ListView.ListViewItemCollection Items = listViewBags.Items;
        //    foreach (ListViewItem item in Items)
        //        item.Checked = select;
        //}

        #endregion

        private void buttonMissingBags_Click(object sender, EventArgs e)
        {
            ListView.CheckedListViewItemCollection checkedItems = listViewDrops.CheckedItems;
            if (checkedItems.Count < 1)
            {
                MessageBox.Show("No Drop selected");
                return;
            }

            string strDropId = string.Empty;
            int    orderId   = 0;

            foreach (ListViewItem item in checkedItems)
            {
                strDropId = item.SubItems[0].Text;
                orderId   = 0;
                Int32.TryParse(item.SubItems[4].Text, out orderId);
                break;
            }

            int missingBags = 0;

            List <int> listOfBagsCounted    = new List <int>();
            List <int> listOfBagsNotCounted = new List <int>();

            using (SqlConnection connection = new SqlConnection(Properties.Settings.Default.WsirDbConnectionString))
            {
                string sql = string.Empty;
                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    connection.Open();
                    sql = @"
                        select [BagID]
                        from [qds_bag] 
                        where [DropID] = @DropId 
                        AND YEAR([DateCounted]) > 1753 
                    ";

                    sql = sql.Replace("@DropId", strDropId);
                    command.CommandText = sql;
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            listOfBagsCounted.Add((int)reader[0]);
                        }
                    }

                    sql = sql.Replace("> 1753", "= 1753");
                    command.CommandText = sql;
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            listOfBagsNotCounted.Add((int)reader[0]);
                        }
                    }
                }
            }

            missingBags = listOfBagsNotCounted.Count;

            string m = String.Format("{0} bags from this drop have not been counted yet.  Do you want to complete this order and set the status of the rest of the bags to MISSING?", missingBags);

            if (MessageBox.Show(m, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != System.Windows.Forms.DialogResult.Yes)
            {
                return;
            }


            //busy cursor
            this.Cursor = Cursors.WaitCursor;

            SolFunctions.CompleteOrder(
                orderId
                , "Q"
                , ref listOfBagsCounted
                , ref listOfBagsNotCounted
                );

            //Add comment to order
            if (sol_Order_Sp == null)
            {
                sol_Order_Sp = new Sol_Order_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }

            sol_Order = sol_Order_Sp.Select(orderId, "Q");
            if (sol_Order != null)
            {
                sol_Order.Comments += string.Format("Bags Counted: {0} Bags Missing: {1}. ", listOfBagsCounted.Count(), missingBags);
                sol_Order_Sp.Update(sol_Order);
            }

            this.Cursor = Cursors.Default;
            MessageBox.Show("Ready!");

            buttonRefresh.PerformClick();
        }
Ejemplo n.º 6
0
        private void ReadDrops(bool MineOnly)
        {
            listViewDrops.Items.Clear();

            string orderType = String.Empty;

            if (checkBoxMissingBags.Checked)
            {
                orderType = "M";
            }
            else
            {
                orderType = "Q";
            }

            //qds_DropList = qds_Drop_Sp.SelectAllInProcess();
            qds_DropList = qds_Drop_Sp.SelectAllByOrderTpe(orderType);
            if (qds_DropList != null)
            {
                if (buttonBags.Text == "&Unselect all")
                {
                    buttonBags.Text = "&Select all";
                }
            }


            Guid UserId = new Guid();

            if (MineOnly)
            {
                if (sol_Order_Sp == null)
                {
                    sol_Order_Sp = new Sol_Order_Sp(Properties.Settings.Default.WsirDbConnectionString);
                }

                MembershipUser UserAccount = Membership.GetUser();
                UserId = (Guid)UserAccount.ProviderUserKey;
            }

            //dropID
            //customer
            //bags
            //paymentMethod
            //depotID
            //orderID

            foreach (Qds_Drop or in qds_DropList)
            {
                if (MineOnly)
                {
                    //is not user's order if does not exist
                    if (or.OrderID < 1)
                    {
                        continue;
                    }

                    sol_Order = sol_Order_Sp.Select(or.OrderID, or.OrderType);
                    //is not user's order if does not exist
                    if (sol_Order == null)
                    {
                        continue;
                    }

                    if (UserId != null)
                    {
                        if (UserId != sol_Order.UserID)
                        {
                            continue;
                        }
                    }
                }

                int    dropID   = or.DropID;
                string customer = or.CustomerID.ToString();
                sol_Customer = sol_Customer_Sp.Select(or.CustomerID);
                if (sol_Customer != null)
                {
                    customer = sol_Customer.Name;
                }

                int bags = or.NumberOfBags;

                string paymentMethod = or.PaymentMethodID.ToString();
                qds_PaymentMethod = qds_PaymentMethod_Sp.Select(or.PaymentMethodID);
                if (qds_PaymentMethod != null)
                {
                    paymentMethod = qds_PaymentMethod.PaymentMethod;
                }

                string depotID = or.DepotID;
                int    orderID = or.OrderID;

                addDropItem(dropID, customer, bags, paymentMethod, depotID, orderID, or.OrderType);
            }
        }
Ejemplo n.º 7
0
        private void ViewReceipt(int orderID)
        {
            if (orderID < 1)
            {
                return;
            }

            this.Cursor = Cursors.WaitCursor;

            //query (has a stored procedure)
            string query          = "storedprocedure";
            string subReportName2 = "";
            //query 2
            string query2         = "";
            string subReportName3 = "";
            //query 3
            string query3 = "";


            Sol_Order_Sp sol_Order_Sp = new Sol_Order_Sp(Properties.Settings.Default.WsirDbConnectionString);
            Sol_Order    sol_Order    = sol_Order_Sp._SelectByOrderID(orderID);

            if (sol_Order == null)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show("Transaction # not found, please try another.");
                return;
            }


            CrystalDecisions.CrystalReports.Engine.ReportDocument rp = new Solum.Reports.TransactionSearch();

            object[,] parametros = new object[, ]
            {
                { "1_BusinessName", Main.Sol_ControlInfo.BusinessName },
                { "OrderID", orderID },
                { "", "" }
            };


            bool  imprimirReporte = false;
            bool  exportarReporte = false;
            short fileFormat      = 0;          // 0 = rtf 1 = pdf 2 = word 3 = excel
            bool  preverReporte   = true;
            short numeroDeCopias  = 1;
            //if (Properties.Settings.Default.SettingsWsReceiptPrintPreview)
            //    preverReporte = true;
            //else
            //    imprimirReporte = true;

            ReportesPrevista f1 = new ReportesPrevista(
                Properties.Settings.Default.WsirDbConnectionString,
                Properties.Settings.Default.SQLServidorNombre,
                Properties.Settings.Default.SQLBaseDeDatos,
                Properties.Settings.Default.SQLAutentificacion,
                Properties.Settings.Default.SQLUsuarioNombre,
                Properties.Settings.Default.SQLUsuarioClave,
                rp,
                query,
                query2,
                query3,
                parametros,
                subReportName2,
                subReportName3,
                Properties.Settings.Default.SettingsWsReportPrinter.Trim(),
                fileFormat,
                String.Empty,
                numeroDeCopias,
                exportarReporte,
                imprimirReporte,
                preverReporte,
                null,
                String.Empty,
                true,
                true
                );

            f1.ShowDialog();
            f1.Dispose();
            f1 = null;

            this.Cursor = Cursors.Default;
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 9
0
        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            if (!Main.CheckUserPermission(Properties.Settings.Default.WsirConnectionString, Properties.Settings.Default.UsuarioNombre, "SolEditCatalogues", true))
            {
                return;
            }

            //empty datagrid
            if (this.DataGridView1.Rows.Count < 1)
            {
                return;
            }

            fieldId = (int)this.DataGridView1.CurrentRow.Cells[0].Value;
            if (fieldId == 0)
            {
                MessageBox.Show("Cannot delete this item!");
                return;
            }

            string descripcion = this.DataGridView1.CurrentRow.Cells[2].Value.ToString();

            //check for orders
            if (sol_Order_Sp == null)
            {
                sol_Order_Sp = new Sol_Order_Sp(Properties.Settings.Default.WsirDbConnectionString);
            }

            List <Sol_Order> sol_OrderList = sol_Order_Sp._SelectAllByCustomerID("", fieldId);

            if (sol_OrderList.Count() > 0)
            {
                MessageBox.Show("Cannot delete this customer because he has orders linked to.\r\nFirst delete all his orders and then try again.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (MessageBox.Show(String.Format("Are you sure you want to delete this item: {0}?", descripcion), "Deleting Item", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.Yes)
            {
                int cnt = this.DataGridView1.SelectedRows.Count;
                if (cnt > 1)
                {
                    for (int i = 0; i < cnt; i++)
                    {
                        if (this.DataGridView1.SelectedRows.Count > 0 &&
                            this.DataGridView1.SelectedRows[0].Index !=
                            this.DataGridView1.Rows.Count)
                        {
                            this.DataGridView1.Rows.RemoveAt(
                                this.DataGridView1.SelectedRows[0].Index);
                        }
                    }
                }
                else
                {
                    ((BindingSource)this.DataGridView1.DataSource).RemoveCurrent();
                }


                this.Validate();
                this.BindingSource1.EndEdit();
                this.TableAdapterManager.UpdateAll(this.DataSet1);


                try
                {
                    this.DataGridView1.CurrentCell.Selected = true;
                }
                catch
                {
                    //
                }
            }
        }