예제 #1
0
        // FUNCIONES CRUD
        public bool insert(Catalogo item)
        {
            bool OK = true;
            try
            {
                string sql = "prendasal.SP_INSERT_CATALOGO";
                MySqlCommand cmd = new MySqlCommand(sql, conn.conection);
                cmd.CommandType = CommandType.StoredProcedure;
                MySqlParameter codigo = cmd.Parameters.Add("codigo", MySqlDbType.VarChar, 20);
                codigo.Direction = ParameterDirection.Input;
                MySqlParameter categoria = cmd.Parameters.Add("cat", MySqlDbType.VarChar,50);
                categoria.Direction = ParameterDirection.Input;
                MySqlParameter unidad = cmd.Parameters.Add("unidad", MySqlDbType.VarChar, 15);
                unidad.Direction = ParameterDirection.Input;

                codigo.Value = item.COD_ITEM;
                categoria.Value = item.CATEGORIA.ToString();
                unidad.Value = item.UNIDAD_MEDIDA.ToString();

                cmd.ExecuteNonQuery();
                MessageBox.Show("ITEM CATALOGO REGISTRADO ", "OPERACION FINALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception e)
            {
                OK = false;
                MessageBox.Show(null, e.Message, "ERROR AL REGISTRAR PRODUCTO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return OK;
        }
예제 #2
0
        public static Catalogo ConvertToItem(DataRow dr)
        {
            Catalogo item = null;
            if (dr != null)
            {
                item = new Catalogo();
                if (dr.Table.Columns.Contains("COD_ITEM")) { item.COD_ITEM = dr.Field<string>("COD_ITEM"); }
                if (dr.Table.Columns.Contains("CATEGORIA")) { item.CATEGORIA = (eCategoria)Enum.Parse(typeof(eCategoria), dr.Field<string>("CATEGORIA")); }
                if (dr.Table.Columns.Contains("UNIDAD_MEDIDA")) { item.UNIDAD_MEDIDA = (eUnidadMedida)Enum.Parse(typeof(eUnidadMedida), dr.Field<string>("UNIDAD_MEDIDA")); }

            }
            return item;
        }
예제 #3
0
        public bool delete(Catalogo item)
        {
            bool OK = true;
            try
            {
                string sql = "prendasal.SP_DELETE_CATALOGO";
                MySqlCommand cmd = new MySqlCommand(sql, conn.conection);
                cmd.CommandType = CommandType.StoredProcedure;
                MySqlParameter codigo = cmd.Parameters.Add("codigo", MySqlDbType.VarChar, 20);
                codigo.Direction = ParameterDirection.Input;

                codigo.Value = item.COD_ITEM;
                cmd.ExecuteNonQuery();
                MessageBox.Show("ITEM CATALOGO ELIMINADO", "OPERACION FINALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception e)
            {
                OK = false;
                MessageBox.Show(e.Message, "ERROR AL ELIMINAR PRODUCTO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return OK;
        }
예제 #4
0
 private void NUEVO(object sender, EventArgs e)
 {
     string codigo = Controles.InputBox("INGRESE NOMBRE DE ARTICULO : ","AGREGAR ARTICULO");
     if (codigo.Trim() != "")
     {
         Catalogo item = new Catalogo();
         item.COD_ITEM = codigo.ToUpper().Trim();
         item.CATEGORIA = (eCategoria)listCategorias.SelectedItem;
         if ((eCategoria)listCategorias.SelectedItem == eCategoria.ORO)
         {
             item.UNIDAD_MEDIDA = eUnidadMedida.GRS;
         }
         else
         {
             item.UNIDAD_MEDIDA = eUnidadMedida.UDS;
         }
         if (dbCatalogo.insert(item))
         {
             cargarLista();
         }
     }
 }