private void setValue(TB_POCai model) { if (model.SupperPrice != null) { txtSupperPrice.Text = string.Format("{0:n2}", model.SupperPrice.Value); } if (model.Total1 != null) { txtTotal1.Text = string.Format("{0:n2}", model.Total1); } //if (model.SupperPrice1 != null) // txtPrice2.Text = string.Format("{0:n2}", model.SupperPrice1.Value); //if (model.Total2 != null) // txtTotal2.Text = string.Format("{0:n2}", model.Total2); //if (model.SupperPrice2 != null) // txtPrice3.Text = string.Format("{0:n2}", model.SupperPrice2.Value); //if (model.Total3 != null) // txtTotal3.Text = string.Format("{0:n2}", model.Total3); //txtSupper2.Text = model.Supplier1; //txtSupper3.Text = model.Supplier2; txtInvName.Text = model.InvName; txtGuestName.Text = model.GuestName; txtNum.Text = model.Num.Value.ToString(); if (model.CaiTime != null) { txtCaiTime.Text = model.CaiTime.Value.ToShortDateString(); } txtIdea.Text = model.Idea; txtUpdateUser.Text = Session["LoginName"].ToString(); txtSupplier.Text = model.Supplier; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request["indexcai"] != null) { int indexcai = Convert.ToInt32(Request["indexcai"]); if (Session["Cais"] != null) { List <TB_POCai> POOrders = Session["Cais"] as List <TB_POCai>; TB_POCai model = POOrders[indexcai]; setValue(model); } } else { txtUpdateUser.Text = Session["LoginName"].ToString(); } } }
protected void btnSave_Click(object sender, EventArgs e) { if (check() == false) { return; } TB_POCai s = new TB_POCai(); s.CaiTime = Convert.ToDateTime(txtCaiTime.Text); s.Idea = txtIdea.Text; s.SupperPrice = Convert.ToDecimal(txtSupperPrice.Text); s.Supplier = txtSupplier.Text; s.UpdateUser = txtUpdateUser.Text; s.Num = Convert.ToDecimal(txtNum.Text); s.Total1 = s.SupperPrice * s.Num.Value; s.Num = Convert.ToDecimal(txtNum.Text); s.InvName = txtInvName.Text; s.GuestName = txtGuestName.Text; //s.Supplier1 = txtSupper2.Text; //s.Supplier2 = txtSupper3.Text; //if (txtPrice2.Text != "") //{ // s.SupperPrice1 = Convert.ToDecimal(txtPrice2.Text); // s.Total2 = s.SupperPrice1.Value * s.Num.Value; //} //if (txtPrice3.Text != "") //{ // s.SupperPrice2 = Convert.ToDecimal(txtPrice3.Text); // s.Total3 = s.SupperPrice2.Value * s.Num.Value; //} //修改 if (Request["indexcai"] != null) { int indexcai = Convert.ToInt32(Request["indexcai"]); if (Session["Cais"] != null) { s.UpdateUser = Session["LoginName"].ToString(); List <TB_POCai> POOrders = Session["Cais"] as List <TB_POCai>; TB_POCai model = POOrders[indexcai]; TB_POCai newSche = s; s.Ids = model.Ids; newSche.IfUpdate = true; POOrders[indexcai] = newSche; Session["Cais"] = POOrders; } this.ClientScript.RegisterStartupScript(this.GetType(), null, "<script> window.close();</script>"); } else { if (Session["Cais"] == null) { List <TB_POCai> POOrders = new List <TB_POCai>(); POOrders.Insert(POOrders.Count, s); Session["Cais"] = POOrders; } else { List <TB_POCai> POOrders = Session["Cais"] as List <TB_POCai>; POOrders.Insert(POOrders.Count, s); Session["Cais"] = POOrders; } clear(); } // this.ClientScript.RegisterStartupScript(this.GetType(), null, "<script> window.close();</script>"); }
public int addTran(VAN_OA.Model.EFrom.TB_POOrder model, VAN_OA.Model.EFrom.tb_EForm eform, List <TB_POOrders> orders, List <TB_POCai> caiOrders, out int MainId) { int id = 0; MainId = 0; using (SqlConnection conn = DBHelp.getConn()) { conn.Open(); SqlTransaction tan = conn.BeginTransaction(); SqlCommand objCommand = conn.CreateCommand(); objCommand.Transaction = tan; TB_POOrdersService OrdersSer = new TB_POOrdersService(); TB_POCaiService caiSer = new TB_POCaiService(); try { objCommand.Parameters.Clear(); tb_EFormService eformSer = new tb_EFormService(); string proNo = eformSer.GetAllE_No("TB_POOrder", objCommand); model.ProNo = proNo; eform.E_No = proNo; id = Add(model, objCommand); MainId = id; eform.allE_id = id; eformSer.Add(eform, objCommand); for (int i = 0; i < orders.Count; i++) { orders[i].Id = id; OrdersSer.Add(orders[i], objCommand); TB_POCai cai = new TB_POCai(); cai.GuestName = orders[i].GuestName; cai.Num = orders[i].Num; cai.InvName = orders[i].InvName; cai.Id = id; caiSer.Add(cai, objCommand); } //for (int i = 0; i < caiOrders.Count; i++) //{ // caiOrders[i].Id = id; // caiSer.Add(caiOrders[i], objCommand); //} tan.Commit(); } catch (Exception) { tan.Rollback(); return(0); } return(id); } }