protected void btnSubmit_Click(object sender, EventArgs e) { DateTime goDate = tbBegin.Text.Trim().ToArrowDateTime(); DateTime backDate = tbEnd.Text.Trim().ToArrowDateTime(); int totalNum = tbNum.Text.Trim().ToArrowInt(); int remainNum = tbRemain.Text.Trim().ToArrowInt(); decimal outerPrice = tbPrice.Text.Trim().ToArrowDecimal(); decimal innerPrice = tbMemberPrice.Text.Trim().ToArrowDecimal(); decimal deposit = tbDeposit.Text.Trim().ToArrowDecimal(); string gatheringTime = tbGatheringTime.Text.Trim(); string gatheringPlace = tbGatheringPlace.Text.Trim(); string transfer = tbTransfer.Text.Trim(); string leader = tbLeader.Text.Trim(); if ((goDate == DateTime.MinValue).ValidateSuccess("出团日期不正确!")) { return; } if ((backDate == DateTime.MinValue).ValidateSuccess("回程日期不正确!")) { return; } if ((goDate <= DateTime.Now).ValidateSuccess("出团日期必须大于今天!")) { return; } if ((backDate <= goDate).ValidateSuccess("返程日期必须大于出团日期!")) { return; } if ((totalNum <= 0).ValidateSuccess("参团人数不正确!")) { return; } if ((remainNum <= 0).ValidateSuccess("剩余位数不正确!")) { return; } if ((outerPrice <= 0M).ValidateSuccess("价格不正确!")) { return; } if ((innerPrice <= 0M).ValidateSuccess("会员价不正确!")) { return; } if ((deposit <= 0M).ValidateSuccess("订金不正确!")) { return; } if (GroupID == 0) { var model = new TravelGroupInfo(); model.AddTime = DateTime.Now; model.AddUserName = CurrentAdmin.UserName; model.AddUserRealName = CurrentAdmin.RealName; model.BackDate = backDate; model.BackTravel = ""; model.Deposit = deposit; model.GatheringPlace = gatheringPlace; model.GatheringTime = gatheringTime; model.GoDate = goDate; model.GoTravel = ""; model.GroupNum = ""; //团号 model.GruopLeader = leader; model.InnerPrice = innerPrice; model.IsDel = 0; model.IsPublish = 0; model.JoinNum = 0; model.RemainNum = remainNum; model.LineID = LineID; model.Name = ""; model.OuterPrice = outerPrice; model.PromotionNum = 0; model.Remarks = ""; model.TotalNum = totalNum; model.TransferPlace = transfer; model.TravelGuide = ""; GroupBLL.AddGroup(model); MessageBox.Show("添加成功!", CurrentUrl); } else { var model = GroupBLL.SelectGroup(GroupID); if (model == null) { return; } model.BackDate = backDate; model.Deposit = deposit; model.GatheringPlace = gatheringPlace; model.GatheringTime = gatheringTime; model.GoDate = goDate; model.GruopLeader = leader; model.InnerPrice = innerPrice; model.LineID = LineID; model.OuterPrice = outerPrice; model.TotalNum = totalNum; model.RemainNum = remainNum; model.TransferPlace = transfer; GroupBLL.UpdateGroup(model); MessageBox.Show("更新成功!"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { try { Inv_ProductGroup groupObj = new Inv_ProductGroup(); groupObj.GroupName = txtGroupName.Text; //if (groupBll.GetGroupByName(groupObj.GroupName) != null) //{ // lblMessage.Text = "Data Already in the List"; // lblMessage.ForeColor = System.Drawing.Color.Red; // txtGroupName.Text = ""; // return; //} int Groupcount = (from grp in _context.Inv_ProductGroup where grp.GroupName == groupObj.GroupName select grp.GroupId).Count(); if (Groupcount == 0) { if (btnSubmit.Text == "Submit") { //groupObj.EditUser = Guid.Parse("a376708d-757f-4777-bd05-bfc89b6971ce"); groupObj.EditUser = ((SessionUser)Session["SessionUser"]).UserId; int result = groupBll.InsertGroup(groupObj); if (result == 1) { // lblMessage.Text = "Data Saved Successfully"; // lblMessage.ForeColor = System.Drawing.Color.Green; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Saved Successfully')", true); } else { // lblMessage.Text = "Data Saving Failure"; // lblMessage.ForeColor = System.Drawing.Color.Red; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Saving Failure')", true); } } else { int groupId = Convert.ToInt32(hdfProductGroupID.Value); int result = groupBll.UpdateGroup(groupObj, groupId); if (result == 1) { // lblMessage.Text = "Data Updated Successfully"; // lblMessage.ForeColor = System.Drawing.Color.Green; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Updated Successfully')", true); } else { // lblMessage.Text = "Data Updating failure"; // lblMessage.ForeColor = System.Drawing.Color.Red; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Updating failure')", true); } } GetAllProductGroup(); txtGroupName.Text = ""; txtGroupName.Focus(); btnSubmit.Text = "Submit"; } else { //lblMessage.Text = "Data Already Exist"; // lblMessage.ForeColor = System.Drawing.Color.Red; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Already Exist')", true); txtGroupName.Text = ""; txtGroupName.Focus(); btnSubmit.Text = "Submit"; } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true); } }