private void btnModificarColor_Click(object sender, EventArgs e) { try { if (lbColor.Items.Count > 0) { clsColor objColor = new clsColor(); objColor.id_color = int.Parse(lbColor.SelectedValue.ToString()); objColor.nombre_color = txtNombreColor.Text; if (objNegocioColor.actualizarColor(objColor)) { MessageBox.Show("Color actualizar con exito"); } else { MessageBox.Show("Error al actualizar la color"); } dsColor = objNegocioColor.consultarColor(""); cargarColor(dsColor); } else { MessageBox.Show("No existen colores para modificar"); } } catch (Exception) { MessageBox.Show("Error al modificar el color"); } }
private void btnAgregarColor_Click(object sender, EventArgs e) { try { if (txtNombreColor.Text != "") { clsColor objColor = new clsColor(); objColor.nombre_color = txtNombreColor.Text; if (objNegocioColor.insertarColor(objColor)) { MessageBox.Show("Color actualizar con exito"); } else { MessageBox.Show("Error al actualizar la color"); } dsColor = objNegocioColor.consultarColor(""); cargarColor(dsColor); } else { MessageBox.Show("No se puede agregar colores vacios"); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }
private void gridView1_DoubleClick(object sender, EventArgs e) { clsColor Color = (clsColor)gridView1.GetFocusedRow(); Event_frmConsultaColor_FormClosing(Color, e); // Close();| }
public Boolean guardar(clsColor ctm, ref string Mensaje) { try { using (INVENTARIOEntities te = new INVENTARIOEntities()) { Color tm = new Color(); tm.IdEmpresa = Convert.ToInt32(ctm.empresa); tm.IdColor = Convert.ToInt32(ctm.codigo); tm.Descripcion = Convert.ToString(ctm.descripcion); tm.IdEstado = Convert.ToInt32(ctm.estado); te.AddToColor(tm); te.SaveChanges(); } return(true); } catch (Exception e) { Mensaje = "ERROR" + e.InnerException + e.Message; //System.Windows.Forms.MessageBox.Show("error al guardar" + e); return(false); } }
private void color() { DataSet ds = new DataSet(); clsColor objColor = new clsColor(); objColor.Action = "SELECT"; ds = objColor.fnColor(); }
void consulta_Event_frmConsultaColor_FormClosing(object sender, EventArgs e) { clsColor color = (clsColor)sender; txt_CodigoColor.Text = color.codigo.ToString(); txt_DescripcionColor.Text = color.descripcion; cbx_EstadoColor.Text = color.estado; consulta.Visible = false; }
private void btn_ConsultaColor_Click_2(object sender, EventArgs e) { consulta = new frmConsultaColor(); consulta.ShowDialog(); cColor = consulta.clastm; txt_CodigoColor.Text = cColor.codigo.ToString(); txt_DescripcionColor.Text = cColor.descripcion; cbx_EstadoColor.EditValue = Convert.ToString(cColor.estado); }
public void eliminar(clsColor ctm) { using (INVENTARIOEntities te = new INVENTARIOEntities()) { var t = (from q in te.Color where q.IdColor == ctm.codigo select q).First(); te.DeleteObject(t); te.SaveChanges(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataSet ds = new DataSet(); clsColor objColor = new clsColor(); objColor.Action = "SELECT"; ds = objColor.fnColor(); string htm = string.Empty; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { htm += "<div class='col-md-1'><p style='background-color:" + ds.Tables[0].Rows[i]["ColorHex"].ToString() + " !important; height:15px;'><p></div>"; } divColorChart.InnerHtml = htm; } }
public Boolean modificar(clsColor ctm) { using (INVENTARIOEntities te = new INVENTARIOEntities()) { EntityKey ekey = new EntityKey("INVENTARIOEntities.Color", "IdColor", ctm.codigo); object OBJ = null; if (te.TryGetObjectByKey(ekey, out OBJ)) { Color Color = (Color)OBJ; Color.Descripcion = ctm.descripcion; Color.IdEstado = Convert.ToInt32(ctm.estado); } te.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave); } return(true); }
public List <clsColor> consulta() { try { List <clsColor> lista = new List <clsColor>(); INVENTARIOEntities ent = new INVENTARIOEntities(); var con = from w in ent.Color select w; foreach (var item in con) { clsColor clas = new clsColor(); clas.empresa = Convert.ToInt32(item.IdEmpresa); clas.codigo = Convert.ToInt32(item.IdColor); clas.descripcion = item.Descripcion; clas.estado = Convert.ToString(item.IdEstado); lista.Add(clas); } return(lista); } catch (Exception) { return(null); } }
public List <clsColor> consultaColor() { try { List <clsColor> listaColor = new List <clsColor>(); INVENTARIOEntities ta = new INVENTARIOEntities(); var con = from w in ta.Color select w; foreach (var item in con) { clsColor clsColorArt = new clsColor(); clsColorArt.empresa = Convert.ToInt32(item.IdEmpresa); clsColorArt.codigo = item.IdColor; clsColorArt.descripcion = item.Descripcion; clsColorArt.estado = Convert.ToString(item.IdEstado); listaColor.Add(clsColorArt); } return(listaColor); } catch (Exception e) { Console.WriteLine("ERROR " + e); return(null); } }
public bool actualizarColor(clsColor objColor) { return(objDatosColor.modificarColor(objColor.id_color, objColor.nombre_color)); }
public bool insertarColor(clsColor objColor) { return(objDatosColor.insertarColor(objColor.nombre_color)); }