public ActionResult Create([Bind(Include = "nombre")] string nombre, [Bind(Include = "direccion")] string direccion, [Bind(Include = "email")] string email, [Bind(Include = "tel1")] string tel1, [Bind(Include = "tel2")] string tel2) { if (ModelState.IsValid) { proveedores proveedor = new proveedores(); proveedor_telefonos telefono1 = new proveedor_telefonos(); proveedor_telefonos telefono2 = new proveedor_telefonos(); proveedor.id_proveedor = (nombre).Substring(0, 2) + DateTime.UtcNow.ToString().Replace("/", "").Replace(" ", "").Replace(":", ""); proveedor.nombre = nombre; proveedor.direccion = direccion; proveedor.email = email; telefono1.fk_proveedor = proveedor.id_proveedor; telefono1.telefono = tel1; telefono2.fk_proveedor = proveedor.id_proveedor; telefono2.telefono = tel2; db.proveedores.Add(proveedor); db.proveedor_telefonos.Add(telefono1); db.proveedor_telefonos.Add(telefono2); db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }
public ActionResult Index() { /* * enlaceTipoID tipo * 1 Nacional * 2 Local * 3 Servicio * 4 Internet */ var oficinas = new oficinas(); var proveedores = new proveedores(); var enlacesTipo = new enlacesTipo(); var enlacesTecnologia = new enlacesTecnologia(); ViewBag.oficinas = oficinas.Listar(); ViewBag.proveedores = proveedores.Listar(); ViewBag.enlacesTipo = enlacesTipo.Listar(); ViewBag.enlacesTecnologia = enlacesTecnologia.Listar(); ViewBag.nacional = enlaces.Listar(1); ViewBag.local = enlaces.Listar(2); ViewBag.servicios = enlaces.Listar(3); ViewBag.internet = enlaces.Listar(4); return(View(enlaces)); }
public int add(proveedores proveedor) { int a = 0; conn = new conexion(); SqlTransaction tran; SqlCommand command = conn.getConn().CreateCommand(); tran = conn.getConn().BeginTransaction("simpleTransicion"); try { command.Connection = conn.getConn(); command.Transaction = tran; command.CommandText = "INSERT INTO proveedores(NomEmpresa,TelefonoEmpresa,CorreoEmpresa) VALUES(@NomEmpresa,@TelefonoEmpresa,@CorreoEmpresa)"; command.Parameters.Add("@NomEmpresa", SqlDbType.VarChar); command.Parameters.Add("@TelefonoEmpresa", SqlDbType.VarChar); command.Parameters.Add("@CorreoEmpresa", SqlDbType.VarChar); command.Parameters["@NomEmpresa"].Value = proveedor.NomEmpresa1; command.Parameters["@TelefonoEmpresa"].Value = proveedor.TelefonoEmpresa1; command.Parameters["@CorreoEmpresa"].Value = proveedor.CorreoEmpresa1; command.ExecuteNonQuery(); tran.Commit(); a = 1; } catch (Exception e) { tran.Rollback(); } finally { conn.cerrar(); } return(a); }
//Cargar Datos public List <proveedores> ListarProveedores() { try { SqlConnection cnx = cn.conectar(); //conexion cm = new SqlCommand("nuevoProveedor", cnx); cm.Parameters.AddWithValue("@b", 2); cm.Parameters.AddWithValue("@idcodigoP", ""); cm.Parameters.AddWithValue("@nombre", ""); cm.Parameters.AddWithValue("@direccion", ""); cm.Parameters.AddWithValue("@telefono", ""); cm.CommandType = CommandType.StoredProcedure; cnx.Open(); dr = cm.ExecuteReader(); listaProv = new List <proveedores>(); while (dr.Read()) { proveedores p = new proveedores(); p.idcodigoP = Convert.ToInt32(dr["idcodigoP"].ToString()); p.nombre = dr["nombre"].ToString(); p.direccion = dr["direccion"].ToString(); p.telefono = dr["telefono"].ToString(); listaProv.Add(p); } } catch (Exception e) { e.Message.ToString(); listaProv = null; } finally { cm.Connection.Close(); } return(listaProv); }
private void BTN_PROVEEDORES_Click(object sender, EventArgs e) { proveedores miProveedor = new proveedores(); miProveedor.ShowDialog(); miProveedor.Dispose(); }
public int remove(proveedores proveedor) { int a = 0; String query = "DELETE FROM proveedores WHERE id_proveedor = @id_proveedor"; conn = new conexion(); SqlCommand command = conn.getConn().CreateCommand(); SqlTransaction trans = conn.getConn().BeginTransaction("simpleTrans"); try { command.Connection = conn.getConn(); command.CommandText = query; command.Transaction = trans; command.Parameters.Add("@id_proveedor", SqlDbType.Int); command.Parameters["@id_proveedor"].Value = proveedor.Id_proveedor; command.ExecuteNonQuery(); trans.Commit(); a = 1; } catch (Exception e) { trans.Rollback(); } finally { conn.cerrar(); } return(a); }
// devuleve un registro en particular public static proveedores GellIdproveedores(string c, int i) { proveedores list = null; using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["default"].ToString())) { conn.Open(); MySqlCommand cmd; if (i == 1) { cmd = new MySqlCommand("SELECT * FROM proveedores WHERE cod = @cod", conn); } else { cmd = new MySqlCommand("SELECT * FROM proveedores WHERE nom = @cod", conn); } cmd.Parameters.AddWithValue("cod", c); MySqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows == true) { while (reader.Read()) { list = Loadproveedores(reader); } } } return(list); }
public ActionResult Edit(proveedores model) { try { proveedores proveedor = db.proveedores.Where(x => x.id == model.id).FirstOrDefault(); proveedor.NombreComercial = model.NombreComercial; proveedor.RFC = model.RFC; proveedor.RazonSocial = model.RazonSocial; proveedor.ActividadEmpresarial = model.ActividadEmpresarial; proveedor.RepresentanteLegal = model.RepresentanteLegal; proveedor.MonedaFacturacion_Id = model.MonedaFacturacion_Id; proveedor.CategoriaProveedor_Id = model.CategoriaProveedor_Id; proveedor.Credito_Id = model.Credito_Id; proveedor.StatusProveedor_Id = model.StatusProveedor_Id; proveedor.direccionproveedor = model.direccionproveedor; proveedor.informacionbancaria = model.informacionbancaria; db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception _ex) { ViewBag.MonedaFacturacion_Id = new SelectList(db.monedafacturacion, "id", "descripcion", model.MonedaFacturacion_Id); ViewBag.CategoriaProveedor_Id = new SelectList(db.categoriaproveedor, "id", "descripcion", model.CategoriaProveedor_Id); ViewBag.StatusProveedor_Id = new SelectList(db.statusproveedor, "id", "descripcion", model.StatusProveedor_Id); ViewBag.Credito_Id = new SelectList(db.credito, "id", "descripcion", model.Credito_Id); ViewBag.Error = "Error"; return(View(model)); } }
private void btGuardar_Click(object sender, EventArgs e) { logicaNegocioProveedors lN = new logicaNegocioProveedors(); try { proveedores objProveedor = new proveedores(); objProveedor.nombre = txtNombre.Text; objProveedor.direccion = txtDireccion.Text; objProveedor.telefono = txtTelefono.Text; if (lN.insertarProveedor(objProveedor) > 0) { MessageBox.Show("Agregado con éxito!"); txtDireccion.Text = ""; txtNombre.Text = ""; txtTelefono.Text = ""; } else { MessageBox.Show("Error al agregar proveedor"); } } catch { MessageBox.Show("Errorrrrrrr"); } }
// PUT api/Proveedores/5 public IHttpActionResult Putproveedores(int id, proveedores proveedores) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != proveedores.id_proveedor) { return(BadRequest()); } db.Entry(proveedores).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!proveedoresExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public proveedores BuscarProveedorXcodigo(int idpro) { proveedores p = new proveedores(); try { SqlConnection cnx = cn.conectar(); cm = new SqlCommand("nuevoProveedor", cnx); cm.Parameters.AddWithValue("@b", 5); cm.Parameters.AddWithValue("@idcodigoP", idpro); cm.Parameters.AddWithValue("@nombre", ""); cm.Parameters.AddWithValue("@direccion", ""); cm.Parameters.AddWithValue("@telefono", ""); cm.CommandType = CommandType.StoredProcedure; cnx.Open(); dr = cm.ExecuteReader(); dr.Read(); p.idcodigoP = Convert.ToInt32(dr["idcodigoP"].ToString()); p.nombre = dr["nombre"].ToString(); p.direccion = dr["direccion"].ToString(); p.telefono = dr["telefono"].ToString(); } catch (Exception e) { e.Message.ToString(); p = null; } finally { cm.Connection.Close(); } return(p); }
private void dataGridView5_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex >= 0) { DataGridViewRow row = dataGridView5.CurrentRow as DataGridViewRow; if (this.dataGridView5.Columns[e.ColumnIndex].Name == "dataGridViewButtonColumn1") { int a = Convert.ToInt32(MessageBox.Show("Está seguro que desea ANULAR el registro", Application.ProductName.ToString(), MessageBoxButtons.YesNo, MessageBoxIcon.Information)); if (a == 6) { proveedores c = new proveedores(); c.cod = row.Cells[1].Value.ToString(); op_sql.parametro("update entradasmat set anul=1 where nrec=@nrec", "nrec", c.cod); op_sql.parametro1("insert into logaccesos values (null, now(),concat('" + op_var.usu + "',' anuló el recibo entrada ','" + c.cod + "'));"); toolStripButton3_Click(toolStripButton3, e); } } } } catch (MySqlException ex) { if (ex.Number == 1451) { MessageBox.Show("El dato está siendo utilizado, por lo tanto es imposible de eliminar", Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show(ex.Message, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
// GET: proveedores/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } proveedores proveedores = db.proveedores.Find(id); IQueryable <proveedor_telefonos> telefonos = db.proveedor_telefonos.Where(proveedor_telefonos => proveedor_telefonos.fk_proveedor == id); ProveedorMulti proveedor = new ProveedorMulti(); proveedor_telefonos telefono1 = new proveedor_telefonos(); proveedor_telefonos telefono2 = new proveedor_telefonos(); int contador = 1; foreach (var telefono in telefonos) { if (contador == 1) { telefono1 = telefono; } else { telefono2 = telefono; } contador++; } proveedor.proveedores = proveedores; proveedor.telefono1 = telefono1; proveedor.telefono2 = telefono2; if (proveedores == null) { return(HttpNotFound()); } return(View(proveedor)); }
public int insertarProveedores(proveedores pv) { try { SqlConnection cnx = cn.conectar(); //conexion cm = new SqlCommand("nuevoProveedor", cnx); cm.Parameters.AddWithValue("@b", 1); cm.Parameters.AddWithValue("@idcodigoP", ""); cm.Parameters.AddWithValue("@nombre", pv.nombre); cm.Parameters.AddWithValue("@direccion", pv.direccion); cm.Parameters.AddWithValue("@telefono", pv.telefono); cm.CommandType = CommandType.StoredProcedure; cnx.Open(); cm.ExecuteNonQuery(); indicador = 1; } catch (Exception e) { e.Message.ToString(); indicador = 0; } finally { cm.Connection.Close(); } return(indicador); }
private void dataGridView5_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex >= 0) { DataGridViewRow row = dataGridView5.CurrentRow as DataGridViewRow; if (this.dataGridView5.Columns[e.ColumnIndex].Name == "Column2") { int a = Convert.ToInt32(MessageBox.Show("Está seguro que desea RESTAURAR el registro", Application.ProductName.ToString(), MessageBoxButtons.YesNo, MessageBoxIcon.Information)); if (a == 6) { proveedores c = new proveedores(); c.cod = row.Cells[1].Value.ToString(); op_sql.parametro("update salidasmat set anul=0 where nrec=@nrec", "nrec", c.cod); op_sql.parametro1("insert into logaccesos values (null, now(),concat('" + op_var.usu + "',' restauró el recibo SALIDA DE MATERIAL ','" + c.cod + "'));"); dataGridView5.AutoGenerateColumns = false; dataGridView5.DataSource = op_salidasmat.GellAllsalidasmatver(_a, _b, null, null, 4); } } } } catch (MySqlException ex) { if (ex.Number == 1451) { MessageBox.Show("El dato está siendo utilizado, por lo tanto es imposible de eliminar", Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show(ex.Message, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public ActionResult Crear(ProveedorViewModel model) { int idComercio = (int)Session["comercio"]; if (!ModelState.IsValid) { return(View(model)); } using (practicaprofesionalEntities db = new practicaprofesionalEntities()) { proveedores oProveedor = new proveedores(); oProveedor.razon_social = model.razon_social; oProveedor.estado = "1"; oProveedor.email = model.email; oProveedor.telefono = Convert.ToString(model.telefono); db.proveedores.Add(oProveedor); db.SaveChanges(); int newIdentityValue = oProveedor.id_proveedor; //insert en tabla proveedores_comercios proveedores_comercios p_comercio = new proveedores_comercios(); p_comercio.id_comercio = idComercio; p_comercio.id_proveedor = newIdentityValue; db.proveedores_comercios.Add(p_comercio); db.SaveChanges(); } return(Redirect(Url.Content("~/Proveedores"))); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex >= 0) { DataGridViewRow row = dataGridView5.CurrentRow as DataGridViewRow; if (this.dataGridView5.Columns[e.ColumnIndex].Name == "eli") { int a = Convert.ToInt32(MessageBox.Show("Está seguro que desea ANULAR el registro", Application.ProductName.ToString(), MessageBoxButtons.YesNo, MessageBoxIcon.Information)); if (a == 6) { proveedores c = new proveedores(); c.cod = row.Cells[1].Value.ToString(); op_sql.parametro("update salidasmat set anul=1 where nrec=@nrec", "nrec", c.cod); dataGridView5.AutoGenerateColumns = false; dataGridView5.DataSource = op_salidasmat.GellAllsalidasmat(); this.toolStripStatusLabel4.Text = dataGridView5.RowCount.ToString(); } } } } catch (MySqlException ex) { if (ex.Number == 1451) { MessageBox.Show("El dato está siendo utilizado, por lo tanto es imposible de eliminar", Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show(ex.Message, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public ActionResult Create([Bind(Include = "ProveedoresID" + "," + "Nombre_empresa" + "," + "Direccion" + "," + "Telefono" + "," + "Celular_contacto" + "," + "Nombre_contacto" )] proveedores proveedores) { if (ModelState.IsValid) { bool bSucess = false; bSucess = proveedoresData.Add(proveedores); if (bSucess == true) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Can Not Insert"); } } return(View(proveedores)); }
public static bool Update(proveedores oldproveedores, proveedores newproveedores) { SqlConnection connection = empresaData.GetConnection(); string updateStatement = "UPDATE " + " [proveedores] " + "SET " + " [ProveedoresID] = @NewProveedoresID " + " ,[Nombre_empresa] = @NewNombre_empresa " + " ,[Direccion] = @NewDireccion " + " ,[Telefono] = @NewTelefono " + " ,[Celular_contacto] = @NewCelular_contacto " + " ,[Nombre_contacto] = @NewNombre_contacto " + "WHERE " + " [ProveedoresID] = @OldProveedoresID " + " AND [Nombre_empresa] = @OldNombre_empresa " + " AND [Direccion] = @OldDireccion " + " AND [Telefono] = @OldTelefono " + " AND [Celular_contacto] = @OldCelular_contacto " + " AND [Nombre_contacto] = @OldNombre_contacto " + ""; SqlCommand updateCommand = new SqlCommand(updateStatement, connection); updateCommand.CommandType = CommandType.Text; updateCommand.Parameters.AddWithValue("@NewProveedoresID", newproveedores.ProveedoresID); updateCommand.Parameters.AddWithValue("@NewNombre_empresa", newproveedores.Nombre_empresa); updateCommand.Parameters.AddWithValue("@NewDireccion", newproveedores.Direccion); updateCommand.Parameters.AddWithValue("@NewTelefono", newproveedores.Telefono); updateCommand.Parameters.AddWithValue("@NewCelular_contacto", newproveedores.Celular_contacto); updateCommand.Parameters.AddWithValue("@NewNombre_contacto", newproveedores.Nombre_contacto); updateCommand.Parameters.AddWithValue("@OldProveedoresID", oldproveedores.ProveedoresID); updateCommand.Parameters.AddWithValue("@OldNombre_empresa", oldproveedores.Nombre_empresa); updateCommand.Parameters.AddWithValue("@OldDireccion", oldproveedores.Direccion); updateCommand.Parameters.AddWithValue("@OldTelefono", oldproveedores.Telefono); updateCommand.Parameters.AddWithValue("@OldCelular_contacto", oldproveedores.Celular_contacto); updateCommand.Parameters.AddWithValue("@OldNombre_contacto", oldproveedores.Nombre_contacto); try { connection.Open(); int count = updateCommand.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException) { return(false); } finally { connection.Close(); } }
public ActionResult DeleteConfirmed(int id) { proveedores proveedores = db.proveedores.Find(id); db.proveedores.Remove(proveedores); db.SaveChanges(); return(RedirectToAction("Index")); }
private void button1_Click(object sender, EventArgs e) { try { if (button1.Text == "Guardar") //Para agregar un nuevo registro { proveedores objProveedor = new proveedores(); //Entidades ---proveedores objProveedor.nombre = txtnombre.Text; objProveedor.direccion = txtdireccion.Text; objProveedor.telefono = txttelefono.Text; if (lN.insertarProveedores(objProveedor) > 0) { MessageBox.Show("Agregado con éxito!"); dgvProveedores.DataSource = lN.ListarProveedores(); //Cargar DataGridView para mostrar nuevo registro txtdireccion.Text = ""; txtnombre.Text = ""; txttelefono.Text = ""; tabProveedor.SelectedTab = tabPage2; //Pasar a la tab2 } else { MessageBox.Show("Error al agregar proveedor"); } } if (button1.Text == "Actualizar") //Para actualizar un registro existente { proveedores objProveedor = new proveedores(); //Entidades ---proveedores objProveedor.idcodigoP = Convert.ToInt32(txtcodigo.Text); objProveedor.nombre = txtnombre.Text; objProveedor.direccion = txtdireccion.Text; objProveedor.telefono = txttelefono.Text; if (lN.EditarProveedor(objProveedor) > 0) { MessageBox.Show("Actualizado con éxito!"); dgvProveedores.DataSource = lN.ListarProveedores(); //Actualizando datos txtdireccion.Text = ""; txtnombre.Text = ""; txttelefono.Text = ""; txtcodigo.Text = ""; tabProveedor.SelectedTab = tabPage2; // Pasar al Tab2 para mostrar datos } else { MessageBox.Show("Error al actualizar proveedor"); } button1.Text = "Guardar"; } } catch { MessageBox.Show("Errorrrrr"); } }
private void btGuardar_Click_1(object sender, EventArgs e) { logicaNegocioProveedors lN = new logicaNegocioProveedors(); proveedores objProveedor = new proveedores(); try { if (btGuardar.Text == "Guardar") { objProveedor.nombre = txtNombre.Text; objProveedor.direccion = txtDireccion.Text; objProveedor.telefono = txtTelefono.Text; if (lN.insertarProveedor(objProveedor) > 0) { MessageBox.Show("Agregado con exito!"); dataGridView1.DataSource = lN.ListarProveedores(); txtDireccion.Text = ""; txtNombre.Text = ""; txtTelefono.Text = ""; tabControl1.SelectedTab = tabPage2; } else { MessageBox.Show("Error al agregar proveedor"); } } if (btGuardar.Text == "Actualizar") { objProveedor.idcodigoP = Convert.ToInt32(txtid.Text); objProveedor.nombre = txtNombre.Text; objProveedor.direccion = txtDireccion.Text; objProveedor.telefono = txtTelefono.Text; } if (lN.EditarProveedores(objProveedor) > 0) { MessageBox.Show("Actualizado con exito"); dataGridView1.DataSource = lN.ListarProveedores(); txtDireccion.Text = ""; txtNombre.Text = ""; txtTelefono.Text = ""; tabControl1.SelectedTab = tabPage2; } else { MessageBox.Show("Error al actualizar proveedor"); } btGuardar.Text = "Guardar"; } catch { MessageBox.Show("Errorrrrrr!"); } }
public ActionResult Edit([Bind(Include = "id_proveedor,nit_proveedor,nom_proveedor,dir_proveedor,contacto_proveedor")] proveedores proveedores) { if (ModelState.IsValid) { db.Entry(proveedores).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(proveedores)); }
public ActionResult Edit([Bind(Include = "id,nombre_comercial,RNC,fecha_registro,estado")] proveedores proveedores) { if (ModelState.IsValid) { db.Entry(proveedores).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(proveedores)); }
public ActionResult Edit([Bind(Include = "id,nombre,direccion,pais,ciudad,telefon,email,URL")] proveedores proveedores) { if (ModelState.IsValid) { db.Entry(proveedores).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(proveedores)); }
public ActionResult Edit([Bind(Include = "supplierId,supplierCode,supplierName,Email,Phone,Address")] proveedores proveedores) { if (ModelState.IsValid) { db.Entry(proveedores).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(proveedores)); }
public ActionResult Edit([Bind(Include = "IdProveedores,Nombre,TipoProveedor")] proveedores proveedores) { if (ModelState.IsValid) { db.Entry(proveedores).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(proveedores)); }
public int deleteProveedores(int id_proveedor) { proveedores proveedor = new proveedores(); proveedor.Id_proveedor = id_proveedor; ProveedoresService dao = new ProveedoresServiceImpl(); return((int)dao.remove(proveedor)); }
public static bool Add(proveedores proveedores) { SqlConnection connection = empresaData.GetConnection(); string insertStatement = "INSERT " + " [proveedores] " + " ( " + " [ProveedoresID] " + " ,[Nombre_empresa] " + " ,[Direccion] " + " ,[Telefono] " + " ,[Celular_contacto] " + " ,[Nombre_contacto] " + " ) " + "VALUES " + " ( " + " @ProveedoresID " + " ,@Nombre_empresa " + " ,@Direccion " + " ,@Telefono " + " ,@Celular_contacto " + " ,@Nombre_contacto " + " ) " + ""; SqlCommand insertCommand = new SqlCommand(insertStatement, connection); insertCommand.CommandType = CommandType.Text; insertCommand.Parameters.AddWithValue("@ProveedoresID", proveedores.ProveedoresID); insertCommand.Parameters.AddWithValue("@Nombre_empresa", proveedores.Nombre_empresa); insertCommand.Parameters.AddWithValue("@Direccion", proveedores.Direccion); insertCommand.Parameters.AddWithValue("@Telefono", proveedores.Telefono); insertCommand.Parameters.AddWithValue("@Celular_contacto", proveedores.Celular_contacto); insertCommand.Parameters.AddWithValue("@Nombre_contacto", proveedores.Nombre_contacto); try { connection.Open(); int count = insertCommand.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException) { return(false); } finally { connection.Close(); } }
private void btnGuardar_Click(object sender, EventArgs e) { if (!validar()) { } else { if (!(dataGridView1.SelectedRows.Count == 0)) { int idmed = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString()); int cantidad = int.Parse(txtCantidadIngresada.Text); Model model = new Model(); Medicamentos med = new Medicamentos(); InventarioMedicamentos im = new InventarioMedicamentos(); InventarioMedicamentos old = new InventarioMedicamentos(); old = model.Entidades.InventarioMedicamentos.Find(idmed); if (idmed != old.idmedicamento) { im.fechaCaducidad = dtFecha.Value.Date; im.CodLote = txtLote.Text; im.idmedicamento = idmed; string idprovee = cmbFabricante.SelectedItem.ToString(); proveedores p = model.Entidades.proveedores.Single(a => a.Nombre.Equals(idprovee)); im.idproveedor = p.idproveedor; if ((controladorinventario.insertarAinventario(im))) { MessageBox.Show("ok"); } else { MessageBox.Show("ERROR"); } } else // ACTUALIZA EL INVENTARIO DE MEDICAMENTOS { MessageBox.Show("ERROR COMPADRE"); } }//fin seleccion else { MessageBox.Show("POR FAVOR, SELECCIONE UNA OPCION"); } } /* * */ }