示例#1
0
        //protected void MarkTempOrdersItemsAsDone(long pCustomerID)
        //{
        //  string _SQLUpdate = "UPDATE OrdersTbl SET OrdersTbl.Done = True WHERE CustomderId = " + pCustomerID.ToString() +
        //                         "AND EXISTS (SELECT RequiredByDate FROM TempOrdersHeaderTbl " +
        //                         "            WHERE (RequiredByDate = OrdersTbl.RequiredByDate))";

        //  TrackerDb _TrackerDb = new TrackerDb();
        //  _TrackerDb.ExecuteNonQuerySQL(_SQLUpdate);

        //  // ResetCustomerReminderCount(pCustomerId);
        //  //'''''''''''''
        //  //' mark orders as done - should do this last
        //  //'''
        //  //lblStatus.Caption = "Marking orders as done"
        //  //dbs.Execute ("UPDATE OrdersTbl SET OrdersTbl.Done = True " + _
        //  //             "WHERE (((Exists (Select TempOrdersTbl.OrderId from TempOrdersTbl where  " + _
        //  //                       "TempOrdersTbl.OrderId = OrdersTbl.OrderId))<>False))")
        //  //'''''''
        //  //'  Resetting count and enable, only if coffee item
        //  //'
        //  //dbs.Execute ("UPDATE DISTINCTROW CustomersTbl SET ReminderCount = 0, enabled = True WHERE CustomerID=" + lblCustomerID.Caption)
        //}

        // Logic for processing order as done:
        // 1. move items consumed from temp aable to the items consumed for the contact
        // 2. using the summary of the data on the form do calculations around predictions
        //    on when the contact needs items again.
        // 3. Notify client of items deliverred (add option to contacts table)
        // 4. return to the previous page.
        protected void btnDone_Click(object sender, EventArgs e)
        {
            const long MAXQTYINSTOCK = 50;

            TrackerTools _TrackerTools = new TrackerTools();

            _TrackerTools.SetTrackerSessionErrorString(string.Empty);

            Label    _CustomerIDLabel   = (Label)(fvOrderDone.FindControl("CustomerIDLabel"));
            Label    _CustomerNameLabel = (Label)(fvOrderDone.FindControl("CompanyNameLabel"));
            long     _CustomerID        = Convert.ToInt64(_CustomerIDLabel.Text);
            TextBox  _OrderDateLabel    = (TextBox)(fvOrderDone.FindControl("ByDateTextBox"));
            DateTime _OrderDate         = Convert.ToDateTime(_OrderDateLabel.Text);
            double   _CoffeeStock       = 0;
            // store the current data for display later:
            ClientUsageTbl _OriginalUsageDAL  = new ClientUsageTbl();
            ClientUsageTbl _OriginalUsageData = _OriginalUsageDAL.GetUsageData(_CustomerID);

            if (!string.IsNullOrEmpty(_TrackerTools.GetTrackerSessionErrorString()))
            {
                Response.Write(_TrackerTools.GetTrackerSessionErrorString());
            }

            TempOrdersDAL _TempOrdersDAL        = new TempOrdersDAL(); //
            bool          _HasCoffeeInTempOrder = _TempOrdersDAL.HasCoffeeInTempOrder();

            if (!string.IsNullOrEmpty(_TrackerTools.GetTrackerSessionErrorString()))
            {
                Response.Write(_TrackerTools.GetTrackerSessionErrorString());
            }

            /* NEED TO ADD Code to check for zzname */

            // check cup count not in wrong place
            if ((tbxStock.Text.Length > 0) && (Convert.ToInt64(tbxStock.Text) > MAXQTYINSTOCK))
            {
                ltrlStatus.Text = "<b>The stock quantity appears very high please check that you have enterred the correct value in kilograms.</b>";
            }
            else
            {
                _CoffeeStock = String.IsNullOrEmpty(tbxStock.Text) ? 0 : Convert.ToDouble(tbxStock.Text);

                // First we must get the latest cup count
                ltrlStatus.Text = "Calculating the latest cup count";
                GeneralTrackerDbTools _GeneralTrackerDb = new GeneralTrackerDbTools();

                GeneralTrackerDbTools.LineUsageData _LatestCustomerData = _GeneralTrackerDb.GetLatestUsageData(_CustomerID, TrackerTools.CONST_SERVTYPECOFFEE);
                if (!string.IsNullOrEmpty(_TrackerTools.GetTrackerSessionErrorString()))
                {
                    Response.Write(_TrackerTools.GetTrackerSessionErrorString());
                }

                bool _bIsActual = (tbxCount.MaxLength > 0); // if there is a cup count
                long _lCupCount = 0;
                if (tbxCount.MaxLength > 0)
                {
                    _lCupCount = Convert.ToInt64(tbxCount.Text);
                }

                // Calculate the cup count if we do not have it on the form or they entered a value that makes no sense
                if ((_lCupCount < 1) || (_lCupCount < _LatestCustomerData.LastCount))
                {
                    ltrlStatus.Text = "Calculating the latest est cup count";
                    _lCupCount      = _GeneralTrackerDb.CalcEstCupCount(_CustomerID, _LatestCustomerData, _HasCoffeeInTempOrder);
                    _bIsActual      = false;
                }

                //' add items to consumption log
                _lCupCount = AddItemsToClientUsageTbl(_CustomerID, _bIsActual, _lCupCount, _CoffeeStock, _OrderDate);

                // update the last cup count for the client
                if (!_OriginalUsageDAL.UpdateUsageCupCount(_CustomerID, _lCupCount))
                {
                    ltrlStatus.Text = "error updating last count";
                }

                // now update the predictions
                _GeneralTrackerDb.UpdatePredictions(_CustomerID, _lCupCount);

                // update all items in the order table as done that are done
                _TempOrdersDAL.MarkTempOrdersItemsAsDone();

                // reset count and enable client
                _GeneralTrackerDb.ResetCustomerReminderCount(_CustomerID, _HasCoffeeInTempOrder);
                // destroy the temp table that we used to create this temp orders
                _TempOrdersDAL.KillTempOrdersData();

                ShowResults(_CustomerNameLabel.Text, _CustomerID, _OriginalUsageData);
            }
        }
示例#2
0
        //protected void MarkTempOrdersItemsAsDone(long pCustomerID)
        //{
        //  string _SQLUpdate = "UPDATE OrdersTbl SET OrdersTbl.Done = True WHERE CustomderId = " + pCustomerID.ToString() +
        //                         "AND EXISTS (SELECT RequiredByDate FROM TempOrdersHeaderTbl " +
        //                         "            WHERE (RequiredByDate = OrdersTbl.RequiredByDate))";

        //  TrackerDb _TrackerDb = new TrackerDb();
        //  _TrackerDb.ExecuteNonQuerySQL(_SQLUpdate);

        //  // ResetCustomerReminderCount(pCustomerId);
        //  //'''''''''''''
        //  //' mark orders as done - should do this last
        //  //'''
        //  //lblStatus.Caption = "Marking orders as done"
        //  //dbs.Execute ("UPDATE OrdersTbl SET OrdersTbl.Done = True " + _
        //  //             "WHERE (((Exists (Select TempOrdersTbl.OrderId from TempOrdersTbl where  " + _
        //  //                       "TempOrdersTbl.OrderId = OrdersTbl.OrderId))<>False))")
        //  //'''''''
        //  //'  Resetting count and enable, only if coffee item
        //  //'
        //  //dbs.Execute ("UPDATE DISTINCTROW CustomersTbl SET ReminderCount = 0, enabled = True WHERE CustomerID=" + lblCustomerID.Caption)
        //}

        // Logic for processing order as done:
        // 1. move items consumed from temp aable to the items consumed for the contact
        // 2. using the summary of the data on the form do calculations around predictions
        //    on when the contact needs items again.
        // 3. Notify client of items deliverred (add option to contacts table)
        // 4. return to the previous page.
        protected void btnDone_Click(object sender, EventArgs e)
        {
            const long MAXQTYINSTOCK = 50;

            TrackerTools _TrackerTools = new TrackerTools();

            _TrackerTools.SetTrackerSessionErrorString(string.Empty);

            Label    _CustomerIDLabel   = (Label)(fvOrderDone.FindControl("CustomerIDLabel"));
            Label    _CustomerNameLabel = (Label)(fvOrderDone.FindControl("CompanyNameLabel"));
            long     _CustomerID        = Convert.ToInt64(_CustomerIDLabel.Text);
            TextBox  _OrderDateLabel    = (TextBox)(fvOrderDone.FindControl("ByDateTextBox"));
            DateTime _OrderDate         = Convert.ToDateTime(_OrderDateLabel.Text);
            double   _CoffeeStock       = 0;
            // store the current data for display later:
            ClientUsageTbl _OriginalUsageDAL  = new ClientUsageTbl();
            ClientUsageTbl _OriginalUsageData = _OriginalUsageDAL.GetUsageData(_CustomerID);

            if (!string.IsNullOrEmpty(_TrackerTools.GetTrackerSessionErrorString()))
            {
                Response.Write(_TrackerTools.GetTrackerSessionErrorString());
            }

            TempOrdersDAL _TempOrdersDAL        = new TempOrdersDAL(); //
            bool          _HasCoffeeInTempOrder = _TempOrdersDAL.HasCoffeeInTempOrder();

            if (!string.IsNullOrEmpty(_TrackerTools.GetTrackerSessionErrorString()))
            {
                Response.Write(_TrackerTools.GetTrackerSessionErrorString());
            }

            /* NEED TO ADD Code to check for zzname */

            // check cup count not in wrong place
            if ((tbxStock.Text.Length > 0) && (Convert.ToDouble(tbxStock.Text) > MAXQTYINSTOCK))
            {
                showMessageBox _MsgBox = new showMessageBox(this.Page, "Stock seems high",
                                                            "The stock quantity appears very high please check that you have enterred the correct value in kilograms.</b>");
            }
            else
            {
                _CoffeeStock = String.IsNullOrEmpty(tbxStock.Text) ? 0 : Math.Round(Convert.ToDouble(tbxStock.Text), 2);

                // First we must get the latest cup count
                ltrlStatus.Text = "Calculating the latest cup count";
                GeneralTrackerDbTools _GeneralTrackerDb = new GeneralTrackerDbTools();

                GeneralTrackerDbTools.LineUsageData _LatestCustomerData = _GeneralTrackerDb.GetLatestUsageData(_CustomerID, TrackerTools.CONST_SERVTYPECOFFEE);
                if (!string.IsNullOrEmpty(_TrackerTools.GetTrackerSessionErrorString()))
                {
                    showMessageBox _smb = new showMessageBox(this.Page, "Tracker Session Error", _TrackerTools.GetTrackerSessionErrorString());
                }
                bool _bIsActual = (tbxCount.MaxLength > 0); // if there is a cup count
                long _lCupCount = 0;
                if (tbxCount.MaxLength > 0)
                {
                    _lCupCount = Convert.ToInt64(tbxCount.Text);
                }

                // Calculate the cup count if we do not have it on the form or they entered a value that makes no sense
                if ((_lCupCount < 1) || (_lCupCount < _LatestCustomerData.LastCount))
                {
                    ltrlStatus.Text = "Calculating the latest est cup count";
                    _lCupCount      = _GeneralTrackerDb.CalcEstCupCount(_CustomerID, _LatestCustomerData, _HasCoffeeInTempOrder);
                    _bIsActual      = false;
                }
                // clear any repairs that may have been logged
                RepairsTbl _Repairs = new RepairsTbl();
                _Repairs.SetStatusDoneByTempOrder();

                //' add items to consumption log
                _lCupCount = AddItemsToClientUsageTbl(_CustomerID, _bIsActual, _lCupCount, _CoffeeStock, _OrderDate);

                // update the last cup count for the client
                if (!_OriginalUsageDAL.UpdateUsageCupCount(_CustomerID, _lCupCount))
                {
                    showMessageBox _smb = new showMessageBox(this.Page, "Error", "Error updating last count");
                    ltrlStatus.Text = "error updating last count";
                }

                // now update the predictions
                _GeneralTrackerDb.UpdatePredictions(_CustomerID, _lCupCount);

                // update all items in the order table as done that are done
                _TempOrdersDAL.MarkTempOrdersItemsAsDone();

                // reset count and enable client
                _GeneralTrackerDb.ResetCustomerReminderCount(_CustomerID, _HasCoffeeInTempOrder);
                if (_HasCoffeeInTempOrder)
                {
                    _GeneralTrackerDb.SetClientCoffeeOnlyIfInfo(_CustomerID);
                }
                // may need to add another check here to handle if they have ordered maintenance stuff.


                switch (rbtnSendConfirm.SelectedValue)
                {
                case "none":
                    break;

                case "postbox":
                    SendDeliveredEmail(_CustomerID, "placed your order in the your post box.");
                    break;

                case "dispatched":
                    SendDeliveredEmail(_CustomerID, "dispatched you order.");
                    break;

                case "done":
                    SendDeliveredEmail(_CustomerID, "delivered your order and it has signed for.");
                    break;

                default:
                    break;
                }
                // destroy the temp table that we used to create this temp orders
                _TempOrdersDAL.KillTempOrdersData();

                ShowResults(_CustomerNameLabel.Text, _CustomerID, _OriginalUsageData);
            }
        }