Ejemplo n.º 1
0
 /// <summary>
 /// 修改深圳票数
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnsz_Click(object sender, EventArgs e)
 {
     try
     {
         using (TMAwardEntities context = new TMAwardEntities())
         {
             int ticketCount = Convert.ToInt32(txtSZ.Text);
             var dt = (from ent in context.TmpTicket
                      where ent.TicketNO == "深圳"
                      select ent).FirstOrDefault();
             if (dt == null)
             {
                 dt = new TmpTicket();
                 dt.TicketCount = ticketCount.ToString();
                 dt.TicketNO = "深圳";
                 context.AddToTmpTicket(dt);
                 context.SaveChanges();
             }
             else
             {
                 dt.TicketCount = ticketCount.ToString();
                 context.SaveChanges();
             }
         }
         loadData();
     }
     catch(Exception ex)
     {
         Response.Write("<script>alert('" + ex.Message +"')</script>");
     }
 }
Ejemplo n.º 2
0
        public void UpdateQuery(int ticketCount, string ticketNO)
        {
            using (TMAwardEntities context = new TMAwardEntities())
            {

                var dt = (from ent in context.TmpTicket
                         where ent.TicketNO==ticketNO
                         select ent).FirstOrDefault();
                if (dt == null)
                {
                    dt = new TmpTicket();
                    dt.TicketCount = ticketCount.ToString();
                    dt.TicketNO = ticketNO;
                    context.Attach(dt);
                    context.SaveChanges();
                }
                else
                {
                    dt.TicketCount = ticketCount.ToString();
                    context.SaveChanges();
                }
            }
        }