/// <summary> /// 订单详情页面 /// </summary> /// <param name="Id"></param> /// <returns></returns> public ActionResult OrderDetail(int?Id) { Userinfo user = Session["user"] as Userinfo; if (user == null) { return(RedirectToAction("Login", "User")); } else { ViewBag.cartcount = db.Cart.Where(c => c.UserId == user.Id).Sum(c => c.Number); ViewBag.user = user; int orderid = Convert.ToInt32(Id); //当前用户的最近订单 var uorder = db.Orders.Where(o => o.Id == orderid && o.UserId == user.Id).FirstOrDefault(); //下单时间格式化 ViewBag.endtime = AddNumber.AddTimestr(uorder.OrderTime); var uorderdetail = db.OrderDetail.Where(or => or.OrdersId == orderid).ToList(); ViewBag.uorder = uorder; ViewBag.uorderdetail = uorderdetail; return(View()); } }
/// <summary> /// 初始化窗体信息 /// </summary> private void initForm() { if (this.hidAddNumberID.Value != "") { this.lstGuideID.Enabled = false; AddNumberMgr aMgr = new AddNumberMgr(); AddNumber addNumber = aMgr.GetAddNumber(this.hidAddNumberID.Value); if (addNumber.AddNumberID != 0) { this.lblPersonName.Text = addNumber.Person.PersonName; this.lstGuideID.ClearSelection(); if (this.lstGuideID.Items.FindByValue(addNumber.Guide.GuideID.ToString()) != null) { this.lstGuideID.Items.FindByValue(addNumber.Guide.GuideID.ToString()).Selected = true; } this.txtTitle.Text = addNumber.Title; this.txtContent.Text = addNumber.Content; if (addNumber.IsAudi == "是") { this.chkIsAudi.Checked = true; this.txtAddInt.Text = addNumber.AddInt.ToString(); this.btnOK.Enabled = false; } } else { this.btnOK.Enabled = false; this.SendMessage("没有找到该信息"); } } }
public void MathRouter(int firstInt, char operatorChar, int secondInt) { if (operatorChar == '+') { AddNumber addnumber = new AddNumber(); addnumber.AddStuff(firstInt, secondInt); } else if (operatorChar == '-') { SubtractNumber subtractnumber = new SubtractNumber(); subtractnumber.SubtractStuff(firstInt, secondInt); } else if (operatorChar == '*') { MultiplyNumber multiplynumber = new MultiplyNumber(); multiplynumber.MultiplyStuff(firstInt, secondInt); } else if (operatorChar == '/') { DivideNumber dividenumber = new DivideNumber(); dividenumber.DivideStuff(firstInt, secondInt); } else if (operatorChar == '%') { ModulusizeNumber modulusizeNumber = new ModulusizeNumber(); modulusizeNumber.ModulusizeStuff(firstInt, secondInt); } }
/// <summary> /// 获取一条AddNumber类信息 /// </summary> /// <param name="AddNumberID">登录编号</param> /// <returns>一条AddNumber类记录</returns> public AddNumber GetAddNumber(string AddNumberID) { AddNumber addNumber = new AddNumber(); Guide2Mgr g2Mgr = new Guide2Mgr(); GuideMgr gMgr = new GuideMgr(); PersonMgr pMgr = new PersonMgr(); ClientMgr cMgr = new ClientMgr(); string strSQL = "SELECT Top 1 * FROM Sys_AddNumber WHERE AddNumberID = " + AddNumberID; DataTable dt = CMMgr.GetDataTable(strSQL); if (dt.Rows.Count > 0) { DataRow row = dt.Rows[0]; addNumber.AddNumberID = int.Parse(row["AddNumberID"].ToString()); addNumber.Title = row["Title"].ToString(); addNumber.Content = row["Content"].ToString(); addNumber.IsAudi = row["IsAudi"].ToString(); addNumber.Person = pMgr.GetPerson(row["PersonID"].ToString()); addNumber.Client = cMgr.GetClient(row["ClientID"].ToString()); addNumber.Guide2 = g2Mgr.GetGuide2(row["Guide2ID"].ToString()); addNumber.Guide = gMgr.GetGuide(row["GuideID"].ToString()); addNumber.AddInt = int.Parse(row["AddInt"].ToString()); return(addNumber); } else { return(addNumber); } }
static void Main(string[] args) { Console.WriteLine("Hello World!"); //Without Lambda AddNumber del = new AddNumber(AddNumberHandler); del(10, 20); //With Lambda AddNumber add = (a, b) => Console.WriteLine($"result = {a + b}"); add(1, 3); BizRuleDelegate addRule = (x, y) => x + y; BizRuleDelegate multiplyRule = (x, y) => x * y; var data = new ProcessData(); data.Process(10, 20, addRule); data.Process(2, 4, multiplyRule); //Using Action<T> var actionDemo = new ActionDemo(); actionDemo.DoAction(); //Using Func<T, TResult> var funcDemo = new FuncDemo(); funcDemo.DoFunc(); Console.ReadKey(true); }
public void AddNumber_NotNull() { operation = OperationBuilder.Build(new CalculationStack(), CalculationMode.Number, OperationType.ADD); AddNumber a = operation as AddNumber; a.Execute(); Assert.IsNotNull(a); }
public void EnsureOnePlusOne() { AddNumber addnumber = new AddNumber(); int expectedResult = 2; int actualResult = addnumber.AddStuff(1, 1); Assert.AreEqual(expectedResult, actualResult); }
public static AddPhonNumber CreateForm(AddNumber bind) { databind = bind; if (_danli == null) { _danli = new AddPhonNumber(); } return(_danli); }
static void Main(string[] args) { AddNumber method = r => { Console.WriteLine(r + r); Console.Read(); } method(1); }
// implementation of CompareTo method // comapres first by State,then City, // then streetName and Address number // then apartment unit // Exception if( Null object found ) public int CompareTo(Object alpha) { if (alpha == null) { throw new ArgumentNullException("Property object being compared with is NULL"); } Property rightOp = alpha as Property; if (rightOp != null) { if (State.ToLower().CompareTo(rightOp.State.ToLower()) == 0) { if (City.ToLower().CompareTo(rightOp.City.ToLower()) == 0) { if (StreetName.ToLower().CompareTo(rightOp.StreetName.ToLower()) == 0) { if (AddNumber.CompareTo(rightOp.AddNumber) == 0) { if (rightOp is Apartment) { Apartment rightObject = (Apartment)rightOp; Apartment thisObject = (Apartment)this; return(thisObject.Unit.ToLower().CompareTo(rightObject.Unit.ToLower())); } else { return(0); //becasue we have more typies of property now, if the addresses are the same, then the ranking of two properties are the same //throw new ArgumentNullException("Error:the address of house has been inputted"); } } else { return(AddNumber.CompareTo(rightOp.AddNumber)); } } else { return(StreetName.CompareTo(rightOp.StreetName)); } } else { return(City.CompareTo(rightOp.City)); } } else { return(State.CompareTo(rightOp.State)); } } else { throw new ArgumentNullException("Property object being compared with is NULL"); } }
// implementation of CompareTo method // comapres first by State,then City, // then streetName and Address number // then apartment unit // Exception if( Null object found ) public int CompareTo(Object alpha) { if (alpha == null) { throw new ArgumentNullException("Property object being compared with is NULL"); } Property rightOp = alpha as Property; if (rightOp != null) { if (State.CompareTo(rightOp.State) == 0) { if (City.CompareTo(rightOp.City) == 0) { if (StreetName.CompareTo(rightOp.StreetName) == 0) { if (AddNumber.CompareTo(rightOp.AddNumber) == 0) { if (rightOp is Apartment) { Apartment rightObject = (Apartment)rightOp; Apartment thisObject = (Apartment)this; return(thisObject.Unit.CompareTo(rightObject.Unit)); } else { throw new ArgumentNullException("Error:the address of house has beed inputted"); } } else { return(AddNumber.CompareTo(rightOp.AddNumber)); } } else { return(StreetName.CompareTo(rightOp.StreetName)); } } else { return(City.CompareTo(rightOp.City)); } } else { return(State.CompareTo(rightOp.State)); } } else { throw new ArgumentNullException("Property object being compared with is NULL"); } }
protected void btnOK_Click(object sender, EventArgs e) { AddNumberMgr sMgr = new AddNumberMgr(); AddNumber addNumber = sMgr.GetAddNumber(this.hidAddNumberID.Value); int AddInt = 0; if (this.chkIsAudi.Checked) { if (this.txtAddInt.Text.Trim() == "") { this.SendMessage("通过审核必须填写增加的分数"); } else if (!int.TryParse(this.txtAddInt.Text.Trim(), out AddInt)) { this.SendMessage("增加的分数必须为一个整数"); } else { addNumber.IsAudi = "是"; addNumber.AddInt = AddInt; sMgr.UpdateAddNumber(addNumber); AssesMgr mgr = new AssesMgr(); Asses asses = new Asses(); asses.Guide.GuideID = addNumber.Guide.GuideID; switch (asses.Guide.GuideID) { case 1: asses.Guide2.Guide2ID = 4; break; case 2: asses.Guide2.Guide2ID = 9; break; case 3: asses.Guide2.Guide2ID = 14; break; } asses.Memo = ""; asses.Person.PersonID = addNumber.Person.PersonID; asses.Scale1 = addNumber.AddInt; mgr.UpdateAsses(asses); this.btnOK.Enabled = false; } } else { addNumber.IsAudi = "否"; addNumber.AddInt = 0; sMgr.UpdateAddNumber(addNumber); } this.SendMessage("信息编辑成功"); }
// GET: Orders /// <summary> /// 添加订单 /// </summary> /// <param name="textpiece_num"></param> /// <param name="texttotal_text"></param> /// <param name="Goodsid"></param> /// <param name="Number"></param> /// <returns></returns> public ActionResult Add(int?addressid, double textpiece_num, double texttotal_text, int?[] Goodsid, int?[] Number) { Userinfo user = Session["user"] as Userinfo; if (user != null) { //新增订单 Orders orders = new Orders { UserId = user.Id, OrderTime = DateTime.Now, Price = (decimal)texttotal_text, AddressId = addressid, OrderState = 0, ordernum = AddNumber.AddSeralNum(DateTime.Now) }; db.Orders.Add(orders); //新增订单明细 //循环添加商品到订单中 for (int i = 0; i < Goodsid.Length; i++) { OrderDetail odetail = new OrderDetail { Orders = orders, GoodsId = Goodsid[i], Number = Number[i], }; db.OrderDetail.Add(odetail); //同时对应得商品减去相应的库存 Goods gooods = db.Goods.Find(Goodsid[i]); gooods.Amount = gooods.Amount - Number[i]; } ; //向订单中添加完毕后,购物车的相关数据清空 IQueryable <int?> cartdelete = Goodsid.AsQueryable(); var cartlist = db.Cart.Where(c => c.UserId == user.Id && cartdelete.Contains(c.GoodsId)); db.Cart.RemoveRange(cartlist); db.SaveChanges(); //获取最新添加的订单编号 // int Id = orders.Id; return(RedirectToAction("OrderDetail", new { Id = orders.Id })); } else { return(RedirectToAction("Login", "User")); } }
static void Main() { AddNumber addnum = new AddNumber(); addnum.FoundFive += a_FoundFive; int Answer = addnum.Add(1, 2); System.Console.WriteLine("Answer = {0}", Answer); Answer = addnum.Add(2, 2); System.Console.WriteLine("Answer = {0}", Answer); Answer = addnum.Add(4, 6); System.Console.WriteLine("Answer = {0}", Answer); Answer = addnum.Add(2, 8); System.Console.WriteLine("Answer = {0}", Answer); }
//public void ConvertString(string a, string op, string b) //{ // int firstNumberInEquation = Convert.ToInt32(a); // char operatorInEquation = Convert.ToChar(op); // int secondNumberInEquation = Convert.ToInt32(b); // MathRouter(firstNumberInEquation, operatorInEquation, secondNumberInEquation); //} public int MathRouter(string firstInt, string operatorChar, string secondInt) { int firstNumberInEquation = Convert.ToInt32(firstInt); char operatorInEquation = Convert.ToChar(operatorChar); int secondNumberInEquation = Convert.ToInt32(secondInt); int result = 0; if (operatorInEquation == '+') { AddNumber addnumber = new AddNumber(); result = addnumber.AddStuff(firstNumberInEquation, secondNumberInEquation); } else if (operatorInEquation == '-') { SubtractNumber subtractnumber = new SubtractNumber(); result = subtractnumber.SubtractStuff(firstNumberInEquation, secondNumberInEquation); } else if (operatorInEquation == '*') { MultiplyNumber multiplynumber = new MultiplyNumber(); result = multiplynumber.MultiplyStuff(firstNumberInEquation, secondNumberInEquation); } else if (operatorInEquation == '/') { DivideNumber dividenumber = new DivideNumber(); result = dividenumber.DivideStuff(firstNumberInEquation, secondNumberInEquation); } else if (operatorInEquation == '%') { ModulusizeNumber modulusizeNumber = new ModulusizeNumber(); result = modulusizeNumber.ModulusizeStuff(firstNumberInEquation, secondNumberInEquation); } // Set the last answer field LastAnswer(result); // Set the last question //LastQuestion($"{firstInt} {operatorChar} {secondInt}"); DisplayAnswer(result, $"{firstInt} {operatorChar} {secondInt}"); return(result); }
private void menuHeal_Click(object sender, RoutedEventArgs e) { AddNumber a = new AddNumber(this, "HEAL"); a.Show(); }
private void MenuItem_Click_1(object sender, RoutedEventArgs e) { AddNumber add = new AddNumber(this, "SPELL"); add.Show(); }
private void btnAddExp_Click(object sender, RoutedEventArgs e) { AddNumber add = new AddNumber(this, "EXP"); add.Show(); }
/// <summary> /// 更新AddNumber类信息 /// </summary> /// <param name="addNumber">留言管理类参数</param> /// <returns>更新成功返回true 否则返回false</returns> public bool UpdateAddNumber(AddNumber addNumber) { string strSQL = ""; SqlDataAdapter sa = null; SqlCommandBuilder builder = null; DataRow row = null; DataTable dt = null; bool returnValue = false; if (addNumber != null) { if (addNumber.AddNumberID == 0) { strSQL = "SELECT Top 0 * FROM Sys_AddNumber"; } else { strSQL = "SELECT Top 1 * FROM Sys_AddNumber WHERE AddNumberID = " + addNumber.AddNumberID.ToString(); } dt = CMMgr.GetDataTable(strSQL); if (dt.Rows.Count > 0) { row = dt.Rows[0]; } else { row = dt.NewRow(); } row["Title"] = addNumber.Title; row["Content"] = addNumber.Content; row["IsAudi"] = addNumber.IsAudi; row["PersonID"] = addNumber.Person.PersonID; row["ClientID"] = addNumber.Client.ClientID; row["Guide2ID"] = addNumber.Guide2.Guide2ID; row["GuideID"] = addNumber.Guide.GuideID; row["AddInt"] = addNumber.AddInt; if (dt.Rows.Count == 0) { dt.Rows.Add(row); } SqlConnection conn = CMMgr.GetConnection(); using (sa = new SqlDataAdapter("SELECT Top 0 * FROM Sys_AddNumber", conn)) { try { builder = new SqlCommandBuilder(sa); sa.Update(dt); returnValue = true; } finally { conn.Close(); conn.Dispose(); } } } return(returnValue); }
private void menuHurt_Click(object sender, RoutedEventArgs e) { AddNumber a = new AddNumber(this, "DAMAGE"); a.Show(); }