public List <E_Etiqueta_Productor_Packing> ListaEtiquetas() { string query = "select * from tbl_prpk_etiqueta;"; MySqlCommand cmd; List <E_Etiqueta_Productor_Packing> temp = new List <E_Etiqueta_Productor_Packing>(); try { if (Conectar()) { cmd = new MySqlCommand(query, MySQLConexion); MySqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { E_Etiqueta_Productor_Packing etiqueta = new E_Etiqueta_Productor_Packing(); etiqueta.ID = Convert.ToString(reader["id"]); etiqueta.Nombre_etiqueta = Convert.ToString(reader["nombre_etiqueta"]); etiqueta.CSG = Convert.ToString(reader["csg"]); etiqueta.Region_CSG = Convert.ToString(reader["Region_CSG"]); etiqueta.Province_CSG = Convert.ToString(reader["Province_CSG"]); etiqueta.Province_CSG = Convert.ToString(reader["Province_CSG"]); etiqueta.CSP = Convert.ToString(reader["csp"]); etiqueta.Region_CSP = Convert.ToString(reader["Region_CSP"]); etiqueta.Province_CSP = Convert.ToString(reader["Province_CSP"]); etiqueta.Township_CSP = Convert.ToString(reader["Township_CSP"]); etiqueta.Producto = Convert.ToString(reader["Producto"]); etiqueta.Embalaje = Convert.ToString(reader["Embalaje"]); etiqueta.OnlyExport = Convert.ToString(reader["OnlyExport"]); etiqueta.Exported_by = Convert.ToString(reader["exportedby"]); temp.Add(etiqueta); } Desconectar(); return(temp); } else { _mensaje = "No se encontraron resultados"; Desconectar(); return(null); } } else { _mensaje = "Error en la conexion a la base de datos"; return(null); } } catch (Exception ex) { _mensaje = ex.Message; Desconectar(); return(null); } }
public E_Etiqueta_Productor_Packing ObtenerEtiqueta(string id) { string query = "select * from tbl_prpk_etiqueta where id = @id;"; MySqlCommand cmd; E_Etiqueta_Productor_Packing etiqueta = new E_Etiqueta_Productor_Packing();; try { if (Conectar()) { cmd = new MySqlCommand(query, MySQLConexion); cmd.Parameters.AddWithValue("@id", id); MySqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { etiqueta.ID = Convert.ToString(reader["id"]); etiqueta.Nombre_etiqueta = Convert.ToString(reader["nombre_etiqueta"]); etiqueta.CSG = Convert.ToString(reader["csg"]); etiqueta.Region_CSG = Convert.ToString(reader["Region_CSG"]); etiqueta.Province_CSG = Convert.ToString(reader["Province_CSG"]); etiqueta.Province_CSG = Convert.ToString(reader["Province_CSG"]); etiqueta.CSP = Convert.ToString(reader["csp"]); etiqueta.Region_CSP = Convert.ToString(reader["Region_CSP"]); etiqueta.Province_CSP = Convert.ToString(reader["Province_CSP"]); etiqueta.Township_CSP = Convert.ToString(reader["Township_CSP"]); etiqueta.Producto = Convert.ToString(reader["Producto"]); etiqueta.Embalaje = Convert.ToString(reader["Embalaje"]); etiqueta.OnlyExport = Convert.ToString(reader["OnlyExport"]); etiqueta.Exported_by = Convert.ToString(reader["exportedby"]); } Desconectar(); return(etiqueta); } else { _mensaje = "No se encontraron resultados"; Desconectar(); return(null); } } else { _mensaje = "Error en la conexion a la base de datos"; return(null); } } catch (Exception ex) { _mensaje = ex.Message; Desconectar(); return(null); } }
public bool ModificarEtiqueta(E_Etiqueta_Productor_Packing etiqueta) { D_Etiqueta_Productor_Packing etiqueta2 = new D_Etiqueta_Productor_Packing(); if (!etiqueta2.ModificarEtiqueta(etiqueta)) { _mensaje = etiqueta2.Mensaje; return(false); } else { _mensaje = "Etiqueta modificada"; return(true); } }
public E_Etiqueta_Productor_Packing ObtenerEtiqueta(string id) { D_Etiqueta_Productor_Packing etiqueta2 = new D_Etiqueta_Productor_Packing(); E_Etiqueta_Productor_Packing temp = new E_Etiqueta_Productor_Packing(); if ((temp = etiqueta2.ObtenerEtiqueta(id)) != null) { return(temp); } else { _mensaje = etiqueta2.Mensaje; return(null); } }
public bool CrearEtiqueta(E_Etiqueta_Productor_Packing etiqueta) { string query = "insert into tbl_prpk_etiqueta(nombre_etiqueta,csg,region_csg,province_csg,township_csg,csp,region_csp," + "province_csp,township_csp,producto,embalaje,OnlyExport,exportedby) " + "values (@nombre_etiqueta,@csg,@region_csg,@province_csg,@township_csg,@csp,@region_csp," + "@province_csp,@township_csp,@producto,@embalaje,@OnlyExport,@exportedby);"; MySqlCommand cmd; try { if (Conectar()) { cmd = new MySqlCommand(query, MySQLConexion); cmd.Parameters.AddWithValue("@nombre_etiqueta", etiqueta.Nombre_etiqueta); cmd.Parameters.AddWithValue("@csg", etiqueta.CSG); cmd.Parameters.AddWithValue("@region_csg", etiqueta.Region_CSG); cmd.Parameters.AddWithValue("@province_csg", etiqueta.Province_CSG); cmd.Parameters.AddWithValue("@township_csg", etiqueta.Township_CSG); cmd.Parameters.AddWithValue("@csp", etiqueta.CSP); cmd.Parameters.AddWithValue("@region_csp", etiqueta.Region_CSP); cmd.Parameters.AddWithValue("@province_csp", etiqueta.Province_CSP); cmd.Parameters.AddWithValue("@township_csp", etiqueta.Township_CSP); cmd.Parameters.AddWithValue("@producto", etiqueta.Producto); cmd.Parameters.AddWithValue("@embalaje", etiqueta.Embalaje); cmd.Parameters.AddWithValue("@OnlyExport", etiqueta.OnlyExport); cmd.Parameters.AddWithValue("@exportedby", etiqueta.Exported_by); cmd.ExecuteNonQuery(); etiqueta.ID = cmd.LastInsertedId.ToString(); Desconectar(); return(true); } else { _mensaje = "Error en la conexion a la base de datos"; return(false); } } catch (Exception ex) { _mensaje = ex.Message; Desconectar(); return(false); } }
public bool ModificarEtiqueta(E_Etiqueta_Productor_Packing etiqueta) { string query = "update tbl_prpk_etiqueta set nombre_etiqueta = @nombre_etiqueta, csg = @csg, region_1 = @region1, province_1 = @province1, township_1 = @township1, csp = @csp, region_2 = @region2, province = @province2," + " township_2 = @township2, descripcion_1 = @descripcion1, descripcion_2 = @descripcion2, descripcion_3 = @descripcion3, exportedby = @exportedby where id = @id;"; MySqlCommand cmd; try { if (Conectar()) { cmd = new MySqlCommand(query, MySQLConexion); cmd.Parameters.AddWithValue("@nombre_etiqueta", etiqueta.Nombre_etiqueta); cmd.Parameters.AddWithValue("@csg", etiqueta.CSG); cmd.Parameters.AddWithValue("@region_csg", etiqueta.Region_CSG); cmd.Parameters.AddWithValue("@province_csg", etiqueta.Province_CSG); cmd.Parameters.AddWithValue("@township_csg", etiqueta.Township_CSG); cmd.Parameters.AddWithValue("@csp", etiqueta.CSP); cmd.Parameters.AddWithValue("@region_csp", etiqueta.Region_CSP); cmd.Parameters.AddWithValue("@province_csp", etiqueta.Province_CSP); cmd.Parameters.AddWithValue("@township_csp", etiqueta.Township_CSP); cmd.Parameters.AddWithValue("@producto", etiqueta.Producto); cmd.Parameters.AddWithValue("@embalaje", etiqueta.Embalaje); cmd.Parameters.AddWithValue("@onlyExport", etiqueta.OnlyExport); cmd.Parameters.AddWithValue("@exportedby", etiqueta.Exported_by); cmd.Parameters.AddWithValue("@id", etiqueta.ID); cmd.ExecuteNonQuery(); Desconectar(); return(true); } else { _mensaje = "Error en la conexion a la base de datos"; return(false); } } catch (Exception ex) { _mensaje = ex.Message; Desconectar(); return(false); } }
private void btnAgregar_Click(object sender, EventArgs e) { if (txtNombreEtiqueta.Text.Trim() == "") { MessageBox.Show("Ingrese nombre Etiqueta"); return; } if (txtCSG.Text.Trim() == "") { MessageBox.Show("Ingrese CSG"); return; } if (txtRegionCSG.Text.Trim() == "") { MessageBox.Show("Ingrese Region"); return; } if (txtProvinceCSG.Text.Trim() == "") { MessageBox.Show("Ingrese Province"); return; } if (txtTownshipCSG.Text.Trim() == "") { MessageBox.Show("Ingrese Township"); return; } if (txtCSP.Text.Trim() == "") { MessageBox.Show("Ingrese CSP"); return; } if (txtRegionCSP.Text.Trim() == "") { MessageBox.Show("Ingrese Region"); return; } if (txtProvinceCSP.Text.Trim() == "") { MessageBox.Show("Ingrese Province"); return; } if (txtTownshipCSP.Text.Trim() == "") { MessageBox.Show("Ingrese Township"); return; } E_Etiqueta_Productor_Packing etiqueta = new E_Etiqueta_Productor_Packing(); etiqueta.Nombre_etiqueta = txtNombreEtiqueta.Text; etiqueta.CSG = txtCSG.Text; etiqueta.Region_CSG = txtRegionCSG.Text; etiqueta.Province_CSG = txtProvinceCSG.Text; etiqueta.Township_CSG = txtTownshipCSG.Text; etiqueta.CSP = txtCSP.Text; etiqueta.Region_CSP = txtRegionCSP.Text; etiqueta.Province_CSP = txtProvinceCSP.Text; etiqueta.Township_CSP = txtTownshipCSP.Text; etiqueta.Producto = txtProducto.Text; etiqueta.Embalaje = txtEmbalaje.Text; etiqueta.OnlyExport = txtforExport.Text; etiqueta.Exported_by = txtExportedBy.Text; etiquetaProductor.CrearEtiqueta(etiqueta); CargarLista(); LimpiarCampos(); }