public int AgregarCliente(int IdEmpresa, int IdCliente, string Nombre, string Apellido, string Telefono, string RUC) { var cl = db.tel_Clientes.Where(p => p.IdClienteWeb1 == IdCliente && p.IdEmpresa == IdEmpresa).FirstOrDefault(); if (cl == null) { cl = new tel_Clientes(); cl.IdEmpresa = IdEmpresa; cl.Nombre = Nombre; cl.Apellido = Apellido; cl.Telefonoweb = Telefono; cl.Diplomatico = false; try { cl.Telefono = Convert.ToInt64(Telefono); } catch (Exception) { // throw; cl.Telefono = 1; } cl.RUC = RUC; cl.IdClienteWeb1 = IdCliente; db.tel_Clientes.Add(cl); } else { cl.Nombre = Nombre; cl.Apellido = Apellido; cl.Telefonoweb = Telefono; cl.RUC = RUC; if (!cl.Diplomatico.HasValue) { cl.Diplomatico = false; } try { cl.Telefono = Convert.ToInt64(Telefono); } catch (Exception) { // throw; cl.Telefono = 1; } } db.SaveChanges(); return(cl.IdCliente); }
public CarritoBLL(int IdCliente, int IdDireccion, String UserName, String IdTipo, SinapsisEntities db) { // DAL.SinapsisEntities db = new DAL.SinapsisEntities(); this.db = db; DAL.tel_Carrito car = new DAL.tel_Carrito(); DAL.tel_Clientes cl = db.tel_Clientes.Find(IdCliente); DAL.Tel_Direcciones dir = db.Tel_Direcciones.Find(IdDireccion); //Asignamos los valores car.IdCliente = cl.IdCliente; car.IdEmpresa = cl.IdEmpresa; car.IdTipoPedido = IdTipo; car.Empresa = cl.Empresa; car.IdFormaPago = 1; car.TransferTemporal = false; car.Audit_Fecha = DateTime.Now; car.UserName = UserName; car.Fecha = DateTime.Today; car.Nombre = cl.Nombre; car.Apellido = cl.Apellido; car.Telefono = cl.Telefono; car.obs = cl.obs; car.IdDireccion = dir.Id; car.Direccion = ArmarDireccion(dir); car.cuadrante = dir.cuadrante; car.referencia = dir.referencia; car.IdSucursal = dir.IdSucursal; db.tel_Carrito.Add(car); db.SaveChanges(); this.cr = car; }
protected void btnAsignar_Click(object sender, EventArgs e) { try { this.lblError.Text = ""; this.lblMensaje.Text = ""; using (var db1 = new DAL.SinapsisEntities()) { //int IdSucursal; //IdSucursal = Convert.ToInt32(dboSucursal.SelectedValue); var numberFormatInfo = new NumberFormatInfo(); numberFormatInfo.NumberDecimalSeparator = "."; var query = db1.Tel_Direcciones.Find(this.fvCliente.SelectedValue); //query = query.Where(c => c.IdEmpresa == this.IdEmpresa && c.IdSucursal == 1); query.GeoLat = Decimal.Parse(this.txtLat.Text, numberFormatInfo); query.GeoLng = Decimal.Parse(this.txtLng.Text, numberFormatInfo); // db.tel_Clientes.Attach(query); // query.Direccion1 = "c/Haedo"; db1.SaveChanges(); //this.RecuperarCliente(); this.txtLat.Text = ""; this.txtLng.Text = ""; this.lblMensaje.Text = "Registro actualizado correctamente."; } } catch (Exception ex) { this.lblError.Text = ex.Message; } }