예제 #1
0
        private void SaveData()
        {
            try
            {
                int i = 0;

                #region General Setting

                #region Pay Type
                //foreach (var taPaymentTypeInfo in CommonData.TaPaymentType)
                //{
                //    taPaymentTypeInfo.PaymentType = txtGsPayType[i].Text;

                //    _control.UpdateEntity(taPaymentTypeInfo);

                //    i++;
                //}
                #endregion

                CommonDAL.GetSysValue(PubComm.SYS_VALUE_FREE_FOOD_ITEM_AMOUNT, PubComm.SYS_DESC_FREE_FOOD_ITEM_AMOUNT, txtTotalAmountThreshold.Text);

                #region Free Food
                i = 0;
                foreach (var taFreeFoodInfo in CommonData.TaFreeFood)
                {
                    taFreeFoodInfo.DishCode = txtGsFreeFoodItem[i].Text;

                    _control.UpdateEntity(taFreeFoodInfo);

                    i++;
                }
                #endregion

                #region Automatic Added Item on Checkout
                CommonDAL.GetSysValue(PubComm.SYS_VALUE_ADD_ITEM_AMOUNT, PubComm.SYS_DESC_ADD_ITEM_AMOUNT, txtAddTotalAmountThreshold.Text);

                i = 0;
                foreach (var taFreeFoodAddInfo in CommonData.TaFreeFoodAdd)
                {
                    taFreeFoodAddInfo.AddDishCode = txtGsAddFreeFoodItem[i].Text;

                    _control.UpdateEntity(taFreeFoodAddInfo);

                    i++;
                }
                #endregion

                #region Discount
                new SystemData().GetTaDiscount();

                TaDiscountInfo discount = new TaDiscountInfo();

                var lstDis = CommonData.TaDiscount.Where(s => s.TaType.Equals("DELIVERY"));
                if (lstDis.Any())
                {
                    discount            = lstDis.FirstOrDefault();
                    discount.TaDiscount = txtDeliveryDiscount.Text;
                    discount.TaDiscThre = txtDeliveryDiscountThreshold.Text;

                    _control.UpdateEntity(discount);
                }
                else
                {
                    discount.TaType     = "DELIVERY";
                    discount.TaDiscount = txtDeliveryDiscount.Text;
                    discount.TaDiscThre = txtDeliveryDiscountThreshold.Text;
                    _control.AddEntity(discount);
                }

                lstDis = CommonData.TaDiscount.Where(s => s.TaType.Equals("COLLECTION"));
                if (lstDis.Any())
                {
                    discount            = lstDis.FirstOrDefault();
                    discount.TaDiscount = txtCollectionDiscount.Text;
                    discount.TaDiscThre = txtCollectionDiscountThreshold.Text;

                    _control.UpdateEntity(discount);
                }
                else
                {
                    discount.TaType     = "COLLECTION";
                    discount.TaDiscount = txtCollectionDiscount.Text;
                    discount.TaDiscThre = txtCollectionDiscountThreshold.Text;
                    _control.AddEntity(discount);
                }

                lstDis = CommonData.TaDiscount.Where(s => s.TaType.Equals("SHOP"));
                if (lstDis.Any())
                {
                    discount            = lstDis.FirstOrDefault();
                    discount.TaDiscount = txtShopDiscount.Text;
                    discount.TaDiscThre = txtShopDiscountThreshold.Text;

                    _control.UpdateEntity(discount);
                }
                else
                {
                    discount.TaType     = "SHOP";
                    discount.TaDiscount = txtShopDiscount.Text;
                    discount.TaDiscThre = txtShopDiscountThreshold.Text;
                    _control.AddEntity(discount);
                }
                #endregion

                #region Menu Display Font
                new SystemData().GetTaConfMenuDisplayFont();

                TaConfMenuDisplayFontInfo taConfMenuDisplayFontInfo = new TaConfMenuDisplayFontInfo();

                if (CommonData.TaConfMenuDisplayFont.Any())
                {
                    taConfMenuDisplayFontInfo = CommonData.TaConfMenuDisplayFont.FirstOrDefault();
                    taConfMenuDisplayFontInfo.MenuDisplayBtnFontSize      = txtMenuDishBtnFontSize.Text;
                    taConfMenuDisplayFontInfo.IsMenuDishCodeFontBold      = chkGsMenuDishCodeFontBold.Checked ? "Y" : "N";
                    taConfMenuDisplayFontInfo.CategBtnFontSize            = txtCategoryBtnFontSize.Text;
                    taConfMenuDisplayFontInfo.IsCategFontBold             = chkGsCategBtnFontBold.Checked ? "Y" : "N";
                    taConfMenuDisplayFontInfo.OtherMenuDisplayBtnFontSize = txtMenuDishBtnOtherFontSize.Text;
                    taConfMenuDisplayFontInfo.IsOtherMenuDishCodeFontBold = chkGsMenuDishCodeOtherFontBold.Checked ? "Y" : "N";
                    taConfMenuDisplayFontInfo.OtherCategBtnFontSize       = txtCategoryBtnOtherFontSize.Text;
                    taConfMenuDisplayFontInfo.IsOtherCategFontBold        = chkGsCategBtnOtherFontBold.Checked ? "Y" : "N";
                    _control.UpdateEntity(taConfMenuDisplayFontInfo);
                }
                else
                {
                    _control.AddEntity(taConfMenuDisplayFontInfo);
                }
                #endregion

                #endregion

                #region Delivery Setting

                #region Delivery Distance Chage
                new SystemData().GetTaDeliverySetDetail();
                TaDeliverySetDetailInfo taDeliverySetDetail = new TaDeliverySetDetailInfo();

                i = 0;
                foreach (var taDeliverySetDetailInfo in CommonData.TaDeliverySetDetail)
                {
                    taDeliverySetDetailInfo.DistFrom    = txtDsDistanceFrom[i].Text;
                    taDeliverySetDetailInfo.DistTo      = txtDsDistanceTo[i].Text;
                    taDeliverySetDetailInfo.AmountToPay = txtDsAmountToPay[i].Text;

                    _control.UpdateEntity(taDeliverySetDetailInfo);

                    i++;
                }
                #endregion

                #region Other Set
                new SystemData().GetTaDeliverySet();

                var lstTds = CommonData.TaDeliverySet.ToList();

                TaDeliverySetInfo taDeliverySetInfo = new TaDeliverySetInfo();
                taDeliverySetInfo.PerMile  = txtPerMile.Text;
                taDeliverySetInfo.OverMile = txtOverMile.Text;
                //taDeliverySetInfo.IsDeliveryCharge = chkDeliveryChge.Checked ? "Y" : "N";
                taDeliverySetInfo.IsDeliveryCharge = "Y";
                taDeliverySetInfo.DeliveryMile     = chkIgnoreDeliveryIfCharge.Checked ? "Y" : "N";
                taDeliverySetInfo.IsIgnoreDelivery = chkIgnoreDelivery.Checked ? "Y" : "N";
                taDeliverySetInfo.OrderThreshold   = txtOrderThreshold.Text;
                taDeliverySetInfo.SurchargeAmount  = txtSurchargeAmount.Text;

                try
                {
                    if (lstTds.Any())
                    {
                        taDeliverySetInfo.ID = lstTds.FirstOrDefault().ID;
                        _control.UpdateEntity(taDeliverySetInfo);
                    }
                    else
                    {
                        _control.AddEntity(taDeliverySetInfo);
                    }
                }
                catch (Exception ex) { LogHelper.Error(this.Name, ex); }
                #endregion

                #endregion

                #region Change Settings
                var lstIpAttr = CommonData.TaChangeMenuAttr.Where(s => !s.MenuAttrEnglishName.Equals(PubComm.MENU_ITEM_LARGE_ENG) &&
                                                                  !s.MenuAttrEnglishName.Equals(PubComm.MENU_ITEM_SMALL_ENG));
                var lstIp = iMenuAttrID > 0 ? lstIpAttr.Where(s => s.ID == iMenuAttrID).ToList()
                                            : lstIpAttr.Where(s => s.MenuAttrEnglishName.Equals(txtEngName.Text)).ToList();

                if (lstIp.Any())
                {
                    TaChangeMenuAttrInfo taChangeMenuAttrInfo = lstIp.FirstOrDefault();

                    taChangeMenuAttrInfo.MenuAttrEnglishName = txtEngName.Text;
                    taChangeMenuAttrInfo.MenuAttrOtherName   = txtOtherName.Text;
                    taChangeMenuAttrInfo.IncrementPrice      = txtIncrement.Text;

                    _control.UpdateEntity(taChangeMenuAttrInfo);
                }
                #endregion
            }
            catch (Exception ex) { LogHelper.Error(this.Name, ex); }

            CommonTool.ShowMessage("Save successful!");

            if (xtpTaConfig.SelectedTabPage.Name.Equals("xtpChangeSet"))
            {
                SetMenuAtt();
            }
        }
예제 #2
0
        private void BtnAttr_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtEngName.Text))
            {
                SimpleButton btn = (SimpleButton)sender;

                string eName = "";
                string oName = "";

                string strBtnText = btn.Text;

                bool isLargeOrSmall = false;

                if (strBtnText.Equals(PubComm.MENU_ITEM_LARGE_ENG) || strBtnText.Equals(PubComm.MENU_ITEM_SMALL_ENG))
                {
                    isLargeOrSmall = true;
                }

                if (isLargeOrSmall)
                {
                    strBtnText = @"(" + strBtnText + @")";
                }

                if (iLange == PubComm.MENU_LANG_DEFAULT)
                {
                    if (hsMenuName.ContainsKey(strBtnText))
                    {
                        eName = strBtnText;
                        oName = hsMenuName[strBtnText].ToString();
                    }

                    if (isLargeOrSmall)
                    {
                        TaChangeMenuAttrInfo taCmai = lstMenuAttr.FirstOrDefault(s => s.MenuAttrEnglishName.Equals(@"(" + PubComm.MENU_ITEM_LARGE_ENG + @")") ||
                                                                                 s.MenuAttrEnglishName.Equals(@"(" + PubComm.MENU_ITEM_SMALL_ENG + @")"));

                        if (taCmai != null)
                        {
                            lstMenuAttr.Remove(taCmai);
                        }
                    }

                    TaChangeMenuAttrInfo taMenuItemInfo = new TaChangeMenuAttrInfo();
                    taMenuItemInfo.MenuAttrEnglishName = eName;
                    taMenuItemInfo.MenuAttrOtherName   = oName;
                    lstMenuAttr.Add(taMenuItemInfo);
                }
                else
                {
                    if (isLargeOrSmall)
                    {
                        if (hsMenuName.ContainsKey(strBtnText))
                        {
                            foreach (DictionaryEntry kv in hsMenuName)
                            {
                                if (kv.Key.Equals(strBtnText))
                                {
                                    eName = strBtnText;
                                    oName = kv.Value.ToString();
                                    break;
                                }
                            }

                            TaChangeMenuAttrInfo taCmai = lstMenuAttr.FirstOrDefault(s => s.MenuAttrEnglishName.Equals(@"(" + PubComm.MENU_ITEM_LARGE_ENG + @")") ||
                                                                                     s.MenuAttrEnglishName.Equals(@"(" + PubComm.MENU_ITEM_SMALL_ENG + @")"));

                            if (taCmai != null)
                            {
                                lstMenuAttr.Remove(taCmai);
                            }

                            TaChangeMenuAttrInfo taMenuItemInfo = new TaChangeMenuAttrInfo();
                            taMenuItemInfo.MenuAttrEnglishName = eName;
                            taMenuItemInfo.MenuAttrOtherName   = oName;
                            lstMenuAttr.Add(taMenuItemInfo);
                        }
                    }
                    else
                    {
                        if (hsMenuName.ContainsValue(strBtnText))
                        {
                            foreach (DictionaryEntry kv in hsMenuName)
                            {
                                if (kv.Value.Equals(strBtnText))
                                {
                                    eName = kv.Key.ToString();
                                    oName = strBtnText;
                                    break;
                                }
                            }

                            TaChangeMenuAttrInfo taMenuItemInfo = new TaChangeMenuAttrInfo();
                            taMenuItemInfo.MenuAttrEnglishName = eName;
                            taMenuItemInfo.MenuAttrOtherName   = oName;
                            lstMenuAttr.Add(taMenuItemInfo);
                        }
                    }
                }

                if (isLargeOrSmall)
                {
                    if (txtEngName.Text.Contains(@"(" + PubComm.MENU_ITEM_LARGE_ENG + @")"))
                    {
                        txtEngName.Text   = txtEngName.Text.Replace(@"(" + PubComm.MENU_ITEM_LARGE_ENG + @")", eName);
                        txtOtherName.Text = txtOtherName.Text.Replace(@"(" + PubComm.MENU_ITEM_LARGE_OTHER + @")", oName);
                    }
                    else if (txtEngName.Text.Contains(@"(" + PubComm.MENU_ITEM_SMALL_ENG + @")"))
                    {
                        txtEngName.Text   = txtEngName.Text.Replace(@"(" + PubComm.MENU_ITEM_SMALL_ENG + @")", eName);
                        txtOtherName.Text = txtOtherName.Text.Replace(@"(" + PubComm.MENU_ITEM_SMALL_OTHER + @")", oName);
                    }
                    else
                    {
                        txtEngName.Text   += @" " + eName;
                        txtOtherName.Text += @" " + oName;
                    }
                }
                else
                {
                    txtEngName.Text   += @" " + eName;
                    txtOtherName.Text += @" " + oName;
                }

                txtIncrement.Text = GetIncrementPrice(strBtnText, iLange);

                if (string.IsNullOrEmpty(txtIncrement.Text))
                {
                    txtIncrement.Text = @"0.00";
                }

                //txtNewPrice.Text = (Convert.ToDecimal(txtNewPrice.Text) + Convert.ToDecimal(txtIncrement.Text)).ToString();
            }
        }