protected void vSave_Click(object sender, EventArgs e) { try { //名稱 string Name = this.vName.Text.Trim(); if (string.IsNullOrWhiteSpace(Name) == true) { throw new Exception("名稱不能為空"); } if (_Argument["Mode"] == "Add" && SchoolItemManager.NameCheck(Name) != null) { throw new Exception("學校名稱重複"); } //排序 int Sort; if (int.TryParse(this.vSort.Text, out Sort) == false) { throw new Exception("排序格式錯誤,請輸入整數數字"); } _SchoolItem.Id = (_Argument["Mode"] == "Add") ? Guid.NewGuid().ToString() : _SchoolItem.Id; _SchoolItem.Name = Name; _SchoolItem.Sort = Sort; SchoolItemManager.Save(_SchoolItem); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Message", "alert('儲存成功');window.parent.$.fancybox.close();", true); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Exception", "alert('" + ex.Message + "');", true); } }
protected void vDelete_Click(object sender, EventArgs e) { try { SchoolItemManager.Remove(_SchoolItem); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Message", "alert('刪除成功');window.parent.$.fancybox.close();", true); } catch (Exception ex) { LeftHand.Gadget.Dialog.Alert(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { if (this.IsPostBack == false) { _AreaSelected = (AreaItemManager.GetAll().Count == 0) ? "" : AreaItemManager.GetAll()[0].Id; } else { //判斷選項是否存在 _AreaSelected = (AreaItemManager.GetById(_AreaSelected) != null) ? _AreaSelected : ""; } //_SchoolItems _SchoolItems = SchoolItemManager.GetAll(); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack == false) { _Argument = LeftHand.Gadget.Encoder.DictionaryDecoder(Server.UrlDecode(Request.QueryString.ToString())); } switch (_Argument["Mode"]) { case "Add": _SchoolItem = new SchoolItem(_Argument["AreaItemId"], ""); break; case "Edit": _SchoolItem = SchoolItemManager.Get(_Argument["Id"]); break; } }
private void Render_SchoolItemList() { this.vSchoolList.DataSource = SchoolItemManager.GetByArea(AreaItemManager.GetById(_AreaSelected)); this.vSchoolList.DataBind(); }
protected void Page_PreRender(object sender, EventArgs e) { if (Page.IsPostBack == false) { this.vMemberName.Text = _CurrentOrderItem.MemberName; this.vMemberAccount.Text = _CurrentOrderItem.MemberAccount; this.vMemberPhone.Text = _CurrentOrderItem.MemberPhone; } //vAreaSelector this.vAreaSelector.Items.Clear(); this.vAreaSelector.Items.Add(new ListItem("請選擇", "")); this.vAreaSelector.Items.AddRange(_AllAreas.Select(a => new ListItem(a.Name, a.Id)).ToArray()); ListItem AreaListItem = this.vAreaSelector.Items.FindByText(_CurrentOrderItem.MemberArea); if (AreaListItem != null) { AreaListItem.Selected = true; } //vSchoolSelector this.vSchoolSelector.Items.Clear(); this.vSchoolSelector.Items.Add(new ListItem("請選擇", "")); this.vSchoolSelector.Items.AddRange(SchoolItemManager.GetByArea(AreaItemManager.GetByName(_CurrentOrderItem.MemberArea)).Select(a => new ListItem(a.Name, a.Id)).ToArray()); ListItem SchoolListItem = this.vSchoolSelector.Items.FindByText(_CurrentOrderItem.MemberSchool); if (SchoolListItem != null) { SchoolListItem.Selected = true; } //vShopList this.vShopList.DataSource = ShopItemManager.GetBySchool(SchoolItemManager.GetByName(_CurrentOrderItem.MemberSchool)); this.vShopList.DataBind(); //Calandar DateTime MinDate = DateTime.Now.Date.AddDays(1); string MinDateString = string.Format("new Date({0},{1},{2})", MinDate.Year, MinDate.Month - 1, MinDate.Day); DateTime MaxDate = DateTime.Now.AddDays(60).Date; string MaxDateString = string.Format("new Date({0},{1},{2})", MaxDate.Year, MaxDate.Month - 1, MaxDate.Day); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "BindCalander", string.Format("BindCalander({0},{1});", MinDateString, MaxDateString), true); if (string.IsNullOrWhiteSpace(this.vSelectedDate.Value) == false) { _CurrentOrderItem.OrderDate = DateTime.Parse(this.vSelectedDate.Value).Date; } //RoundList ShopItem SelectedShop = ShopItemManager.GetById(_CurrentOrderItem.ShopId); if (SelectedShop != null && SelectedShop.RoundItems != null && _CurrentOrderItem.OrderDate != null) { //還沒有額滿的回合,包含當日還沒有愈時的 List <RoundItem> NotFullRounds = new List <RoundItem>(); Dictionary <string, int> RoundCount = OrderItemManager.GetRoundCount(_CurrentOrderItem.ShopId, (DateTime)_CurrentOrderItem.OrderDate); foreach (RoundItem Round in SelectedShop.RoundItems) { DateTime OrderDate = (DateTime)_CurrentOrderItem.OrderDate; if (OrderDate <= DateTime.Now && Round.StartTime < DateTime.Now.TimeOfDay) { continue; } if (RoundCount.ContainsKey(Round.Name) == false) { NotFullRounds.Add(Round); continue; } if (RoundCount[Round.Name] < Round.LimitPairAmount == true) { NotFullRounds.Add(Round); continue; } } if (NotFullRounds.Count > 0) { this.vNoRound.Text = ""; this.vRoundList.DataSource = NotFullRounds; this.vRoundList.DataBind(); } else { this.vNoRound.Text = "所有時段都已被預訂,請選擇其他日期或其他分店。"; this.vRoundList.DataSource = null; this.vRoundList.DataBind(); } } this.vSendButton.Text = "下一步"; //Bind_IdCardNumberCheck ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Bind_IdCardNumberCheck", "Bind_IdCardNumberCheck();", true); }