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(); } }
private void btnSave_Click(object sender, EventArgs e) { #region 保存Delivery Set new SystemData().GetTaDeliverySet(); var lstTds = CommonData.TaDeliverySet.ToList(); TaDeliverySetInfo taDeliverySetInfo = new TaDeliverySetInfo(); taDeliverySetInfo.PerMile = txtPerMile.Text; taDeliverySetInfo.IsDeliveryCharge = chkDeliveryChge.Checked ? "Y" : "N"; taDeliverySetInfo.DeliveryMile = txtMile.Text; 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); } if (!isAdd) { return; } #endregion #region 保存Delivery Set Detail if (string.IsNullOrEmpty(txtDistFrom.Text)) { CommonTool.ShowMessage("Distance From can not NULL!"); return; } if (string.IsNullOrEmpty(txtDistTo.Text)) { CommonTool.ShowMessage("Distance To can not NULL!"); return; } if (string.IsNullOrEmpty(txtAmountToPay.Text)) { CommonTool.ShowMessage("Amount To Pay can not NULL!"); return; } new SystemData().GetTaDeliverySetDetail(); TaDeliverySetDetailInfo taDeliverySetDetailInfo = new TaDeliverySetDetailInfo(); taDeliverySetDetailInfo.DistFrom = txtDistFrom.Text; taDeliverySetDetailInfo.DistTo = txtDistTo.Text; taDeliverySetDetailInfo.AmountToPay = txtAmountToPay.Text; try { if (isAdd) { _control.AddEntity(taDeliverySetDetailInfo); isAdd = false; } else { taDeliverySetDetailInfo.ID = Convert.ToInt32(gvDeliverySet.GetRowCellValue(gvDeliverySet.FocusedRowHandle, "ID")); _control.UpdateEntity(taDeliverySetDetailInfo); } CommonTool.ShowMessage("Save successful!"); BindData(); GetOtherData(); } catch (Exception ex) { LogHelper.Error(this.Name, ex); } #endregion }