private void setLDataBase(DataBase DB) { LDataBase = DB; }
public void CreateDataBase() { try { if (!verificarBaseDatos()) { DataBase DB = LDataBase; string strSQL = "Create Database Supermercado_Angel"; DB.ExecuteQuery(strSQL); DB = new DataBase(DB.StrServerName, "Supermercado_Angel", DB.StrUserId, DB.StrPassword); strSQL = "\n USE Supermercado_Angel" + "\n" + "\nCREATE TABLE Cliente(" + "\n id_cliente int IDENTITY(1,1) NOT NULL,"+ "\n Nombre varchar(50) NULL,"+ "\n)" + "\n CREATE TABLE Entradas(" + "\n id_entrada int NULL,"+ "\n Fecha date NOT NULL ,"+ "\n Usuario int NOT NULL,"+ "\n Cantidad int NULL,"+ "\n Articulo int NOT NULL,"+ "\n Descripcion nchar(10) NULL,"+ "\n Monto decimal(4, 2) NULL"+ "\n) " + "\n CREATE TABLE Inventario(" + "\n id_inventario int NULL,"+ "\n Articulo int NOT NULL,"+ "\n Cantidad int NOT NULL,"+ "\n Descripcion varchar(50) NULL"+ "\n)" + "\n CREATE TABLE Producto(" + "\n id_producto int IDENTITY(1,1) NOT NULL,"+ "\n Nombre varchar(50) NULL,"+ "\n Categoria varchar(50) NULL,"+ "\n Descripcion varchar(50) NULL,"+ "\n Precio_Unitario decimal(4, 2) NULL"+ "\n )"+ "\n CREATE TABLE Salidas(" + "\n id_salida int NULL,"+ "\n Usuario int NOT NULL,"+ "\n Cliente int NULL,"+ "\n Fecha date NOT NULL,"+ "\n Cantidad int NOT NULL,"+ "\n Articulo int NOT NULL,"+ "\n Descripcion varchar(50) NULL,"+ "\n Monto decimal(4, 2) NULL"+ "\n)" + "\n CREATE TABLE Usuario(" + "\n id_usuario int IDENTITY(1,1) NOT NULL,"+ "\n Nombre varchar(50) NULL,"+ "\n Foto image NULL,"+ "\n Contraseña varchar(100) NULL"+ "\n)"; DB.ExecuteQuery(strSQL); strSQL = "\n Alter Table Usuario" + "\n ADD CONSTRAINT PK_Usuario" + "\n Primary key (id_usuario)" + "\n Alter Table Cliente" + "\n ADD CONSTRAINT PK_Cliente" + "\n Primary key (id_cliente)" + "\n Alter Table Producto" + "\n ADD CONSTRAINT PK_Producto" + "\n Primary key (id_producto)" + "\n Alter Table Entradas" + "\n ADD CONSTRAINT FK_Usuario" + "\n FOREIGN key (Usuario)" + "\n REFERENCES Usuario(id_usuario)" + "\n Alter Table Salidas" + "\n ADD CONSTRAINT FK_UsuarioOut" + "\n FOREIGN key (Usuario)" + "\n REFERENCES Usuario(id_usuario)" + "\n Alter Table Salidas" + "\n ADD CONSTRAINT FK_ClienteOut" + "\n FOREIGN key (Cliente)" + "\n REFERENCES Cliente(id_cliente)" + "\n Alter Table Salidas" + "\n ADD CONSTRAINT FK_ProductoOut" + "\n FOREIGN key (Articulo)" + "\n REFERENCES Producto(id_producto)" + "\n Alter Table Entradas" + "\n ADD CONSTRAINT FK_ProductoOut2" + "\n FOREIGN key (Articulo)" + "\n REFERENCES Producto(id_producto)" + "\n Alter Table Inventario" + "\n ADD CONSTRAINT FK_ProductoOut3" + "\n FOREIGN key (Articulo)" + "\n REFERENCES Producto(id_producto)"; DB.ExecuteQuery(strSQL); strSQL = "\n Alter Table Entradas" + "\n ADD CONSTRAINT DF_Date" + "\n Default getdate() for Fecha" + "\n" + "\n Alter Table Salidas" + "\n ADD CONSTRAINT DF_Date2" + "\n Default getdate() for Fecha" + "\n "; DB.ExecuteQuery(strSQL); strSQL = "\n Create Procedure add_products" + "\n @id int," + "\n @name varchar(50)," + "\n @categoria int," + "\n @descripcion varchar(50)," + "\n @price decimal(4,2)" + "\n As" + "\n if (Select COUNT(*) From Producto where Nombre=@name)=0" + "\n Begin" + "\n insert into Producto values (@name,@categoria,@descripcion,@price)" + "\n Declare @cod_product int" + "\n Select @cod_product = id_producto from Producto where Nombre=@name--Sacamos el codigo del producto en inventario y lo agregamos a inventario" + "\n insert into Inventario values (@id,@cod_product,0,@descripcion)" + "\n End" + "\n ELSE" + "\n Begin" + "\n PRINT 'Ya existe un producto con ese nombre'" + "\n End"; DB.ExecuteQuery(strSQL); strSQL = "\n Create Procedure add_sale" + "\n @id int," + "\n @user int," + "\n @client int," + "\n @quantity int," + "\n @Article int," + "\n @comment varchar(50)," + "\n @total_sale decimal(4,2)" + "\n As" + "\n Declare @cant INT" + "\n select @cant = Cantidad from Inventario where Articulo = @Article" + "\n if (@cant>@quantity)" + "\n Begin" + "\n insert into Salidas Values (@id,@user,@client,default,@quantity,@Article,@comment,@total_sale)" + "\n END" + "\n ELSE" + "\n Begin" + "\n PRINT 'Cantidad pedida rebasa a la de stock'" + "\n END"; DB.ExecuteQuery(strSQL); strSQL = "\n Create Procedure add_buy" + "\n @id int," + "\n @user int," + "\n @quantity int," + "\n @Article int," + "\n @comment varchar(50)," + "\n @total_sale decimal(4,2)" + "\n As" + "\n Declare @cant INT" + "\n select @cant = Cantidad from Inventario where Articulo = @Article" + "\n if (Select COUNT(*) from Producto where id_producto=@Article)>0" + "\n Begin" + "\n insert into Entradas Values (@id,default,@user,@quantity,@Article,@comment,@total_sale)" + "\n update Inventario SET Cantidad = @cant + @quantity where Articulo=@Article" + "\n End" + "\n else" + "\n Begin" + "\n PRINT 'Cantidad pedida rebasa a la de stock'" + "\n End"; DB.ExecuteQuery(strSQL); strSQL = "\n Create Procedure add_client" + "\n @name varchar(50)" + "\n AS" + "\n if(select COUNT(*) from Usuario where Nombre=@name)=0" + "\n Begin" + "\n insert into Cliente values (@name)" + "\n End" + "\n ELSE" + "\n Begin" + "\n Print 'Ya hay un usuario con ese nombre'" + "\n End"; DB.ExecuteQuery(strSQL); strSQL = @" Alter Table Producto DROP COLUMN Categoria Alter Table Producto ADD Categoria int Create Table Categorias ( id_categoria int IDENTITY(1,1) not null, Nombre varchar(50) not null, Descripcion varchar(50) ) Alter Table Categorias ADD CONSTRAINT pk_categorias primary key(id_categoria) Alter Table Producto ADD CONSTRAINT fk_categorias FOREIGN KEY (Categoria) REFERENCES Categorias(id_categoria) "; DB.ExecuteQuery(strSQL); //Cargamos un usuario por defecto strSQL = @"insert into Usuario values ('Admin', 0xFFD8FFE000104A46494600010101006000600000FFE1003A4578696600004D4D002A00000008000351100001000000010100000051110004000000010000000051120004000000010000000000000000FFDB004300080606070605080707070909080A0C140D0C0B0B0C1912130F141D1A1F1E1D1A1C1C20242E2720222C231C1C2837292C30313434341F27393D38323C2E333432FFDB0043010909090C0B0C180D0D1832211C213232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232FFC000110800E100E103012200021101031101FFC4001F0000010501010101010100000000000000000102030405060708090A0BFFC400B5100002010303020403050504040000017D01020300041105122131410613516107227114328191A1082342B1C11552D1F02433627282090A161718191A25262728292A3435363738393A434445464748494A535455565758595A636465666768696A737475767778797A838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FAFFC4001F0100030101010101010101010000000000000102030405060708090A0BFFC400B51100020102040403040705040400010277000102031104052131061241510761711322328108144291A1B1C109233352F0156272D10A162434E125F11718191A262728292A35363738393A434445464748494A535455565758595A636465666768696A737475767778797A82838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002110311003F00F7FA28A2800A28A2800A28A2800A28A2800A29090A324E0557798B703814013348ABD4F3E82A3339EC00A868A007191CF5634DC93D4D1450019229C1D874634DA2802513B0EA01A956556EF83EF5568A00BB4556495978EA2AC2B07191400B45145001451450014514500145145001451450014514500145145001451450014D66083269490A327A0AAAEC5DB26800672E7269B4514005159DABEB9A7E876FE6DF4E1377DC8C72EFF41FD7A579E6ADF12351BA668F4D892CE2ECEC03C87F3E07E47EB5DD85CBB118AD60B4EEF638F138EA187D26F5ECB73D50F032781EB5525D574E80E26D42D233E8F3A8FE66BC2AEF52BEBF62D79793CF939FDE4848FCAAAD7B10E1ED3DFA9F723CA9E7BFC90FBD9EFB1EB1A5CC7116A564E7D16E10FF005AB8AC1D77290C3D41CD7CED535B5E5D59BEFB5B89A06F589CAFF2A73E1E56F72A7DEBFE08433D7F6A1F89F42515E47A5FC44D62C982DE6CBE87BF9836B8FA30FEA0D7A1E87E27D375F4C5ACBB67032D049C38FF0011EE2BC8C565988C32E692BAEE8F4F0D9850C4691767D99B34AAC54E41A4A2BCF3B8B492071EFDC53EA98254E455A460EB91400EA28A2800A28A2800A28A2800A28A2800A28A2800A28A2800A28A6C8DB109FCA802199F2DB47415151450015CDF8B3C570F87ADC4510596FE55CC719E883FBCDEDE83BD6A6B5AB43A26933DF4C33E58C2267EFB1E83FCFBD786DEDE4FA85ECD7774E5E695B7337F9EDDABD9CA72E58997B4A9F0AFC59E56678F7878F243E27F8212F2F2E750BA7B9BB99E699CE59D8FF9C0F6A828A2BEC9249591F26DB6EEC28A28A620A28A2800A7C52C904A92C32347221CABA1C107D41A65149AB8D3B6A8F58F0778CC6B1B74FD41956FC0F91FA0980FE4DEDDEBB2AF9DE391E291648D8A3A10CACA70411D08AF6BF09EBE35FD19667C0BA88F973A8FEF7F7BE87AFE7E95F239C65AA83F6D497BAF75DBFE01F519563DD65ECAA7C4BF1FF826ED3E37D8DEC7AD328AF08F64BB45470B6E4C7715250014514500145145001451450014514500145145001504E790BF8D4F55643991BEB400CA28A2803CBBE256AA6E354874C8DBF776CBBE400F5761FD171FF7D1AE1AAEEB178750D66F2EC9C89666653ED9E3F4C552AFD0B074150A11A7D97E3D4F86C5D675ABCA7E7F80514515D4730514514005145140051451400574DE04D58E9BE2586366C4177FB971DB27EE9FCF8FC4D7334E4768E45910ED752194FA1158D7A2AB5295397546B42ABA552351743E88A2A0B3B95BCB1B7BA5FBB344B20FC466A7AFCE9A69D99F789A6AE89216C498F5AB354C1C303E957290C28A28A0028A28A0028A28A0028A28A0028A28A002A99FBC7EB572A99FBC7EB400950DE4862B1B8947F044CDF9026A6A82F50CB617318EAF13AFE608AA85B995C52D9D8F9F074A281D28AFD28FCF828A28A0028A28A0028A28A0028A28A0028A28A00F71F094864F09E98C7B4017F2247F4AD9AC5F08A18FC25A629EF0EEFCC93FD6B6ABF3AC55BDBCEDDDFE67DE61EFEC617ECBF20AB83EE8FA553AB8BF747D2B036168A28A0028A28A0028A28A0028A28A0028A28A002AA4831237D6ADD4138F981F5A00868FAD145007806AB686C356BCB4231E4CCC83E80F1FA554AED7E246946D75A8F5045FDD5DA618FA3AF07F318FC8D7155FA1E0EBAAF42351755F8F53E171745D1AD28766145145749CE14514500145145001451450014AAACEC15412CC7000EE692BA2F04E94754F135BEE5CC36DFBF90FD3EE8FC5B1FAD655AAAA34E5525B246B4693AB5141753D82C2D85969D6B683A411247F9002AC51457E7326E4EECFBC4925642819207A9AB955A11993E9CD59A430A28A2800A28A2800A28A2800A28A2800A28A2800A648BB908EFD453E8A00A54549326D6C8E86A3A00CCF1068F1EBBA3CD64E42B9F9A273FC0E3A1FE87D89AF0DB9B69ACEE64B6B88DA39A262AE8DD41AFA16B94F18784535E8BED769B53508D7033C0947A1F7F43F87D3DBCA33158797B2A9F0BFC1FF0091E46698075E3ED29FC4BF1479051525C5BCD6B7124171134534676BA38C106A3AFB04D35747CAB4D3B30A28A298828A28A0028A295559D82AA966638000C9269002A9660AA096270001924D7B3F83BC3FFD83A38132817971879BFD9F45FC3F99358FE0CF05369EE9A9EA89FE92066180FF00CB2FF69BFDAF6EDF5E9DD57C9E73992ABFB8A4FDD5BBEE7D3E558074BF7D516AF65D828A29D1A6F6C76EF5E01ED93C2B84CFAD494514005145140051451400514514005145140051451400514514008CA1948355594A360D5BA8A629B70796ED8A00AF4514500646B9E1BD375F8B177162651849E3E1D7F1EE3D8D79CEADF0F758B0667B40B7D08E863E1C7D54FF004CD7AED15E861333C461BDD8BBAECCE1C4E5F4311AC959F747CF334135B49E5CF149138FE1914A9FC8D475F43CB0C53A6C9A24917FBAEA187EB59B2786B4390E5B48B2CFB42A3F957B10E2185BDF87DCCF2A7914AFEE4FEF478553A34795C2468CEE7A2A8C93F857B927863424391A459FE3083FCEB460B5B7B55DB6F6F142BE91A051FA539F10C2DEE41FCDFF00C3847229DFDE9FE078FE97E05D6F522ACF07D9213D64B8F94E3D97AFF2FAD7A2E81E10D3741C4A8A67BBC733C8391FEE8FE1FE7EF5D0515E462F35C462572B768F647A986CB6861DF32577DD8514515E69DE28049C0EA6AD22045C7E751C0547FBC7D6A6A0028A28A0028A28A0028A28A0028A28A0028A28A0028A28A0028A09C0C9AAD2485CE07DDA007493765FCEA1A28A0028A2B075AF18691A2968E59BCFB91FF2C20C3303EE7A0FC79AD2951A9565CB4D5D9152AC29479A6EC8DEA2BCBA6F89DA8B5DABC3636C96E0F31B92CC7FE05C7F2AE834EF88FA45D00B789359C87AEE1BD3F31CFE6057754CA7174E3CCE17F4D4E3A799E1672E552B7AE87634552B4D634DBE1FE8B7F6D37B24A33F975ABD83E86BCF946517692B1DD19292BC5DC4A29769F43F9554BAD4AC6C97375796F07FD74942FF00334A3172768AB836A2AECB545729A87C42D0ECC32C12497920ED12E17FEFA38FD335CDFF00C2D0BFFB66FF00ECFB7FB37FCF2DEDBBFEFAE9FA57A14B2AC5D55750B7AE9F99C55732C2D37672FBB53D3E8AE7B46F1A691AC95896636D707810CF8049F63D0FF3F6AE86B8EAD1A9465CB51599D54EAC2AC79A0EE82A68E62386E47AD434564685DEBD28AAD1C850E0FDDAB008232280168A28A0028A28A0028A28A0028A28A0028A2A199F1F28FC680192C9B8E07DD1FAD47451400556BFD42D74CB47BABC9961853AB377F603B9F6A8B57D5ED344D3DEF2F1F08BC2A8FBCEDD947BD78C6BBAFDEEBF7A67B96DB1AFFAA854FCB18F6F7F53DEBD3CBB2D9E2E5CCF48AEBFA23CEC76610C2AB2D64FA7F99B5E22F1EDF6A85ADEC0BD9D99E320E247FA91D07B0FCCD7214515F65430F4B0F0E4A6AC8F94AD5EA5797354770A28A2B7310A9239E687FD54D227FBAC4547452693DC69B5B12BDD5C4A3124F2B8F46726A2A28A124B606DBDC28A28A620AEAFC3DE3ABFD20A41765AEECC71B58FCE83FD927F91FD2B94A2B1AF87A75E1C9515D1B51AF528CB9A9BB33DFF004ED4ECF56B35BAB2996589B8E3AA9F423B1AB75E0FA26B979A0DF0B9B47E0F12444FCB20F43FE3DABD9F45D6AD35DD396EED5BDA48CFDE8DBD0FF9E6BE3731CB27847CD1D60FAF6F53EAF01984714B95E925D3FC8D1A9229361C1FBA6A3A2BCB3D12ED150C2FFC07F0A9A800A28A2800A28A2800A28A28011DB6A9354C924E4F5352CED96DBE951500151DC5C456B6F25C4EE2386252CEC7A002A4AF37F891AF1691345B77F957125C91DCF555FEBF88F4AEAC161658AACA9AF9FA1CD8BC4C70F49D47F2F5397F1378867F10EA6D3B6E4B68F2B0444FDD5F53EE7BFF00F5AB168A2BEFA9538D2828415923E26A549549B9CDDDB0A28A2B42028A28A0028A28A0028A28A0028A28A0028A28A002B5BC3DAEDC787F534BA849689BE59A2CF122FF0088EC7FFAF59345454A71A90709ABA65D39CA9C94E2ECD1F425A5DC17F6715D5B38786550C8DEA2A6AF31F873AF182EDB469DFF0075365E024FDD7EEBF88FD47BD7A757C163B092C2D674DEDD3D0FB5C1E2562692A8B7EBEA1D0E6ADA36F5CFE7552A485B0F8EC6B8CEA2CD14514005145140052138049ED4B51CC711E3D4D0056272727BD14514015B51BD8F4DD36E2F65FB90465C8F5C741F89E2BC12EAE65BCBB9AEA76DD2CAE5DCFA926BD33E266A060D1EDAC14E1AE64DCDFEEA63FA95FCABCB6BEBB21C3F251755EF2FC97FC13E5F3AAFCD55525B47F361451457BC78A145145001451450014514500145145001451450014514500145145003E19648268E6898A491B07461D883906BDEB48D45356D22D6FE3C013206651FC2DD187E0722BC0ABD37E18EA064B1BCD39CF30B89507B3707F503F3AF0F3DC3A9D05556F1FC9FF48F6725AFC959D37B4BF3477B47439A28AF8F3EA4B8A77283EB4B514072847A1A96800A28A2800A8273F301ED53D5698FEF3E828023A28A2803C93E23DD99FC4FE406CADBC0A98F4272C7F98AE42BDCAF3C2DA26A17725D5D582CB3C841773238CE063B1F41507FC213E1CFFA05A7FDFC7FFE2ABE9F0B9D61E8D18D3E57A2F2FF0033E77139457AD5A553996AFCFF00C8F14A2BDAFF00E109F0E7FD02D3FEFE3FFF001547FC213E1CFF00A05A7FDFC7FF00E2AB7FF5830FFCB2FC3FCCC7FB0EBFF32FC7FC8F14A2BDAFFE109F0E7FD02D3FEFE3FF00F1547FC213E1CFFA05A7FDFC7FFE2A8FF5830FFCB2FC3FCC3FB0EBFF0032FC7FC8F14A2BDAFF00E109F0E7FD02D3FEFE3FFF001547FC213E1CFF00A05A7FDFC7FF00E2A8FF005830FF00CB2FC3FCC3FB0EBFF32FC7FC8F14A2BDAFFE109F0E7FD02D3FEFE3FF00F1547FC213E1CFFA05A7FDFC7FFE2A8FF5830FFCB2FC3FCC3FB0EBFF0032FC7FC8F14A2BDAFF00E109F0E7FD02D3FEFE3FFF001547FC213E1CFF00A05A7FDFC7FF00E2A8FF005830FF00CB2FC3FCC3FB0EBFF32FC7FC8F14A2BDAFFE109F0E7FD02D3FEFE3FF00F1547FC213E1CFFA05A7FDFC7FFE2A8FF5830FFCB2FC3FCC3FB0EBFF0032FC7FC8F14A2BDAFF00E109F0E7FD02D3FEFE3FFF001547FC213E1CFF00A05A7FDFC7FF00E2A8FF005830FF00CB2FC3FCC3FB0EBFF32FC7FC8F14A2BDAFFE109F0E7FD02D3FEFE3FF00F1547FC213E1CFFA05A7FDFC7FFE2A8FF5830FFCB2FC3FCC3FB0EBFF0032FC7FC8F14AEA3E1F5DFD9BC5B0A76B88DE23F96E1FAA8AF43FF8427C39FF0040B4FF00BF8FFF00C554D6BE13D0ECAEA3B9B6D3D639A26DC8E247383F89AC7139DE1EB51953E57AA6BA7F99B61F28AF4AAC6A732D1F9FF91B3451457CB9F444B01F9C8F51562AAC3FEB455AA0028A28A002AACBFEB5AAD55597FD6B500328A28A0028A28A0028A28A0028A28A0028A28A0028A28A0028A28A0028A28A0028A28A0028A28A0028A28A0028A28A00747FEB17EB56EAA47FEB17EB56E800A28A2800AAB2FF00AD6A28A006514514005145140051451400514514005145140051451400514514005145140051451400514514005145140051451400F8FF00D62D5AA28A0028A28A00FFD90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ,'123456')"; DB.ExecuteQuery(strSQL); //Agregamos la columna Precio_Compra que habiamos olvidado strSQL = @"Alter Table Producto ADD Precio_Compra decimal(4,2)"; DB.ExecuteQuery(strSQL); } } catch (SqlException ex)//Manejamos las exepciones SQL(Lado del Servidor) { StringBuilder errorMessages = new StringBuilder(); for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Mensaje: " + ex.Errors[i].Message + "\n" + "Numero de Linea: " + ex.Errors[i].LineNumber + "\n" + "Fuente: " + ex.Errors[i].Source + "\n" + "Procedimiento: " + ex.Errors[i].Procedure + "\n"); } MessageBox.Show(errorMessages.ToString(), "Error del Servidor", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception e) { MessageBox.Show(e.ToString(), "Error del Cliente", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public BunisessDataBase(DataBase DBL) { setLDataBase(DBL); }