private void cambiaCantidad() { try { //var itemToRemove = db.VENTASTICKET_PV.SingleOrDefault(x => x.Ticket_Id == idTicket && x.Prod_Id == idProducto); //returns a single item. //if (itemToRemove != null) //{ // var entity = new VENTASTICKET_PV { // Venta_Cantidad= Convert.ToDecimal(txtCantidad.Text) //}; // db.VENTASTICKET_PV.Attach(entity); // db.SaveChanges(); //} /// VENTASTICKET_PV stud; using (var ctx = new AppDTEntities()) { stud = ctx.VENTASTICKET_PV.Where(s => s.Ticket_Id == idTicket && s.Prod_Id == idProducto).FirstOrDefault <VENTASTICKET_PV>(); } //2. change student name in disconnected mode (out of ctx scope) if (stud != null) { stud.Venta_Cantidad = Convert.ToDecimal(txtCantidad.Text); } this.Close(); } catch (Exception es) { lblError.Visible = true; } }
private void btnTienda_Click(object sender, EventArgs e) { if (this.btnTienda.BackColor == Color.Orange) { var context = new AppDTEntities(); var CrearTicket = new TICKETS_PV //Make sure you have a table called test in DB { Ticket_Subtotal = 0, Ticket_Factura = 0, Ticket_Date = DateTime.Now, Sucu_Id = 1, Ticket_Status = "abierto" }; context.TICKETS_PV.Add(CrearTicket); context.SaveChanges(); var idTicket = db.TICKETS_PV.Max(t => t.Ticket_Id); //RegistroVentaNew objVino = new RegistroVentaNew(idTicket); Panel objVino = new Panel(idTicket); objVino.Show(); } else { //RegistroVentaNew objVino = new RegistroVentaNew(int.Parse(lblTicketTienda.Text)); Panel objVino = new Panel(int.Parse(lblTicketTienda.Text)); objVino.Show(); } this.Close(); }
// GET: GetCheckIn public ActionResult Index() { int inst_id = Convert.ToInt32(Request.QueryString["inst_id"]); int visitid = Convert.ToInt32(Request.QueryString["visit_id"]); int custid = Convert.ToInt32(Request.QueryString["cust_id"]); string lat = Convert.ToString(Request.QueryString["lat"]); string lon = Convert.ToString(Request.QueryString["lon"]); string hr = Convert.ToString(Request.QueryString["hr"]); string fcha = Convert.ToString(Request.QueryString["fcha"]); int emo = Convert.ToInt32(Request.QueryString["emo"]); var succes = ""; using (AppDTEntities objDataContext = new AppDTEntities()) { try { VISITA_REGISTRO vISITA = new VISITA_REGISTRO(); // fields to be insert vISITA.inst_id = inst_id; vISITA.reg_lat = lat; vISITA.reg_lon = lon; vISITA.cust_id = custid; vISITA.reg_date = fcha; vISITA.reg_ini = hr; vISITA.reg_end = hr; vISITA.visi_id = visitid; vISITA.reg_status = 1; vISITA.reg_emo = 0; objDataContext.VISITA_REGISTRO.Add(vISITA); objDataContext.SaveChanges(); var result = from r in objDataContext.VISITA_ASSIGN where r.visi_id == visitid select r; // Get the first record from the result VISITA_ASSIGN vISITA_ASSIGN = result.First(); // Update the product name vISITA_ASSIGN.visi_status = 1; objDataContext.SaveChanges(); succes = "Ok"; } catch (Exception e) { succes = "NoOk"; } } return(Json(new { succes }, JsonRequestBehavior.AllowGet)); }
public List <Login_Logistic_Return> Index(string user, string password) { using (AppDTEntities db = new AppDTEntities()) { return(db.TRANS_LOGISTIC.Where(q => q.tran_user == user && q.tran_password == password).Select(barber => new Login_Logistic_Return() { tran_id = barber.tran_id, tran_name = barber.tran_name, tran_phone = barber.tran_phone }).ToList()); }; }
void pedido_sugerido(int Producto, int Cant, int Tipo) { if (Tipo == 1) { //var desc = db.sp_Stock_Paquete(Producto).ToList(); var desc = db.test_appdt(1).ToList(); var w = desc[0].Value; }//si es venta por paquete else { using (var ctx = new AppDTEntities()) { var stock = db.PRODUCTOS_PV.Where(a => a.Prod_Id == Producto).ToList(); var s1 = Convert.ToInt32(stock[0].Prod_Stock); if (s1 <= 2) { decimal st = Convert.ToDecimal(stock[0].Prod_Stock); string date = DateTime.Now.Date.ToString("yyyy-MM-dd"); var ps = new PEDIDO_SUGERIDO_PV { Prod_Id = Producto, Sucu_Id = "1", Prod_Stock = st, Prod_date = date, Pedi_Status = 0 }; db.PEDIDO_SUGERIDO_PV.Add(ps); db.SaveChanges(); } int resta = s1 - Cant; if (resta > 0) { var producto = (from s in ctx.PRODUCTOS_PV where s.Prod_Id == Producto select s).FirstOrDefault(); producto.Prod_Stock = resta; // producto.Ticket_Subtotal = Convert.ToInt32(lblTotal.Text); int num = ctx.SaveChanges(); } else { MessageBox.Show("No cuentas con stock suficiente"); } } }//si es solo }
private void btnCerrar_Click(object sender, EventArgs e) { if (MessageBox.Show("¿Deseas facturar esta venta?", "Alerta!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0, false) == DialogResult.Yes) { using (var ctx = new AppDTEntities()) { var ticket = (from s in ctx.TICKETS_PV where s.Ticket_Id == idTicket select s).FirstOrDefault(); ticket.Ticket_Status = "terminado"; ticket.Ticket_Subtotal = Convert.ToInt32(lblTotal.Text); int num = ctx.SaveChanges(); } IndexNew objmesas = new IndexNew(); objmesas.Show(); this.Close(); //datosFactura factura = new datosFactura(idTicket); //factura.Show(); //btnimprime_Click(sender, e); //MessageBox.Show("Facturando"); } else { using (var ctx = new AppDTEntities()) { var ticket = (from s in ctx.TICKETS_PV where s.Ticket_Id == idTicket select s).FirstOrDefault(); ticket.Ticket_Status = "terminado"; ticket.Ticket_Subtotal = Convert.ToInt32(lblTotal.Text); int num = ctx.SaveChanges(); } IndexNew objmesas = new IndexNew(); objmesas.Show(); // btnimprime_Click(sender, e); this.Close(); } }
private static PedidoSugerido GetStockSimple(int Producto, int Cant) { using (var db = new AppDTEntities()) { var stock = db.PRODUCTOS_PV.Where(a => a.Prod_Id == Producto).ToList(); var s1 = Convert.ToInt32(stock[0].Prod_Stock); if (s1 <= 2) { decimal st = Convert.ToDecimal(stock[0].Prod_Stock); string date = DateTime.Now.Date.ToString("yyyy-MM-dd"); var ps = new PEDIDO_SUGERIDO_PV { Prod_Id = Producto, Sucu_Id = "1", Prod_Stock = st, Prod_date = date, Pedi_Status = 0 }; db.PEDIDO_SUGERIDO_PV.Add(ps); db.SaveChanges(); } int resta = s1 - Cant; if (resta > 0) { var producto = (from s in db.PRODUCTOS_PV where s.Prod_Id == Producto select s).FirstOrDefault(); producto.Prod_Stock = resta; // producto.Ticket_Subtotal = Convert.ToInt32(lblTotal.Text); int num = db.SaveChanges(); } else { MessageBox.Show("No cuentas con stock suficiente"); } var result = new PedidoSugerido { add = resta }; return(result); } }
public HttpResponseMessage Index(int transid, int origenid, int destinoid, string code, string lat, string lon) { string message = ""; using (AppDTEntities db = new AppDTEntities()) { try { // var fecha = DateTime.Today.Date.ToString("yyyy-MM-dd HH:mm"); var entity = new GUIA_LOGISTIC { tras_id = transid, guia_origen = origenid, guia_destino = destinoid, guia_code = code, guia_date = DateTime.Now, guia_status = 0, guia_lat = lat, guia_lon = lon }; db.GUIA_LOGISTIC.Add(entity); db.SaveChanges(); message = "ok"; } catch (Exception e) { message = e.ToString(); } }; var resp = new HttpResponseMessage() { Content = new StringContent("[{\"Succes\":\"" + message + "\"}]") }; resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(resp); }
public HttpResponseMessage Index(int transid, string latend, string lonend) { string message = ""; var fecha = DateTime.Today.Date.ToString("yyyy-MM-dd"); using (AppDTEntities db = new AppDTEntities()) { try { // var id = db.GUIA_LOGISTIC.Where(q => q.tras_id == transid && q.guia_date==fecha && q.guia_status == 0).ToList(); var id = db.GUIA_LOGISTIC.Where(q => q.tras_id == transid && q.guia_status == 0).Max(q => q.guia_id); var stud = (from s in db.GUIA_LOGISTIC where s.guia_id == id select s).FirstOrDefault(); stud.guia_latend = latend; stud.guia_lonend = lonend; stud.guia_status = 1; int num = db.SaveChanges(); message = "ok"; } catch (Exception e) { message = e.ToString(); } }; var resp = new HttpResponseMessage() { Content = new StringContent("[{\"Succes\":\"" + message + "\"}]") }; resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(resp); }
// GET: GetCheckOut public ActionResult Index() { int inst_id = Convert.ToInt32(Request.QueryString["inst_id"]); int visitid = Convert.ToInt32(Request.QueryString["visit_id"]); int custid = Convert.ToInt32(Request.QueryString["cust_id"]); string lat = Convert.ToString(Request.QueryString["lat"]); string lon = Convert.ToString(Request.QueryString["lon"]); string hr = Convert.ToString(Request.QueryString["hr"]); string fcha = Convert.ToString(Request.QueryString["fcha"]); int emo = Convert.ToInt32(Request.QueryString["emo"]); var succes = ""; using (AppDTEntities db = new AppDTEntities()) { try { var result = from r in db.VISITA_REGISTRO where r.visi_id == visitid select r; VISITA_REGISTRO vISITA_REGISTRO = result.First(); vISITA_REGISTRO.reg_end = hr; vISITA_REGISTRO.reg_emo = emo; db.SaveChanges(); //status var result2 = from r in db.VISITA_ASSIGN where r.visi_id == visitid select r; VISITA_ASSIGN vISITA_ASSIGN = result2.First(); vISITA_ASSIGN.visi_status = 2; db.SaveChanges(); succes = "Ok"; } catch (Exception e) { succes = "NoOk"; } } return(Json(new { succes }, JsonRequestBehavior.AllowGet)); }
public ActionResult Index() { int inst_id = Convert.ToInt32(Request.QueryString["inst_id"]); int visitid = Convert.ToInt32(Request.QueryString["visit_id"]); int custid = Convert.ToInt32(Request.QueryString["cust_id"]); string lat = Convert.ToString(Request.QueryString["lat"]); string lon = Convert.ToString(Request.QueryString["lon"]); string hr = Convert.ToString(Request.QueryString["hr"]); string fcha = Convert.ToString(Request.QueryString["fcha"]); int emo = Convert.ToInt32(Request.QueryString["emo"]); var succes = ""; var buscar = db.VISITA_REGISTRO.Where(a => a.inst_id == inst_id && a.reg_status == 8).ToList(); if (buscar.Count() == 0) { using (AppDTEntities objDataContext = new AppDTEntities()) { try { VISITA_REGISTRO vISITA = new VISITA_REGISTRO(); // fields to be insert vISITA.inst_id = inst_id; vISITA.reg_lat = lat; vISITA.reg_lon = lon; vISITA.cust_id = custid; vISITA.reg_date = fcha; vISITA.reg_ini = hr; vISITA.reg_end = hr; vISITA.visi_id = 100; vISITA.reg_status = 8; vISITA.reg_emo = 0; objDataContext.VISITA_REGISTRO.Add(vISITA); objDataContext.SaveChanges(); succes = "Ok"; } catch (Exception e) { succes = "NoOk"; } } } else { if (buscar[0].reg_emo == 1) { using (AppDTEntities objDataContext = new AppDTEntities()) { try { VISITA_REGISTRO vISITA = new VISITA_REGISTRO(); // fields to be insert vISITA.inst_id = inst_id; vISITA.reg_lat = lat; vISITA.reg_lon = lon; vISITA.cust_id = custid; vISITA.reg_date = fcha; vISITA.reg_ini = hr; vISITA.reg_end = hr; vISITA.visi_id = 100; vISITA.reg_status = 8; vISITA.reg_emo = 0; objDataContext.VISITA_REGISTRO.Add(vISITA); objDataContext.SaveChanges(); succes = "Ok"; } catch (Exception e) { succes = "NoOk"; } } } else { if (buscar[0].inst_id != 0) { int id = buscar[0].inst_id; var result2 = from r in db.VISITA_REGISTRO where r.inst_id == id && r.reg_status == 8 select r; VISITA_REGISTRO vISITA_ASSIGN = result2.First(); vISITA_ASSIGN.reg_end = hr; vISITA_ASSIGN.reg_emo = 1; db.SaveChanges(); succes = "Ok"; } else { using (AppDTEntities objDataContext = new AppDTEntities()) { try { VISITA_REGISTRO vISITA = new VISITA_REGISTRO(); // fields to be insert vISITA.inst_id = inst_id; vISITA.reg_lat = lat; vISITA.reg_lon = lon; vISITA.cust_id = custid; vISITA.reg_date = fcha; vISITA.reg_ini = hr; vISITA.reg_end = hr; vISITA.visi_id = 100; vISITA.reg_status = 8; vISITA.reg_emo = 0; objDataContext.VISITA_REGISTRO.Add(vISITA); objDataContext.SaveChanges(); succes = "Ok"; } catch (Exception e) { succes = "NoOk"; } } } } } return(Json(new { succes }, JsonRequestBehavior.AllowGet)); }