コード例 #1
0
        /// <summary>
        /// Update the quantity for the live orders
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void BtnUpdateQuantityClick(object sender, EventArgs e)
        {
            //now update the quantity for each menu in the live order details table



            try
            {
                var liveOrder = _orderManagement.GetLiveOrder();
                if (liveOrder != null)
                {
                    var value = ddlWeekAndDates.SelectedValue;

                    var weekPart = value.Split(new char[] { '(' });

                    var dates = weekPart[1].Trim().Replace(")", "");

                    var datePart = dates.Split(new char[] { '-' });

                    //validation added to check if flight schedule is present or not?
                    var flightScheuldeValid = true;

                    try
                    {
                        flightScheuldeValid = _menuProcessor.FlightScheduleValidityCheck(liveOrder.LiveOrderId, Convert.ToDateTime(datePart[0]), Convert.ToDateTime(datePart[1]));
                    }
                    catch { }

                    if (flightScheuldeValid)
                    {
                        _menuProcessor.CalculateQuantity(liveOrder.LiveOrderId, Convert.ToDateTime(datePart[0]), Convert.ToDateTime(datePart[1]));
                        BindGrid();
                    }
                    else
                    {
                        //send mail alert

                        var scheduleMailTemplate = EmailHelper.FlightScheduleMailTemplate;

                        string notificationEmails = (System.Configuration.ConfigurationManager.AppSettings["NotificationEmails"]);

                        var emails = notificationEmails.Split(new char[] { ';' });

                        foreach (var email in emails)
                        {
                            if (!string.IsNullOrEmpty(email))
                            {
                                EmailHelper.SendMail(email, "*****@*****.**", "EMMA- Flight Schedule Issue", scheduleMailTemplate);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //write to Elma
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
コード例 #2
0
        public void btnReOrder_Click(object sender, EventArgs e)
        {
            try
            {
                var orderName = txOrderName.Text;

                if (string.IsNullOrEmpty(orderName))
                {
                    return;
                }

                var hiddenfieldOption = hfchangeoption.Value;

                if (hiddenfieldOption == "1")//straight reprint
                {
                    var currOrderId = lblCurrOrderId.Text;

                    var newliveorderdetails = _orderManagement.CreateReorderFromLiveOrder(Convert.ToInt64(currOrderId));

                    if (newliveorderdetails != null)
                    {
                        // calculate quantity for the new live order
                        var value = ddlWeekAndDates.SelectedValue;

                        var weekPart = value.Split(new char[] { '(' });

                        var dates = weekPart[1].Trim().Replace(")", "");

                        var datePart = dates.Split(new char[] { '-' });

                        _menuProcessor.CalculateQuantity(newliveorderdetails.LiveOrderId, Convert.ToDateTime(datePart[0]), Convert.ToDateTime(datePart[1]));
                        // set the is converted to order column to true in live orders table
                        _orderManagement.CreateReOrderNow(Convert.ToInt64(newliveorderdetails.LiveOrderId), Convert.ToDateTime(datePart[0]), Convert.ToDateTime(datePart[1]), orderName);

                        //update reordercount
                        List <string> reorderedMenuIds = new List <string>();
                        var           liveOrderDetails = _orderManagement.GetLiveOrderDetails(newliveorderdetails.LiveOrderId);
                        foreach (var data in liveOrderDetails)
                        {
                            var menuid = Convert.ToString(data.MenuId);

                            //TODO: upadte the LOT NUM variable
                            _menuProcessor.UpdateLotNoChiliVariable(Convert.ToInt64(menuid));
                            if (!reorderedMenuIds.Contains(menuid))
                            {
                                reorderedMenuIds.Add(menuid);
                            }
                        }
                        _orderManagement.UpdateReOrderCount(reorderedMenuIds);
                    }

                    divProcessdone.Visible    = true;
                    divReorderOptions.Visible = false;

                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "MsgMovedToOrder", "MsgMovedToOrder();", true);

                    var userId = Convert.ToInt32(Session["USERID"]);
                    var user   = _accountManagement.GetUserById(userId);

                    var reorderMessage = EmailHelper.ReorderOption1EmailTemplate;

                    EmailHelper.SendMail(user.Username, "*****@*****.**", "EMMA- Re-Order - Straight Reprint", reorderMessage);

                    string notificationEmails = (System.Configuration.ConfigurationManager.AppSettings["NotificationEmails"]);

                    var emails = notificationEmails.Split(new char[] { ';' });

                    foreach (var email in emails)
                    {
                        if (!string.IsNullOrEmpty(email))
                        {
                            EmailHelper.SendMail(email, "*****@*****.**", "EMMA- Re-Order- Straight Reprint", reorderMessage);
                        }
                    }



                    //ScriptManager.RegisterStartupScript(this, this.GetType(), "KEY", "CloseAndRebind();", true);
                }
                else if (hiddenfieldOption == "2")//schedule update
                {
                    // see if there is a current live order
                    var currLiveorder = _orderManagement.GetLiveOrder();
                    if (currLiveorder != null)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "MsgHasLiveOrders", "MsgHasLiveOrders();", true);
                    }
                    else
                    {
                        var currOrderId         = lblCurrOrderId.Text;
                        var newliveorderdetails = _orderManagement.CreateReorderFromLiveOrder(Convert.ToInt64(currOrderId));
                        if (newliveorderdetails != null)
                        {
                            //update reordercount
                            List <string> reorderedMenuIds = new List <string>();
                            var           liveOrderDetails = _orderManagement.GetLiveOrderDetails(newliveorderdetails.LiveOrderId);
                            foreach (var data in liveOrderDetails)
                            {
                                var menuid = Convert.ToString(data.MenuId);
                                //TODO: upadte the LOT NUM variable
                                _menuProcessor.UpdateLotNoChiliVariable(Convert.ToInt64(menuid));
                                if (!reorderedMenuIds.Contains(menuid))
                                {
                                    reorderedMenuIds.Add(menuid);
                                }
                            }
                            _orderManagement.UpdateReOrderCount(reorderedMenuIds);

                            divProcessdone.Visible    = true;
                            divReorderOptions.Visible = false;

                            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "MsgMovedToLiveOrder", "MsgMovedToLiveOrder();", true);


                            //send email
                            var userId = Convert.ToInt32(Session["USERID"]);
                            var user   = _accountManagement.GetUserById(userId);

                            var reorderMessage = EmailHelper.ReorderOption2EmailTemplate;


                            EmailHelper.SendMail(user.Username, "*****@*****.**", "EMMA- Re-Order with schedule update", reorderMessage);

                            string notificationEmails = (System.Configuration.ConfigurationManager.AppSettings["NotificationEmails"]);

                            var emails = notificationEmails.Split(new char[] { ';' });

                            foreach (var email in emails)
                            {
                                if (!string.IsNullOrEmpty(email))
                                {
                                    EmailHelper.SendMail(email, "*****@*****.**", "EMMA- Re-Order with schedule update", reorderMessage);
                                }
                            }
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "MsgMoveFailed", "MsgMoveFailed();", true);
                        }
                    }
                    //ScriptManager.RegisterStartupScript(this, this.GetType(), "KEY", "CloseAndRebind();", true);
                }
                else if (hiddenfieldOption == "3")//Menu Update
                {
                    var currLiveorder = _orderManagement.GetLiveOrder();
                    if (currLiveorder != null)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "MsgHasLiveOrders", "MsgHasLiveOrders();", true);
                    }
                    else
                    {
                        Thread newThread = new Thread(new ThreadStart(ReorderAllMenuWithMenuUpdate));
                        newThread.Start();

                        btnReOrder.Enabled = false;
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "MsgMenuUpdate", "MsgMenuUpdate();", true);
                    }
                    //ScriptManager.RegisterStartupScript(this, this.GetType(), "KEY", "CloseAndRebind();", true);
                }
                else if (hiddenfieldOption == "0")// select option message
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "MsgSelectOption", "MsgSelectOption();", true);
                }
            }
            catch (Exception ex)
            {
                //write to Elma
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }