You are on page 1of 129
SISTEMA DE COMPRA Y VENTA SISTEMA DE COMPRAY ESTE ES UN PROYECTO HECHO EN VISUAL BASIC 2010 CON SOL SERVER 2005. El proyecto esti orientado hacia todas las personas que quieran disponer de ideas, conocimientos, ejemplos y una visiGn tecnoWigica de lo que conciere a lo que es un sistema, que esta codificado para soportar todo tipo de aceiones del usuario en general *E-mail *royerstudios@hotmail.com Blog http://www.rayerstudios. blogspot.com *Facebook *royerstudios SISTEMA DE COMPRA ¥ VENTA Lo primero tenemos que hacer es crear nuestra base de datos con sus respectivas tablas: Base dedatos: CREATE DATABASE FACTURA my USE FACTURA @o & Tablas ¥ Usuario: CREATE TABLE USUARIO USUARIO. VARCEAR (50) CLAVE VARCHAR (50 ) Y Cliente: CREATE TABLE CLIENTE IDCLIENTE VARCHAR(5O) , NOMBRE VARCHAR (50 APELLIDO VARCHAR (50) , DIRECCTON VARCHAR (80) , TELEFON VARCHAR (50) , EMAIL VARCHAR (50), FECHA DATETIME Y Proveedor: CREATE TABLE PROVEEDOR( IDPROVEEDOR VARCHAR (50) , EMPRESA VARCHAR (50), DIRECCION VARCHAR (59), TELEFOMO VARCHAR (50) , CELULAR VARCHAR (50), FAX VARCEAR(50) , EMAIL VARCHAR (50), RUC VARCHAR(S0), FECHA DATETIME SISTEMA DE COMPRA ¥ VENTA Y Articules: CREATE TABLE ARTICULOS( CODIGO VARCHAR ($0) , NOMBRE VARCHAR (50) , PRECIO VARCHAR (50), STOCK VARCHAR (50) ) ~ Compra: ‘CREATE TABLE COMPRA( MNROFACTURA VARCHAR (50) » IDPROVEEDOR VARCHAR (50) , SUBTOTAL CHAR (10), TGV CHAR (10) , TOTAL CHAR (10), FECHA DATETIME ~ Detallede Compra: CREATE TABLE DETALLECOMPRA MROFACTURA VARCHAR (50) , DOCUMENTO VARCHAR (50), IDPROVEEDOR VARCHAR(S®) , EMPRESA VARCHAR (59), CODIGO VARCHAR (50) NOMBRE VARCHAR (50) , CANTIDAD VARCHAR (50) , PRECIO VARCHAR (50), IMPORTE VARCHAR (59) ) Y Factura: CREATE TABLE FACTURA NROFACTURA VARCHAR (50) , IDCLIENTE VARCHAR (50), SUBTOTRL CHAR (10), GV CHAR(19), ‘TOTAL CHAR(10), FECHA DATETIME SISTEMA DE COMPRA ¥ VENTA Detallede Factura: CREATE TABLE DETTALLEFACTORA| WROFACTORA VARCHAR ($0 DOCUMENTO VARCHAR (50) IDCLIENTE VARCHAR (50) NOMBREC VARCHAR (50) . CODIGO VARCHAR ($0), NOMBRE VARCHAR ($0) , CANTIDAD VARCHAR (50), PRECIO VARCHAR ($0) , IMPORTE VARCHRE (50) ) ¥ TipodeDocumento: (CREATE TABLE TIPODOCUMENTOS ( CODEGO CHAR (3), DESCRIPCION VARCHAR(S0). SERIE CHAR(10), NUMERO CHAR (10) Y Generador: CREATE TABLE GENERADOR( PARAMETRO VARCHAR (50) , ULTIMO CHAR SISTEMA DE COMPRA ¥ VENTA ¥ Temporal Stock: CREATE TABLE TEMPORALSTOCK( COpTGO CHAR (10), STOCKACTUAL CHAR (10) ) © Procedimiento Almacenado: ¥ Compra: CREATE PROC SCOH STDPROVETDOR VARCIOS (86 err carerne, FF DATETIME as Brerw SELECT + FROM COMPRA SOHERE ZDPROVEEDCR-#IDFROVEEDOR 2 m0 Y Venta: CREATE PROC SPFAC @TDCLIENTE VARCHAR (50) BATE INE, arr oxTET De SISTEMA DE COMPRA ¥ VENTA Luego abrimos nuestro lenguaje de programacién (Visual Basic 2010). ‘Agregamos una clase y dentro de ella vamos a escribir la conexidn y las variables que vamos a utilizar, Imports Systen.Oate Imports System.Data. SqlClLent Module Conexion ‘variables tipo publica me va ha servit p Public gSERVER As String Public ESTADO Ar New Boolean Public READER As SqlDataReader *conexion a 1a base de datoz Public CONEX As New SqiConnection(“Oata Sources. Initial Catalogefactura;User Public contador_pata_guerder As Integer Private oDataadapter As SqlDataAdepter Private oDataTable As lsesiable Feivate oDataRow ss Dat aRow Private aComandBuilder As sqiCommandoutider Private PosFiladet As Integer Public fila As Integer = -1 Public TIPO Ar String =“ Public © As Integer = @ Public pre As Double “repartes Public coneetarme As Hew SqlConnection Public dataset, dat As lew DataSet Je adapter, ada As thew Sjlatatdapter Public buscar, bus As String End Module is otros formlaries Tssa;Parmordesa”) Agregamos una clase y dentro de ella vamos a escribir los numeres que me va a servir para mestrar el total en la venta dsea que me lea de nimeros a letras. SUBTOTAL \VEINTE 00/100 NUEVO SOLES ae wee | (euaRoaa) [Gancean) [Sum ora, SISTEMA DE COMPRA ¥ VENTA. vy Dinumeresivb Module nuseros | Public Function LETRAS(Byval MIMERO Az String) As String SES"QECLARA VARIABLES DE TIPO CADENA**##+ee2e0ne Dim PALABRAS, ENTERO, DEC, FLAG As String '**DECLARA VARIABLES DE TIPO ENTERO**" Dim mr, x, ¥ As Integer Fuss - H sosecseeeeminERO NESATIVO"="~ af mid(uumeno, 1, 1) = "-* Then MUPERO = MiM(NMMERO, 2, NIMERO.ToString-Length - 1).ToString PALABRAS = "HEROS ~ en of 751 TIENE CEROS A LA TZQUTERDA for X = 2 Ta MPERD.ToString, Length Tf Mid(MUMERO, 1, 2) = NUMERO = ‘rhegraatpuneno, 2 2, MMERO. ToString. Length). ToString) If Trim(MUMERO.ToString.Length) = @ Then PALABRAS = Else Exit For end Tf ext. Continuacién, “**DIVIDIR PARTE ENTERA Y DECINAL™** For ¥ = 1 To Len(Mneno) If Mid(WMERO, ¥, 1) = 7." Then FLAG = tise 1 FLAG = “WY Then ENTERO = ENTERO + Mid(MUMERD, Y, 1) else DEC = DEC + Mid(MIMERO, Y, 1) End If End If Next Continuacién, If Lem(QEC) » 1 Then DEC = DEC & 79" Stesees**PROCESO DE CONVERSION** FLAG =H" TF Val{NUMERO) <+ 999999999 Then For ¥ = Len(ENTERO) To 1 Step -1 Wwe) = Len(ENTERO) ~ (Y - 1) Select Case ¥ Case 3, 6, 9 SISTEMA DE COMPRA ¥ VENTA Continuacién, Select Case Mid(ENTERO, NUM, 1) case "2" Hf MLd(ENTERO, Mt + 1, 2) = "0" And MUd(ENTERO, Nut + 2) 2) = PALABRAS = PALABRAS & "CIEW Else PALABRAS = PALABRAS & "CTEUTO " End If case “2° PALABRAS = PALABRAS & “DOSCIENTOS * Case *3" PALABRAS = PALABRAS B “TRESCIENTOS Case “4” PALABRAS = PALABRAS & “CUATROCIENTOS " Case “5” PALABRAS = PALABRAS & “QUINTENTOS * Case “6” PALABRAS = PALABRAS & "SEISCIENTOS * Case °7" PALABRAS = PALABRAS & "SETECTENTOS * Case "8" PALABRAS = PALABRAS & “OCHOCIENTOS * Case "9" PALABRAS = PALABRAS & “MOVECIENTOS End Select Case 2, 5, 8 SISTEMA DE COMPRA ¥ VENTA Continuacién, ASIGNA LAS PALABRAS PARA LAS DECENAS™ Select Case Mid(ENTERO, NUM, 1) case "1" Tf Pd(ENTERO, NUM + 1, 1) = Fiss = *S* PALABRAS = PALABRAS 8 "DIEZ ~ End IF If Mid(ENTERO, MUM + 2, 2) = "1" Then FLAG - *S" PALABRAS = End If Tf Hd(ENTERO, MUM + 1, 1) = "2" Then FLAG = "Ss" PALABRAS = PALABRAS 8 “DOCE ~ End 1F If MMd(ENTERO, MUM 4 1, 1) = 73" Then FLAG = “S* PALABRAS = End IF Tf Pid(ENTERO, NUM 4 1, 1) = FLAG = *S* PALABRAS = PALABRAS & “CATORCE * End IF If Mid(ENTERO, MUM + 1, 2) = 757 Then FAs = *S" PALABRAS = End If If HLd(ENTERO, NUM + 1, 2) > "5" Then FLAG = "NT PALABRAS = PALABRAS & “DIECT™ End 3F Then PALABRAS. & “ONCE ~ PALABRAS. & “TRECE 4" Then PALABRAS. & “QUINCE * SISTEMA DE COMPRA ¥ VENTA Continuacién.. Case "2" Tf MiA(ENTERO, MUN + 1, 1) = "0" Then PALABRAS « PALABRAS & “VEINTE “ Flag = "Ss" Else PALABRAS = PALABRAS & “VEINTI" Fuag = oH" End If cane “3” If MLA(ENTERO, MUM + 1, 1) = 78" Then PALABRAS & "TREINTA * PALABRAS & “TREINTA Y * Mut + 3, 1) = °8" Then PALABRAS & “CUARENTA PALABRAS & “CUARENTA ¥ ~ PALABRAS & “CINCUENTA * PALABRAS & “CTNCUENTA Y ~ SISTEMA DE COMPRA ¥ VENTA. Continuacién, case - Tf Mid(ENTERO, MUM + 1, 1) = "8" Then PALABRAS = PALABRAS & “SESENTA ” FLAG = "5" Else PALABRAS = PALABRAS & “SESENTA Y 7 FLAG =" End IF cae 77" ‘If Mid(ENTERO, mu 4 2, 1) = “@" Then PALABRAS = PALABRAS & “SETENTA FLAG = "5" Else PALABRAS = PALABRAS & “SETENTA Y * FLAG = End IF case If Mid ENTERO,, PALABRAS = FLAG = "S* fe PALABRAS FLAG = oH End if SISTEMA DE COMPRA ¥ VENTA. Continuacién.. Case 1, 4, 7 ASTGHA LAS PALABRAS PARA LAS UNTOADES#++e=+0= Select Case Mid(ENTERO, MUM, 1) Case "1" Tf FLAG = *N* Then If Y = 2 Then PALABRAS = PALABRAS & "UNO ~ else PALABRAS = PALABRAS & "UM * End If CHT Then PALABRAS = PALABRAS & “OOS ~ case *3" TY FLAG = “h* Then PALABRAS = PALABRAS & “TRES Case "a" Tf FLAG = “N Then PALABRAS = PALABRAS & “CUATRO * Case *9° Tf FLAG wexnco * case "6" Hf FLAG “srs * Case "7" Tf FLAG “STETE ~ Case “a TF FUG "oH * Case "9" If FLAG smueve ~ End Select End Select SISTEMA DE COMPRA ¥ VENTA Continuacién... 1f Mid(ENTERD, 6, 1) © 70" Or ALd(ENTERO, 5, 1) © “8” OF MIM(ENTERD, 4, 1) «> "8" OF _ (Rid(EHTERO, 6, 1) = "C" And Mid(ENTERO, 5, 1) = "” And MEG(ENTERO, 4, 1) = “8” And Len(ENTERO) <= 6) Then PALABRAS = PALABRAS & “MIL * TY 07 Then TF Len(ENTERO) » 7 And LA(ENTERO, 1, 2) © "1" Then PALABRAS © PALABRAS & "HILLGH * tse PALABRAS » PALABRAS & "ILLONES * tnd If end If Next aeeneeeaye LA PARTE ENTERA Y UA PARTE DECIRAL“*=*++¥=+¢== af DEC © ** Then LETRAS = PALABRAS & "CON " A DEC ese LETRAS = PALABRAS & “eo” ind If thse LeTRas ind If nd Function End Vedule SISTEMA DE COMPRA ¥ VENTA Agregamos una clase y dentro de ella vamos a escribir el siguiente e6digo que nos ha permitir que nuestro formulario tanto ellente, proveedor y factura se generen automiticamente, Teports System.Data .SqlClient Module Generar Public dsEntorno As New Dataset Public tlpoDocu As String Public eeddoeu As String Continuacién, Public Functicn GenerarIBClente(Sylal TABLA As String) As String Din RESULT As. String « Dim ORI Ay Sqloatateader Din WT As Teteger = 8 Dim O As New Salomund(“SELECT ULTIDO FRON GENERADOR AMERE PARATETRO = "* + TABLA “"", COMEX) (ne. ope0() DRL = O.feecatetender ale Dmt.Read WT + vaL(OUC RATIO") + 3) Ed hile (COMEK. Close) Din CERDS As Integer (AROS = 5 = Len(ste(uer)) Select Case Cems, S RESULT LeFECTABLA, 1) 4 "OBO" 6 Trie(Str(WLT)) SRERAT = Left(TABLA, 1) + "00" + Tria(Str(WLT)) RESULT = Lefe(ragua, 2) + "2" + Tria(Str(uLr)) RESULT LefE(ABLA, 1) 4 °° 4 Trin(Sér(ULT)) SISTEMA DE COMPRA ¥ VENTA. Continwacién. ‘iblic Function GenerarFactura(B/al TABLA As String) a8 String Din RESULT 4s String = Din DU As selbatateader in WT fs Integer 2 Bi OD As Ne SlComand( “SELECT MIMERO FRON TIMDOCUPENTOS WERE COOIGO = "* + TABLA+ “*, COMER) HEX. pent) Rl» OO BracuteReader le Oe Read UT « wal(RL(7HERO) + 1) ad while (DEX. Close() i CERIS As tage EROS = 8 Len(str(t)) Select Case C805 Case 6: RESULT = Left (TABLA, 2) + TebeNO” + Trda(Ste(ULT)) Cove 5-2 RESULT « Left(TABLA, 1) + "eene” + Tria(ste(UT)) Case 4: RESULT = Left(THBLA, 1) + “Weta” + Tria(Str(QT)) Cove 3 5 RERAT = LefR(TIOUA, 1) + "O80 + Tria(str(ULT)) Gave 2 5 RESWAT = Left (TABLA, 1) + “WR” + Tria(Str(iRT)) Gave 1: REST = LefR(TABLA, 1) + "4" + Trla(Str(UAT)) Cove 8 : REST = LefR(TABLA, 1) 4°74 Teba(SEe(ULt)) End Select ceararfacturs = REST fd Function Continwacién: Public Function GenererTIProveedenes(Byvl TABLA As String) As String Din RERALT As String = “* Di Dat As SqlDstatencer Din WT As Integer = 8 Dis OP As Ne SalCommand(“SELECT ULTDO FRM GEXEMOOR WHERE PeRANETRO = "* + HOLA + **, COneR) mex. cg) Dit = OD frectetesler le OR ead WT « val(oR(ULTIO") + 1) fd ile (Comer Cose() Din CER As Integer EROS » 5 ~ ken(strur)) select Case C5 Gave 2: REBT « LeFe(TABUA, 2) + "ORO" + Teia(str(.7)) ase 2: NESUAT = LeFE(TABLA, 1) + "88" + Trial Ste(UET)) Case 1s RESULT « Left(TALA, 3) 4 "8" + Teba(ste(aLT)) (Case 0: RESULT = LaFt(TABLA, 1) + "7 + Teia(Ste(aLT)) nd Select GenerartDProveedores = REST fed Function bod Podale SISTEMA DE COMPRA ¥ VENTA. Luege vamos a crear nuestros respectivos formularios = Formularie ¥ Usuario: Imports System.Data Imports System.Data. SqlClient Public Class usuario, ‘Dim ESTADO As New Boolean Dim READER As SqlOatakeader Public gSERVER2 As String Dim It As String Dim 12 As String ¥ Ydentro del botén aceptar escribimos al siguiente cédigo: (sexta) Pelee Sh ccnp C1ich( yal sede A Spt Djeck, yal: As Spt. tings) Wes enlanpbe. Lek bratic contador 4s Single Din slower Js ew StingCipe"elect * from nario where aseriui", char) Dia as Re man slice, CORE) ! ealrCar).Yae = teeter ext Din Te String» CSt(adnestesenle()) 1 cantar #3 The aga“ wabrer Les Setar”) ted et 1 ter) «0 Then contador » cota +1 egon(" euarle cetrecle es ncorecta") speunsris Tat « tle eat = “7 ‘ersarin.Feces() erase) Ese ROG « a. ecsteeer ‘READER. Read) Th = Gotr(REAOeR(“enearia")) Te = Ctr (BOR “clave")) oer cene) SISTEMA DE COMPRA ¥ VENTA Continuacién, else READER = ed.ExecuteReader READER. Read() In = CStr(READERC“usuario")) 2 = Cstr(READER("clave")) COMEX.Clese() If (12 = txtclave.Text) Then ‘Usuario Actdvererm.Hide() Menu_Principal.StatusSteip1.Visible = True Menu_Principal. ToolstripstatusLabel2.Text = Me. txtusuario. Text Menu_Principal. ToolstripstatusLabel3.Text = Me. txtclave Text Meou_Principal ShowLalog() Else contador = contador + 2 HagBox("Ele usuario o centrasela es incorrecto") txtusuaria.Text =" txtelave.Text « “* txtusuario.Focus() End IF End IF End Sub ¥ Ydentro del botén cancelar escribimos el siguiente cédigo: Private Sub cedsalir_Click(8yva Me.Close() end Sub Y Ydentro del evento keyPress de la caja de texto tatusuario escribimes el siguiente codigo: Private Sub tetusuario KeyPress(Byval ser If e-KeyChar = Chrii(Keys-Enter) Then ‘e-Handled = True be. txtelave.Feeus() nd If end Sub Y Ydentro del evento KeyPress de la caja de texto txtclave escribimos el siguiente. codigo: Private Sub txtclave KeyPress(8yVal sen If e.keyChar = Chrii(iieys.Enter) The ‘e.Mandled = True ecadaceptar.Focus() ind TF End Sub SISTEMA DE COMPRA ¥ VENTA InoLeNTE 1 GD GaweeD [ ouanoan womans [ | LMoincan APELLIBOS | | oon) BIRESCION ([eARcELAR] (CERRAR Ewa Clientes: (Schemes Imports Systee.Oata Imports Systen.Data.sqlchient Public €lass Clientes Private obatandapter As SqlDst adapter Private eDatatable As ataTadle Private oBatalow As Dataltow Private oComandBuilder As SqlComandBullder Private PosFilaact As Integer Ieports Systen.0ata Ieports System.Data.SqlCLient Public Class Clientes Private oDataAdapter As SqlDateAdapter Private DataTable As DataTable Private oDataRow As Dstafow Private oComandBuilder As SqiComandduilder Private PosFilaact As Integer YY dentro del botén nuevo escribimos el siguiente cédigo: SISTEMA DE COMPRA ¥ VENTA Private Sub Oyttonk Click(@yVal sender Ar Syste: Gall Limpiar() TextBoxt.Text = GenerarIDCliente("CLIENTE”) TextBoxl.Enabled = Felse TextBoxd.Enabled = True TextSoxs.enabled = True textboxt.Enabled = True TextBoxs.tnabled = True Texttoxé.Enabled = True OateTinePickerl. Enabled = True Texttox2.Focus() contador_pata_guardar = 1 ‘Strltueva. Enabled = Falst BtrGuarder. Enabled = True Btneditar Enabled = False Btn€Lininar. Enabled = Fal) btncancelar. Enabled = True BtnCerrar.Enabled = False ‘Button2. Enabled = False TextBoxz,Focus() End Subs Y Yluego creamos una funcién de nombre limpiar que nos va a permitirlimpiar las cajas de textos: Private Sub Limpiar() TextBoxd.Text = Nothing TextBoxd.Text = Nothing TextBox3.Text « Nothing textbart.Text + Nothing TextBoxS.Text = Nothing TextBoxt.Text = Nothing DateTinePickeri.Text = othing TextBoxl.Text = Nothing End Sub YY dentro del formularioload escribimos el sigulente cé digo: Private Sub Form3_Load(Byval sender As Systes.object, ByVal Text@oxi.Enebled = Felse TextSox2.Enabled = False Textfox3.fnabled = False textboxt. Enabled = False TextBox5. Enabled = False Textox6.Enabled = False DateTimePickert. Enabled = False Btneditar.Enabled = False BenGuardar.tnabled = False Otneliminar.tnabled = False Button2, Enabled = True oComandBuilder * New SqlComandBulider(Ne.oDatadapter) oDataddapter = New SqlDatandapter( “Select * From Cliente ORDER BY IdCliente™, COMEX) eDataTable = New DstsTable ‘oDataAdapter .Fill(cDstaTable) End sub SISTEMA DE COMPRA ¥ VENTA SISTEMA DECOMPRAY VENTA © dennro del Bonde quardar escribimos el squisrne oddhyo: Private Sub euttung CLick(eyval sender as Syster Tf TextBowd.Text = hetiing Then Fake Sub it it Tf Tented text © Nisthing then xk Sub ted tf 17 Tewtond. Text = Rothing Then Cake fb tea tt if tenthoet, text © toting then kt ube ind TF IY Textlens. Text © nothing Thea Exit Sub ee EF ‘Textiend-Text = hothing Then take fab ing BF If Daterimerickert.Text = wothing Then Exit Sub na Tf | Sontinuacén.. 2 suntan pata guarar = The ed GREE fet) (Sen ents As Re Sing pe{"ivsert fete CLiante! Mints Sere, Ages Seen, teams, tt Mechlales fi Be ", Ca) (Ce A ee RRR, COREE) maploet "Lor tenes se gramiewn corectamente") (a yaw Comm RATE SEG SET TDS = TPAD © ERE AARUPETNG = “CLIENTE'™, ON) | Sontinuacién.. If contador pata_guardar = 2 Then iy (Comet. Spent Dia tevtasglelininer ds lew String(tTypet"opdate Clieste set Monbrenfiy where Edtlientess", Chari})} Dis cde As New Sclcomenc(tertosqleLiminar, CONEX) ‘cada. Forapeters Adda thilalue{ "a", He. TextSeal. Text) cad Parameters. Additinnlue(“WE", Me.TextSen2. Text) ‘cde. Parameters Addai thunloe( "Bs, Me. TextSenS, Text) \cmde, Parameters. Addaithvalue("§e", he. textbox®. Text) ccna, Parameters. adstithvalue{"fe", Me. TextBoxS. Text) (ca. Parameters.addhcitiwalue("t™, Me. TextSoxs., Text) Can. Parameters Addai thwsiue( "Be", Me OubeTieePickerd. Text} cade, tuecetoionguery(} ‘Comets. Chose) Magton{"Los dition se wediticaros correctimmente") SISTEMA DE COMPRA Y VENTA ¥¥denvo del boten cancelar eserbimos el siguiente coco: (cacews ) Private Sub bencancelar_€1Lck{8yval set Call Linpiar() ‘exttoxt.tnabled » False JextBor? Enabled = False TextBor3.Enabled = False textbox Enabled = False JectBous Enabled = False TextBoxé Enabled = False DateTimePickeri. Enabled = Felse ‘TextBoxi .Focus() contador pata. piardar = 1 Denuevo-tnabled © True Stneditar.tnabled ~ False Benflininar Enabled = False teneuardar- enabled « False bascancelar.tnabled « Paleo Dencerrer, Enabled = True ‘TextBox2.Foeus() tnd Sub ¥ Ydentro del botdn cerrar escribimos el siguiente cédigo: (NG) Private Sub BtnCerrar_Click(By\va Btneditar-Enabled = False BtnGuardar-Eoabled = False Btneliminar.enabled = False Ne-Close() End sub ¥ Ydentro del botén buscar escribimos el siguiente digo: Private Sub Buttonz Click 1(8yval Buscar Cliente, Showsalog() End Sub SISTEMA DE COMPRA ¥ VENTA ¥ Ydentro del botén modifiear escribimes el siguiente eédigo: (woorrcaa) Private Sub Beneditar Click (ByVal TextBox «Enabled = True TextBox? Enabled = True ‘TextBex3 Enabled = True textbord.enabled = True TextBoxs Enabled = True TextBoxs.Enabled = True DateTinePicker!.Enabled = True contador_pata_guardar = 2 Btnlevo-Enabled = False Btneditar.Enabled = False BtnGuardar. Enabled = True BenEliminar.Enabled = Felse End Sub SISTEMA DECOMPRAY VENTA © dennro del Bonde eliminar esentimas elsiguieene codigo: (Buea | Relate Sub Mtntllbatnar CLick(By vel sender As Spstem.chjece, Myla Syevtam.toestiings) Menten #eat iets Try Con. Open{ ) Bim Tastaaglbrrer As tiew Striog(CType(“éeLete fren Cliante where Lacliontengoaderlialas™, Cnsr())) Ohm mdberrar As tars iq Comenl(tawtenglierrer, Conn) slteorrar Parwseters Add{"fsoteelimine", “410%! ype Werther). Welue = Testthent. ent miborrar txacvtstionjuery( ) conex.clase() Fag#ox("#1 producto fue: borrado: conectamente”) Textfaat.cnabled = False TextBox?fnabled = False Texted Enabled = Fulas fecthest enabled = Halve Textion}.trabled = False TextBoxé.tnabled « False terthort.tnabled © fothing Tertnest.tnablet © wothing Textdeet.trabled = hetning GateTimePicherl. Enabled = lothing Cateh et Aa Eaceptlon ugtion(ex.swssage) nd Tey tintlininer.trebled = false Mineditar.trabled = False Eo Sub ‘End Class SISTEMA DE COMPRA Y VENTA ¥ Proveedores: (BD Provesdoresvt REGISTRO DE PROVEEDORES IDPROVEEDOR Geen [curren | EMPRESA ODIFICAR | DIRECCION EUMINAR | CELULAR FAX EMAL Rus. Inport: Systen.ats Isports System.0ata.SqiClient Public Class Provesdares Private oOataddapter As S9ldatandaps Private oDataTable As DataTable Private oDataRow As Datakow Private oComendBuilder As SqiCommandbullser Private PosFiladet As Intener dentro del formularie load escribimos el siguiente cédigo: Private Sub Form _Lood{ByVal sender As System.Object, ByVal € As System. ventérg: ‘TextBoxh. Enabled = False ‘TextBen2. Enabled = False ‘TextBoxs. Enabled = False TextSoxd. Enabled = False TextBoxS.Enabled ~ Falee TextBoxs. Enabled = False ‘TextBox. Enabled = False ‘Textbox. fnabled = False DateTimePickert. Enabled = False Btneditar Enabled = False tnGuarder.Enabled = False BtnElininar.tnabled « False Button2.tnabled = True ‘oComeandBuilder = New SqiComanddusider(Me.abataAdapter) obataddapter = Hew Sql0ataAdapter("Select * From Proveedor ORDER BY IdProveedor™, DataTable = New Oatatab! ‘obateAdapter. Fill (oOateTable) End Sub Handles Myo + COWEX) SISTEMA DECOMPRAY VENTA © Y dentro del bona nueve eseribimos el suerte codigo: rdvate tub Ptatvaws CLick(Hyivel sender de System call Lepiart( Tentibond. Test « Generar IDCLiewte(“Picttoon") TextBond tabled = False SISTEMA DE COMPRA Y VENTA ¥ Ydentro del botén guardar escribimas el siguiente cédigo: Private Sub BtnGuardar_Click(ByVal sender £ If TextBoxL.Text = Nothing Then exit Sub End TF If TextBox2.Text = Nothing Then exit Sub ind If If TextBox3.Text = Nothing Then exit Sub End af If TextBond. Text = Nothing Then exit Sub ind If IF TextBox5.Text = Nothing Then exit Sub ind Tf If TextBox8. Text = Nothing Then exkt Sub End If If TextBox?. Text = Nothing Then Exit Sub ind Tf If Textboxd.Text = Nothing Then Ext Sub ind If If DateTimePicker2.text = Nothing Then Exit Sub End If SISTEMA DECOMPRAY VENTA Sontinuacén.. {If contader_pata_guardar « 1 Then wy cone ape () Oke textong ingresar Ax lew strtng( ctype “Insert eto Provendee(tdFroimedar, Feprwia/Dhreccian, tebetan, Calabar, Fax, aa) Rac ech) Rv sta, Ac. Be Dim cad Ay Mew 9 Comans(ewtovgLingresae, CONEX) artnet IMI RHFaue( “BA, Me Text Bow) Tent) jer emeter ts mdi thivelue("@", Me. TewtBouz. Text) ermncters,hddulthialue(“BI", He. TextBond, Text] ermmeters.hédhithiinlue(“e", He. extBonS. Text] Parameters. Adchithtialue("@f", He. TextBox8.Text] Parmeter: Addhititialue("g", He. TextBox?.Text] acaseters.kéchithvalue( “gh”, He. TextBoxlText] RERRRRERE onda Execateftorguery() COREXChowat) HsgBen(“Los datos we graberon corectamente”) Dim ced: Aa few SighCommand{"WPONTE GENERIOOK SET UTD = ULTTAD «1 WHERE FARAMETRO = "PROVEEOOR™™, COME) Parameters. addiithvalue("gi", He.DateTime?icher1.Text) ecb)", Chort))) ‘eettaet.tratled = Tale TextfoxS.Eonbled = taloe ‘Fewtont,tombled = telie ‘TentBW? Enabled = Palie Bax. Enabled = False DateTiaaPickerl.Unsbled = ¥ eomtador_pata_guardar = @ Cotch en Ae Except lon MagBiou(ex Message) nt Tey End If | Sontinuaaon.. 2f contador pata guardar = 2 Then Ty ‘cone. open) Dim texteagleLiminar Ax ew String(CType("update Srowentor eat Emprenasg where IdProvmedorea”, Char())) Bim cela an few Slommanst{textasqleliminar, COME) onde. Parameters addiithwalue( “Ga”, Me, TextDexL, Text) ‘onde Parameters Adsiiithvalue( "gb", Me. TextBoxz. Text) senda. Parameters. ddiidithvalue(“fe", Me. TextBox. Text) cmd. Parameters addwithvalue( "Bt", Me. TextBomd, Text) ‘onda Paraeeters.ddihlithvalue(“ie",, He. TextBax5. Text) ‘cada. Paraeeters.addidthvalue( "At", Me. TextBox. Text) ‘cma Parameters Adubllthvalue(“ig”, Mo. TextBax7_Text) caea Paramarters Addhbthuale( "Bh" , He, Textbox Text) cmd Parameters acuithvalue("Gi", Me DateTimePickerd. Text) COMEE. Close () Pagtox("Los dates se sodificaron correctamente”) ‘extBoxttnabled = False Temtiea-fratled Datet imePickert.trabled = contadorpate_guardar » B ‘catch ex as Exception Ragiox(ex.Message) End Try end it | Sontinuacion: BtnGuardec.tnabled = False Strtiveva. tnabled + Troe Wtrediter.trabled = trot RAELialnarcrabled = True call Limpiar() nd Sia dentro del botén moditcar excabimas of sguente cédigo: (aooncaa) Private Sut Btnedicar_chick(eyval x Textdeni.Enabied > True Teeter. Evabled = True ‘Textiion).Qnabled = True BatefbenPicheri.tnabled = truw santadar_pata_gvarder = 2 | © dennro del Bonde eliminar esentimas elsiguieene codigo: Private Sub BinElininar Click(ByVvol sender as System.Object, Byval © As System fveotings) Handles #taelindan Tey (COMEK.Open() Gin textoagiborrar As fon String(CType("delete fran Clisnte where 18Clievtenendeet nina, Char())) Bim maborrar Ai New Sqicomarn(textonqlborrar, COMEK) dorrer Parameters. Add{“icoderlinina’, Salobiype.aVarcher].Walve © TextBoxd. Text mthorrer teecutetiontuerr{) COMEK. Vall(ConboBexi. Text) Then MegBon{ "CIATION INUFICTENTE™, MogSocstyle.Critleal, “AIWERTEMCTA™) oe, TexRBon?. Text = Pidd(e.TextBox?. ext, 2, Len(?e.Texthan?. teat) an TextBox Select lonttari © (an(Fie,TextBen, Text) » tate up ‘he. TextBon?,Fecue( } fod It ATW _AGREGAR. Enabled = True emt Sub | © creamos una funcdin para que nuestros stack de nuestros amicuics se actualicen af momenta de vender Private aie detualitersiock() 4 aa Integer Laps = val(detat. Rows Count Tattring) ~ 4 Fextient5,Fext ~ Validated. lees. Cost TaString) Fee k= Te Laps Tr CONEE.Cpent) Bie textasal. 45 sew String(yoet “updete Articulos set codige-codign, SteckfStack where codigo-ficedige", Che-{})) Sgitdmard(texterql, COREE) ends. Parameters. AdebiStonalone(“Bitock™, att. ows( 1)(4)) ‘ces. taecitemorgeery() Comer Cheaec) uw) cOmeE opens) Bie sqherrar ds tw String( “delete frow Teaporalsteck™) Eke deteeqbarrar AL lew Seghteman(@berrer, COREX) Matasaberrar, tencuseuarquery() conex.clnoet} Gatch ex As Eaceztion ‘magaam(ex_mezzage) Eng Tey tnd Seb | © Greamosotra funcidn ext funcisn me va a permitircumplir fas funcione s de acuerdo al tpo de documenta que uno wa eleyir en ef combolFactura o Boletal: the ee ____ SSLETA FACTURA vores Private tub BOL_FACT() nie OTT ee en adder eetigsis imemenmnnsreficl aarensingesn) << er) end 1 ee ee eT ‘SumerTotelingreser() — End rf acre © Dent del evento SelectedindexChanged del combo bax de documenta ltamamos a fa funcién que hemos creado aenina: EIEN Commbotinn? setectetns =| (BOL FACT) | Benito def botén carkelar esonibimos el sauce coding = rivate Sub ButtonS Click i(8y¥al ser CANCELAR_VENTAC] atagr ipl) atngrid3() Stnduardar, Enabled = false Ptrvvevo.tnabled = True Buctton3.nabled = false BtnCerrar.Enabled = True TextBoxt.Enabled = False Textiioa2 Enabled = False Coabotan’.fnabled = Falie texthosS Enabled ~ False sthox, Enabled = Pele Texthoa7.Enabled = False texthoxs.enabled = False Textfions.Enabled = False Textaoxia. Enabled ~ False TexttlonLL.tnabled = False ad = Fake sled = False btnguitar,tnabled = False inet ute | Denvten del botdn agregar excritimas et squlente coda: Prdwate ub OTH AGREGAR_Click(MyVal sender as Spstes.ci:ject, My¥al © fs Spates 1 Mea tembon?, Text = tithing then WagBoutangrese ta varvtldad”) eed Sub ind IF od ‘con. pent} ‘Dim Uanterqlingresar At lime SUringiClype(“Lnkert nts Dettallefacturatteut actuca,Oucusenta, LAC Liante.nanires,Codiga.Wenare,” A “Cantddad, Precio, taperte aue s(@roF nc turin Documenta BIAC Lente, Primbe ac Rodi go, More AAA Lied, WerecdeBlapir te)" Chard} ‘Dim emda As Heat Sq iComand(tentenahingresar, COWER} rameters, Addit thvele("pirotuctura”, Me Combiond text) they) Mandles, BTW aameoa.CLick Addstthvalue( "Roost go", ‘ne, textbons. Text) Adil thveluetpeoabre”, Ne. cbbon Text) Addi thovale (amt sind", he anton? Tex) aranaters-Addabthvelue(“Btreco”, he, textbans.Taxt} rameters, Addi thvelue("PImporte®, he, TextBox, Tent) ‘Conta pee ‘he tawtosgl As Row StrLng(eTyped"insert Unto TeaparaLttock(eadiga, Stockactual juslues(Beodlgo,@Stockierusl}", Chee (}}] Dim cedz Ab Mew Sq iCsmmund(textecal,, CONEX mdz, Parameters Addai thWaloe(codigo", He, textbaxS.Text) onde, Parameters Addaithvelue( Estacksctuil”, Me, Tevttaxt, Text) ends Execataonguery() ‘Comen.Ciese{) MsgBon{"Los datos se grabaron corectaseste™) datagrid3() BOL_PACTE) pre-e CorboBond. Enabled = False ‘tewtbanS.Enabled = False sbhon, Enabled = Fale Fenton. Enabled = Palys ‘eethon.tnabled © False Tertiiond Enabled = Faloe DateTiserickert. enabled = Fase Combaltond Text =“ Fawtilon’? Text Rawtbaxil. Text + Teton. Text textboxs. Text « ebbion. Text =" sbbon. Enabled = True Text8ox7 Enabled = Troe Cateh wx Ax Exception ‘Snugtion( ax. tteeuage) tnd Try Tm AonMEGAA tnobled = Fale ited tab | © Dent def botén guitar agre gamos of sguente codigo: (aura) Priowte Sub Btngsltar Click (Eyval. sender Ae System.Object, Syvall ¢ Ax Syrtes,cvevuips) Mandlex Wamgultar click COREE. open() Die aqborrari As: lew String{ "delete free O£TTALLEFACTURA HERE lire actucee"* WH fie ContoBend. Text "and cadigen'™ RewtierS.Text 1 Dim detengberrert Ay Hew Sq lcomemnd(amtorraris GORER) Dim saborrard AL Wow String( delete from tenporalatoct MRE codigos!" A taethoxs fext & Di datABGDOrrer? AN Mew Salcommnit sMborrarzy OOREX) dataaqborr ord Eeseotestondoaryl) (COME. Clase() sdatage Lats) birquiter tabled = Feise nt Sat | Bento del evento CelIMOUseClick del DataGridView! excribimos ef squlente cOdgo: (TEL atacietaview 1 Cotttoamet tick oy Private tot Betadriatriet CellmouseCicki tyes] seeder 4s on: TF e.Roindex < @ Then Exit Sub tevthosS. Text = DutaGrlaviewt. Thea(t, ¢.lowTadex) aloe wenguiltar.taahled = True tnd See Dentin del evento MouseMove delfarmuaria vents excribimos ellsiguiente cddiga: ‘(CEST Fm facture moucestove ic Petvate Sub Pru factura Mowsetove( Sys oa_FACT() (tra Sub | Dentwo det botén Via Previa escribimos el siguiente cbcigo ef cual nos aa permtir general un reporte dela venta: Privte Sub btwriste_click(myvsl vender az Syster with ppd "Dimloge de Breview -Docuaant = Pat Test = “Lute de Producto CiindowState © fore jrwirit ate Flaximized Shanaralog() End with Enel Sub © Deeitm def botén imprimir excabimas et dguene cbdiga: (eee sen Private Sus GtnDwprimir Click(eyval sender ss Syste. ce ject, # With Fdg “Dislogo de Friant Bocwment = Pde AlLonBrinttorile = False ALlewdelectlon = Troe ALlowtometages = Tro M4 ShowDialog() = Windows. Ferms.OLstogtievel* Gt Them Pdt.Printersettings * .Printersettings de. Print) End 1 End ith nd Sate | cmon at (a) Lavi) Private Sub PAt_PrLetRapa( val sender AL Syitem.cn ject, Byval @ As Sywten.tra ‘Ole A as Integer Bim wth, athnonbre, sthfecha, sthOOUM, wtbnperier, Stila, stipapet, athfecture, sthapellidei, wtheodigec! athruceepress, stbdistrite, stidi-rccien, steteletone, stbwenteder, sthnosbrevende, stb ds tien Stringhet lien) ‘Din Testo, textoz, textad, Cextod, tanto, Teutes, texto?, tewtad, TEKTOLG, NENtGLT, ThwtOM, texters ax String ‘Bie Fuente As Wow Font ("Courier mew", 38) Ble Breche Aa fcush = Beanies tile Gin M As Integer © e.Margintiounds. Left ‘Dim ¥ As Integer = e.marginfounds. Too “He stbsalto.Append(") texto’ ~ ethcalte.Tostring -e.Geaphies rawString(Revte3, Fuente, Brocka, X,Y) Y= 1 6 Fuente. Getheight sthsalte.Length = 6 7 sthfeche.append("Feche del Peds 5 ke eterinerickerL. text) textou = sthfechs. toString e.traphics.trasString(textos, Fuente, Brocka, 258, V} Yo ¥ © Fuente Gemieight: tbpago. Length = @ te | Sontinuacén.. \e-fieaphicn.trawitring|terto3, Fuente, Bracha, K, ¥) Ys ¥ + Nucrte-tetmeight stbsalte.Length = # “aH stbeepreta.sgpend(“Neauee ue la Expreta : * A Me Lanelas Text) textel? = stheapresa.ToString se Graphics Drawitring(textel2, Fuente, Srocha, 258, 1) sta haat = 8 we ‘s.eraphics.pravstring(texte3, Fuente, Brochs, X, ¥} sthewceapress Appand{("Huc le In Expresa = * Re. Label $6. Text) testaid = athrucespresa.Testring s-Sraphics.Grawstring(textol3, Fuente, roche, 258, ¥) Ye Y + fuente. tetieight sthpage. Length = “at t.Graphles.Drawstring{texte3, Fuente, Bracks, X, ¥) vn Fe Fuanta catia ignt stbaalte. Length = “HM ARECEUR Append ("F ips Becusents 1 Be. Combetiond. tect} teetsid © sthOOCU, Tabering sGraphica.Orawitring(textolé, Puente, Srochs, 289, ¥) Ve Vy Fuente, Getieghe steam teneth = @ | Sontinuacén.. te s-Graphics-Demtring(texted, Fumte, Bracha, X,Y) * 8 he combopons. Text) #.Graphics Dractring(textod, Fuente, Bracha, 258, ¥} ¥ = 7 + Fuente Gemielgre sthpegs. Length = @ 77 evGraphica.Drmctring(texted, fuente, frache, X,Y) aphics.Ormcitringitente?, fuente, Meuche, 24, ¥) Wa ¥ + Poente.Getietgne we iage se Graghics.Drmctring( texted, Fusnta, Brecha, X,Y) 6 Fuente Setrmeighe sthvelto length = 6 a7 sscudigecli somerd( "Codigo del lience 5° me TewtBoxa. Text) ‘= stbendigocli.TaString creruehics.tracstringibertetl, Feentr, érecha 258, ¥) Y= ¥ + Fuente.cettielght stbpage. Length = © | Sontinuacén.. “Ht estrapnics.Drestring(texta3, Fuente, Bache, x) ) = ¥ + Fuente. Getiteight sthaslta.Legeh = @ “it sthapel dt Jgpend("Wostre Complete y OT = 7 We Textiox2.Text) Sthuuperiorvepend("Cedigs Deieripclon Cantidad Precis iaperte”) tanta? = athuperior TeString evirephiics.Oreeitringtterted, fuente, trache, ®, Y) on + Mumnte.Getneight sthnuperdor Length = @ | Sontinuacén.. sthsalte typend("*) tented = stosalte.1: e.liraphice Ormtring(textal, Fuente, Bracks. X. ) Va V0 Fate teetielght Wtbealta.Lemgn = @ “in Hor KO fo: Me Batatie ive town Cavnt - 1 stb Append (DatstrLaviewt.Dstasaurce Mews (1)(8). Testing. Peamight( 1a) ) tb. Append{ Detaoriavtewt. Datasource.Mewe(1)(1). ToString. Paatightt Ie) > Sth. Append Datadr Laviewt. Datascurce Rowi(1}(7). Tabtring.Magtight 13) UD Append Date Leviewd. Gatabavece Rews(4)(2), Tebtring. Pmaigee( ie) > tb, Append Dainde Laviend. Bartahoue ce Meet (1)( 8). Radtiring. Pinetlght (18) ) Text, = th Tastriiag Araghlcs.Ormciuning( Texts, fuente, Arche, a, ¥) + V0 Fumie eh Lengty est Slrephics Orettringitertel, Fernte, Bracke, 1, 7) ve ¥ + Puente, Nebealen. engin = @ “ie tba te-Apoens(™") Revtad = stinelts. tottering e.tiraphics.Oradtring(tertet, Puente, Bracks, 1, ¥) ay + Ruente. Geemeiget ‘sthsalte.tength = @ “ae Graphics.Ormcstring(textols, Puente, Orochs, 292, ¥) ¥ + Fuente. GetHeight D7 lanaliel Graphics OrauString(texte3, Fuente, Brocha, X, ¥) Yon + Fuente seme igre stbsalte Length = 6 “tt stbpagn appends “ivototal: * Pec Textonta. Text) texted = sthoago. toString A.WPaphich.DemGtring( texted, Puente, Brocha, 00, ¥) Wa 0 o Fuente Getieignt thyaga, Length = @ tf e-rephice Drmitring( texted, Fete, Brachay iy ¥) Wa ¥ + Poente.Getiietght wttaaleo.tengen = @ w sty Append “Tov: * a he. Tewtbantt. Taw) tanned = sthlgy.Tottring Graphics Orewitringitextod, fomnte, Brocha, 480, ¥) 2 + Puente. Getiteight “a . e.Graghics.Demestring(texte3, Fuente, Brocha, X.Y) = ¥ + Fuente.cethielgnt stbaaTeo. Length = 8 | Sontinuacén.. mm tSpagot Append( “Total a Pagar: tested = sthoeget.Testring eMireghics.Oreabtring(textod, fuente, troche, a0, ¥) Va Vs Rammte.Getanlght wtapagotcamats = 0 ue ~ ma. Teatdoxd2. Text) ¥ Dentm del events TenC hanged dela caja de texto titotalescribimes elsiguiente eécigo: (EEN Fenton Feat hanged el Prlivete Sub TewtBionLd textthenged{tyvel sender An Syites.cbject, tyvel A Tumseerde(TewtBionl2. Text) Then ‘he-Cabelii. Text = (ETAAS(TextBari?. Text) & 7/00 meso SOLES tise ind if ‘Taxtibonl2.SebectionLength = Texttiond2. toftrling. Length tnd Sus (DVECISES 09/100 MUEVG SOLES TOTAL % SISTEMA DE COMPRA Y VENTA Vamos. realizar una compra de 5 productos de tipo GHUR: Tipo Documento Primero me mostrara el formulario eto de documento que voy hacer la venta al cliente. eNTADE PRODUCTOS ron AOA S| Empresa, LOS SAUCES LAGUNA AZUL, its aie Teste: STR] See aT [ene] ‘cop CLENTE: ‘cuoea ce SUB-TOTAL we DosciENTOS UND Goa NUEVO SOLES erie au | ("ane (wana) (EamceLaR) SAL Tom a J | tosmeFacaae ) [is Pes) SISTEMA DE COMPRA ¥ VENTA ¥ Luego hacemos clic en el botén Vista Previa Coventree) Ynos va a mostrar todos los productos vendidos al cliente: Fecha del Pedido 29/10/2013 Nombre de la Empresa: LOS SAUCES LAGUNA AZUL Ruc de ia Empresa + 20267217785 Tipo Bocumento : FACTURA Meo de Documento + 00000002 ceeesse---Datos del Cliente: Codigo del cliente + cooo2 Nombre Complete y DNT : royer Detalle del Pedido Codigo - Descripcion Cantidad Precia Importe 0002 Mouse ¥ 8 8 Ao002 Teclado 1 34 34 0003 Impresora Lt 54 34 RO004 Camara Web £ 32 32 O00 Monitor 1 21 2 Subtotal: 169 Gv: 32,11 Total a Pagar: © 202 SISTEMA DE COMPRA ¥ VENTA. J Vamos realizar una compra de 5 products de tipo ISIE: Tipo Documento Primero me mostrara el fermulario Tate | BIEW = ée tipo de documento que voy hacer ' laventa al cliente, sate [0] [ononoon | ‘vena De PAODUCTOS fom SWB =] Empresa LOS SAUCES LAGUNAAZUL RUC 20167217785 eae Seve fo) (anion sopcuewte — [i]t om SUBTOTAL ‘CIDWTD SESENTAY NUEVE o1/1O0 NUEVO SOLES ae ! TOTAL ue SISTEMA DE COMPRA ¥ VENTA Luege hacemos clic en el botén Vista Previar (ita wa) Y nos va a mostrar todos los productos vendidos al cliente: Fecha del Pedido 1 29/10/2013 Nombre de la Empresa: LOS SAUCES LAGUNA AZUL Ruc de la Empresa : 20167217785 Tipo Documenta : BOLETA Nro de Documento : 90000001 sorces----Datos del Cliente-----~--- Gadigo del cliente coooz Nombre Completo y DNI = royer Detalle del Pedido--- Codigo —- Descripcion Cantidad Precio Importe ROOOT Mouse a 8 8 0002 Teclado 2 sé 54 20003 Impresora © 84 54 0004 Camara Web a 32 32 R0005 Monitor 1 21 21 Subtotal: T¢v: Total a Pagal 169 SISTEMA DE COMPRA ¥ VENTA. Ventas Diarias: ‘ENTAS DFAS oeite BOI Be Hace 9107203 ¥ Importamos nuestras librerias: Inports System.Oata Imports System Date Sqilient ¥ Dentro del botén cerrarescribimos el siguiente cédigo: Private Sub autt Me.Close() End Sub SISTEMA DE COMPRA ¥ VENTA. Y _Escribimos el siguiente cédigo dentro del botén cons ultar: (ont) Private Sub Buttont_Click(8y¥val sender As System.Object, ByVal © As System, Wry Dix end Ax New Sq)Comand(“Spfae", CONEX) cad. CommandType = ComandType. StoredProcedure If Me, Textfoxl.Text = “" Then end Parameters adduithvalue("@ldCliente”, System.00nu!|.Value) else ond Parameters Addwithvalue("@idcliente™, Me.TextBoxd. Text) end Hf cad. Parameters Addwithvalue(“@ti~, Me.dtfi.value.Date) cmd. Parameters Adduithvalue(“@tf", Me.dtff.Value.Dete) Die da As New SqldstsAdepter(cad) Din dt As New OstaTable do. FAlL(at) Me DateGridiew!.DateSource = dt Cateh ex £8 Exception ‘MsgBox (ex. Message) End Try End Sub Y- Procedimiento almacenado para realizar consulta de tal fecha a fecha y con el cédigo delcliente: CREATE FROC SPFAC @apciTENTE VARCHAR(S0), @er oarerne, Ger oRTETDS as Best SELECT = PROM FRCTORA HERE IDCLIENTE-@IDCLIEWTE a0 (FECHA BETWEEN GFT AID GFE) Exo SISTEMA DE COMPRA ¥ VENTA ¥ Buscar Cente: (i Bicar Cherte BUSCAR CLIENTE BUSCAR POR NONBRE: (aba Imports System.Data Imports System.Data.sqiClient Public Class Guscar Cliente ‘Dim ESTADO As New Boolean Dim READER As SqlDataheader im contador_pate_guardar As Integer Private oDatasdapter As SqlbstaAdepter Private oDataTable As OstsTable Private oDataRow As Ostokow Private oComandsuilder As SqlCommandoullde~ Private PosFilaaet As Integer Dim filo as Integer = -2 Dim THPO As String = “* Dim € Ac Integer = 0 Dim pre As Double aba SISTEMA DECOMPRAY VENTA © Bento del evento Tenchanged dela capa de texto de buscar esoribimos el squlente chcigo: BUSCAR POR MOSBRE. > Teschanged TextBox] Teethanged Welvata Sob Newton tantthenged (Oye) sander 4 Sywtesstli ject, Ayal @ As Syetem,tuenticgs) Mardlan Taxten, Tentthanged 1 be sollstaTable Clear) If TextBaxt.Text © "> Then Me cOmtasdapter = fine Sqldetaadapter{"Select © From Cliente ubere tiontee Like'" & TextBox).Text & "” tse Me eiiatndapter = fess Sifetsidiapter{"Select " From Cliente, COMEX) ind a9 e .olatdlapiver F111 (Me oGetaTabie) Catch en Ax Eeception Sessagelion fore 5q]fommanaiturl lier te. oOataidanter) Datekdapter = New iqlostatdapter("Select * trom Cliente ORGtR OY TdChiente™, COWEX) epataTable © feew OetaTable ‘oOataddapter PELL (otataTable) DateinLeiesdOatasirce = ofetatanle Pie Outed Laviewt Ai LawuserTaaddRows Pie Detar LaViewt Al LowtiverTabe tetas, Labels. text = Tieestring Pin Outed idviewt Cetazaucce = wdeta Table: Uslnosore.Text = String-Foreat{"Total de Registros’ (8)", ofataTable, ows Count) End Su ¥ Dentan del botén Regresar al Chentes es cribimas ef siguiente cadiga ( Regeseieres Private tb futtom ie Clowe(} | © Dent del evento CeliMoweCoubleCick del DaiaGre view! excrbimos el sguiente obdiga: ET reaeview | Cottons + Private Sub OutaGrigviewd_cellnouseDoubleClick(Byval sender 5 Object, Eyval Tf e.Ronindex < @ Then Exbt Sub Clientes. TextBont Text = GataGedvient Itee(0, +. Routnden) Tae Clientes. Textfou?. text + OstalridView!.Itee(1, ¢,Rowindes).¥alee Clientes, Tenttoxd. text = Datadrigview!, Itee(2, #.Rowinden) Cientes.textboud. Text = DataGriovient.Ttee(7, ¢.Rouinden).. Teettart, Text + OstaGrieview! tree(4, 6 Rowinden) alee Tantiiond. Text = DataGridView! tten(S, +. Rowinden) Walon SISTEMA DE COMPRA Y VENTA Y BuscarProveedor: (Buscar Proveedorre BUSCAR PROVEEDOR toe BUSCAR POR NOMBRE: = ae Imports Systen.0ate Imports System. Oate.SqlChient Public Class Bvicar_Provecdor Dim ESTADO As New Boolean Dim READER As SalDetafeaser Die contador pata_guardar As Integer Private eOataAdapter As SqlDataAdapter Private eOatatable As DataTable Private Dataflow As Ostahow Private eComandéul der £5 SqlComandBuiléer Private Postilasct As Integer Pim fila As Integer = -1 Dim TIO As String « ~* Dim € As Integer = 0 Din pre As Double SISTEMA DECOMPRAY VENTA © Bento del evento Tenchanged dela capa de texto de buscar esoribimos el squlente chcigo: BUSCAR POR MOSBRE. > Teschanged TextBox] Teethanged Poivate Sub Textllonl_Textchangedtyial sender At thysten.BEIMEE, Eyal « As Systen,tuentings) Helen TextBox. Textthanged Ty e.obataTable.cleer() Hf Taxtilond, Texto °* Then ‘ha. ebatnAdapter + few ‘ujitetastepter(*tebact © Fras Pra a jar where tmprese ike" & Tewthord.Tet & “K*, CoWeK) Ne,oDataldepter « New Sqlnetatdanter("Select * From Proveedor”, COMEX) end If he oDataddapter. F111 (He adataTable) Eaten on Aa Exception sShon(“trror sl bwrcer” & che(a8) & em tessage) | © Greamos una funon para mostrar o cangar los datos e0 el DataGridView! deltormufario: Private Sb CongerOuragriai) Bla textougl Au Sting eewtoeg] = “ielect * frum Breweedor GHOER BY 1dProweedor* try ‘Comex. open{) Bie cmd As Kew Scitomment(testesgl, CORE) ‘Die an Ae tw et cenyen (cm) Dla Oe Ae tow Catatonia aeration) ne Daeniridvient Oataiource = ft ne. Mbhnombee.Text = String.Ferae("Tatal we Regtstros: (W)", #t.Rowt.Coumt) ‘Cm. Close() Catch on fa Exaagtcs Seaplon ex Message} ent End 508 | © Dent del formufarto load escribimas a! quien cédga: Private Sub tuscer_Proveedor_Losd(2yval sender as System.ob-ject, Bywal © As Systee.fventérgs) ComandBullder = liew Sq] camanc2u1 ide-(Re-eOutaAdapter } eDarakdaptar = lew SqiDatoidagter("Selact * From Prowedar ORDEN BY TdProvesdor™, COMER) DataTable = Wew Dota Table cOvtaadepter , Fill(oOetaTable) CataGriuviewt Detasource = cOstatable e.DataGeideiewl.ALlowserToaddtes = False Pe tatade Lilet ALLowiserTeeletekons = fais Labels. tant © Thasttring Fe Datatriitviewt DataSource = oOatetab! Ublnosbre,Text © String, Poramt (“Total End Sub Registresy (0)*, obate ble Rows Count} ¥ Dentan del botén Regresar al Chentes es cribimas ef siguiente cadiga Private tb futtom ie Clowe(} | © Bento del evento CeliMouseCouble Cick del DataGridView: excrbimos el siguiente obdiga: EE oneettien Cotton =) Frist Sub DateGridvied_cellcuiedoublecLick(eyval sender As cbject, ayval e 4 TY we foutnden ¢ 8 Then Exit 5 = DataGridvient.Dtem{z, 2.Rowindex) value Proveedires.TextBon. Text « OataGridutew!.ttem(3, ©.fowIndex).Value Praveedores. TextBoxes. Text = DstaGridview!..tee(4, a). wae Prueeedarts.TextBons. Text = DataGridviewt.tiee(5, a) ae Prarnedares. TestBon?. Text = Datatrictviawt. 11eR( a) vane Preeemdores. textSont. Tet = Datedridhvien!. ttm? value Praveedores ute? isePichert.Text = Detadridview!, tten(O, me closet) End Sub RaveEndex) Value SISTEMA DE COMPRA Y VENTA Buscar Articulo: Buscar Anicules vb BUSCAR PRODUCTO eee BUSCAR POR NOMBRE: Imports Systes.Data Imports Systes.0ata.SqlClient Public Clazs uscer_Articules Dim ESTADO Az New Boolean Dim READER As Sql0atoaeader Dim contador_pata_guardar Az Integer Private oOstasdapter As SqlDetaAdapter Private oDatatable As DataTable Private oOateRow Az Oetatow Private oComandBuilder As SqiCcmandBuilder Private PosFilact As Integer Dim file As Integer = -1 Die TIPO As String = Dim C as Integer = @ Dim pre As Double SISTEMA DECOMPRAY VENTA © Bento del evento Tenchanged dela capa de texto de buscar esoribimos el squlente chcigo: nscren one Pett Sub Tey ‘Pe aberoTabbe hear Eft TentBionl TextChanged(Syiel vender ax System.Object, Syvel © An System Corrtirgs) Handley Texto}. TextChenged fenton, Text «> Ma, SOaEMAMApRAr = Nis SalOutaldipter(*Halact * Pro AMELCULeS Where saskew bike'™ A Testcnd. Test & “W'*, COME) ee Ma, aataAdapter * New Sqi0etakiaptar( "Select * From Artioalan*, CERx) Then end af Me -ebmtaddapter FAL (Pe. otter abl Catch ox escageson.Show("Error al buscar" End Try Ent Subs As Eaception che(aa) A ex.meszage) | © Greamos una funon para mostrar o cangarlos datas en ef DataGridView! deltormufario: Private Sus CargurOutageta() Die cantonal As String Rextangl = “select * from deticulon ORGER BY Codigo" 1 COMEX.Ceen() Dm ond As Hew SxiCommand(textesq!, CONEX) ia da Ac Mew SalDarsedupter( cad) Dim a As Rew DataTable da. Finacer) he QateGridviewl Oatasource = dt Me. lbleonbre.Text « String.Pormet{“total de Repistron: (8}*, st.Aews.Count) OMEX.Clase() Catch x At Leceation Magia ex es sage} ft Try End Seth | © Dents del formufario load escribimas et squiente codigo: Pleat Tabs Formt_Aand(Qyvel vender da Syste. Giciect, SyVal @ Ae System. oentdegs) Hand cCemmarsshlder # Kew Sqifomandtivilter(Meobtatdanter} eOataadapter = few Sqlowtantarter("select * From Articulos OspER wr Codign”, CONEX) DataTable « Kew DataTacl= ‘eQataAdaoter.° 111 (opataTable} DataGridView! OataScurce ~ olataTable Me ButaGeidviaatl AE TodiearTodddlows = False Mie Rata itVisent AL londaeeTeOeleteBom ~ False abel). tent © Tinestring “Dim dt ds Rew Detetable he. QutaGriifviewi DataSource = obetatable Unloosbre.text = St-ing.Foreat("Total de fegitteon: End Sats + sOatatahle. Rows Count Dantas del botén Regresar al Articulo escribimar ef siguiente cidlga a Private tb futtom ie Clowe(} | © Bento del evento CeliMouseCouble Cick del DataGridView excnbimos el sgukente cédiga: Private Svo Oetagridviewt_cellMausedoubleclick(2/vl sender As Object, Mt e.fowindex ¢ @ Then Bult Sub Oat Lidl Thea(®, «- Ronin) Walon Resteviex) value Arttoulos,TextBow. Text = Datadridview! Tten(2, «.Keutnder), value Articulos Textooad,Text + Oatuiridwiew!.Jtea(3, ¢.Rowindex) valve NenChoset) fd Su | © Formifario Mend pinopaleste tomnutano es donde eatin todas tas opciones de lamar a todaslos formularDs y Tene el control de sequidad: Ti Mena Principal ob atime Registe: Ustad Repates Haromientar Ayu Ee Mewsinet La patusteipt CD timert | Denton de fa pestata sistema estén bos su mens | Simems | Regie Listede aportes Haramientar — fiyuca Dentin de is pestaAa registra estin los sub mend Regione | Listed Repomes fismamientas Ayuda Denia de Ia pestafia listado estin los sub mens: Sateme Fegtsu | Lidado | Repertes (lierte Histories Byule Provercicens Acheules | Dente de la pestata de eeportes extin los sumer: Sslema Regsbe isade [ Reporte Herervewias Ayude eres Bivins Arbcates inbiegasics Dente de Is pestaAs herramientas estin los sub mene: Sistema Regise Listads Rxpovtes awamientas | yuck Merwal de! Sieterms Eatculadars Dee Tet Blocuet del Satema Pains Wes | © Dents de la pestis ayuda extin los sub menkis Setems ayebo Linede Resene: evernaniae | duds | ACERCE TEL SLA ¥ Dente de Ia pestis heramientashayuns opdién donde dice biquearelsitems extaaprién me va a permbie tener una zeguadsd a en cazo of usuario tiene una cosa pendeme que haceren otralugar y porelip ef usuaro iendd que bloquearel ss ma por seguridad hasta que regrese y tendra que ponernuevamente su dawe para activar ef meni: Sern: Heapohig = toda) Papert] Heveetentes. | aac. Morwal de! Sistems Calculadarm bee. Let [Besaeecet setae Pagine veo | una verhecho clic ef usuario en lapestata bloquear el fommuino se verade exta forma donde todos los meni estin bioqueados solo ia caja de ‘ean donde ponermi dave sera desdioqueado: Una vez puesto la dave de seguridad ef usuario, presioramas|a teclaemer , o farmmulario se cambia de daeho y ce desbloquean los ments obseria: Listed Reporte Sutera Rag) SISTEMA DE COMPRA Y VENTA Primero tenemos que importar estas dos opciones: Option Explicit off Imports Microsoft .VisualBasie Y Dentro de la herramientaescribimos el siguiente cédiga Dtinert Private Sub Timera_Tick(Byval sender As System.ob 2 = Strings. RAght(Me.Text, Len(Me-Text) - 2) b = Strings. Left (Me, Text, 2) NesText = ab End Sub ¥ Dentro del formularios ioad escribimos el siguiente cédigo: Private Sub Menu Principal_oad(sy¥ Me stabela.visible = False Me. TXTBLOQUEAR.Visible = False Label2.Text » How End Sub Y Dentro del evento KeyPress de la caja detexto escribimes el siguiente eddigo: “a ENCUENTRA BLOQUEADO INGRESE SU CLAVE DE ACCESO Private Sub TXTBLOQUEAR_KeyPress(ByVol sender As Object, Byva Tf Me -TXTBLOQUEAR. Text = ToolStripStatustabel3.Text Then Ne-BackColor = Color.uhite Ne.MenuStrip1.Enabled = True he StetusStripi.Visible = True Ne. TETBLOQUEAR. Text = Ne.Labell Visible = False e-TXTBLOQUEAR. Visible = False End TF End Sub SISTEMA DE COMPRA ¥ VENTA Dentro de la pestafta ayuda ~ sub ment salir escr ibimos el siguiente cédigo: Ronee SoG ee eee aan | a ACERCA DEL USUARIO Private Sub SALIRTOOLStripMenuTtes CLick(SyWval sender As Syste Dis S = MegBox("Desen Cerrar”, Mgtoxstyle.Yede, ) if 5 = vbves Then End Else End tf End Sub Dentro de la pestafia herramientas ~ sub mend Doc Txt escribimos el siguiente cédigo: Sistema Registro Lstado Reporter | Horramientas | Ayuda cae een Private Sub DOCTXTToo1StriptienuTtes Click(Byval 2 “a pestaia doc texto sheLl("notepad.exe”, Appilinstyle.MorsalFocus) end Sub Dentro de la pestafa herramientas ~ sub ment Bloquae del Sistema eseribimos el siguiente cédigo: Sistema Registro Listado Reporter [ Harramientas | Ayuda Manual del Sistema Caleuladora Pagins Web SISTEMA DE COMPRA ¥ VENTA Private Sub BOQUEODESESTEMAToOIStript Me.MenuStrip! tnabled = False Me, StatusStripl.visible = False Me.label.Visible = True Ne. TXTBLOQUEAR. Visible = True Me.tackCelor = (olor.Red End Sub Dentro de la pestafia registro ~ sub mend Proveedores escribimos el siguiente cédigo: Sial| Rapes [Lae eS oie Private Sub CLIEWTESToolStrig Proveedores. Show0ialog() End Sub Y Dentro de la pestafia registro ~ sub meni Clientes escribimos el siguiente cé digs Sistema | Registro | Listado _Reportes Havremientes Ayuda Private Sub COMPRATeoIStrd (Clientes ‘ShowOialog() End Sub Dentro de la pestafia registro ~ sub mend Articulos escribimos el siguiente codigo: Listado Reportes Harramientas Ayuda SISTEMA DE COMPRA ¥ VENTA Private Sub PROVEEDORESToo! ‘ticulos, ShewOlaLoge) End Sub Dentro de la pestafia sistema ~ sub meni Compra escribimos el siguiente cédigo: Registro Listado Reportes Hamamientas Ayuda De ‘Venta Configurar lmpresera Private Sub PROVEEDORToo! compra, Show0dalog() End Sub Y Dentro de la pestafa sistema ~sub meni Venta escribimos el siguiente cédigo: [Scicen [Epa Compra Reportes Herramientas Ayude Private Sub CTUDADToc F -Show@Lelog() End Sub Dentro de la pestafa reportes— sub mend Ventas Dlarias escribimas el siguiente cédigo: Sistema Registro Listado | Reporte: | Harramientas Ayuda ‘Ventas Diasias Articulos Entregados SISTEMA DE COMPRA ¥ VENTA Private Sub VentesDLardasToolstri Ventss_Dlariss.Shewialog() End sub ¥ Dentro de la pestaita reportes — sub mend Articulos Entregados escribimos el siguiente cédige: Sistema Registro Listado | Reportes | Harremientes Ayuda Ventas Diaras Private Sub ArticulostatregadosToolstri Articulos_entregedos Showotalog() End Sub Dentro de la pestafta herramientas ~ sub mend Calculadora escribimos el siguiente codigo: Sioteme Regis itade Reporte | Haremientas | Ayuda Manual el tema oc. Tat Bloqueo del Sistema Paina Web Dentro de la pestaha herramientas ~ sub mend Pagina Web eseribimes el siguiente cédige: Sistema Registro Ustado Reportes | Hatramientas | Ayuda Menus del Sisters Coleuladore Dac. Tt Blequeo de! Sistema SISTEMA DE COMPRA Y VENTA Dentro de la pestafla ayuda ~ sub ment Acerca del Usuario eseribimes el siguiente cédigo: Sictema Registro ListadoReportes Herramientas [Ayuda "ACERCA DEL USUARIO | SAUIR Private Sub ACERCADELUSUARI ShowOialog. End Sub Dar Pa omit le] Koll de) inc 30POLit Ano Email: royerstudios@hotmail.com SISTEMA DE COMPRA ¥ VENTA. Y Imagen donde se muestran todos los nombres de los formularios en el explorador de soluciones: Solucion Facturacion’ l proyecto) a My Propect ACCA DE Mee BD op p.contig Bl Ariculosve a Ameuios_Entregados. ve Bl Barca: Aniculosvt ( Buscor Center El Bacar Cihemte Ingreso.vb (Bil buscar producto facture BE Buscor Producto Ingresov El Bescar Proveedor By Bexcer Proveedor Ingresevt Di Comprave 1M Conexion Bre 1B Generac EE Menu Principals 1B Proveedoresve Bl asuatione Biventas Hl Ventas, Dison

You might also like