-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbdd.sql
More file actions
700 lines (662 loc) · 22.1 KB
/
bdd.sql
File metadata and controls
700 lines (662 loc) · 22.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
CREATE TABLE [dbo].[arearps](
[idarearp] [int] IDENTITY(1,1) NOT NULL,
[arearp] [varchar](20) NOT NULL,
CONSTRAINT [PK_arearps] PRIMARY KEY CLUSTERED
(
[idarearp] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[cancelaciones] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[cancelaciones](
[idcan] [int] IDENTITY(1,1) NOT NULL,
[iddoc] [int] NOT NULL,
[comentarios] [varchar](200) NULL,
[fecha] [datetime] NOT NULL,
CONSTRAINT [PK_cancelaciones] PRIMARY KEY CLUSTERED
(
[idcan] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[carpetas] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[carpetas](
[idcarpeta] [int] IDENTITY(1,1) NOT NULL,
[carpeta] [varchar](20) NOT NULL,
CONSTRAINT [PK_carpetas] PRIMARY KEY CLUSTERED
(
[idcarpeta] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[documentos] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[documentos](
[iddoc] [int] IDENTITY(1,1) NOT NULL,
[codigo] [varchar](50) NOT NULL,
[doc] [varchar](100) NOT NULL,
[idpersonal] [int] NOT NULL,
[comentarios] [varchar](200) NOT NULL,
[autorizo] [varchar](100) NOT NULL,
[idrama] [int] NOT NULL,
[idcarpeta] [int] NOT NULL,
[activo] [int] NOT NULL,
CONSTRAINT [PK_documentos] PRIMARY KEY CLUSTERED
(
[iddoc] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[historial] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[historial](
[idhist] [int] IDENTITY(1,1) NOT NULL,
[iddoc] [int] NOT NULL,
[fecha] [datetime] NOT NULL,
[comentarios] [varchar](200) NOT NULL,
CONSTRAINT [PK_historial] PRIMARY KEY CLUSTERED
(
[idhist] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[mos] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mos](
[idmo] [int] IDENTITY(1,1) NOT NULL,
[mo] [varchar](15) NOT NULL,
CONSTRAINT [PK_mos] PRIMARY KEY CLUSTERED
(
[idmo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[personales] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[personales](
[idpersonal] [int] IDENTITY(1,1) NOT NULL,
[nombre] [varchar](100) NOT NULL,
[idpuesto] [int] NULL,
[idmo] [int] NULL,
[idarearp] [int] NULL,
CONSTRAINT [PK_personales] PRIMARY KEY CLUSTERED
(
[idpersonal] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[puestos] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[puestos](
[idpuesto] [int] IDENTITY(1,1) NOT NULL,
[puesto] [varchar](30) NOT NULL,
CONSTRAINT [PK_puestos] PRIMARY KEY CLUSTERED
(
[idpuesto] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[ramas] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ramas](
[idrama] [int] IDENTITY(1,1) NOT NULL,
[rama] [varchar](50) NOT NULL,
CONSTRAINT [PK_ramas] PRIMARY KEY CLUSTERED
(
[idrama] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[cancelaciones] WITH CHECK ADD CONSTRAINT [FK_cancelaciones_documentos] FOREIGN KEY([iddoc])
REFERENCES [dbo].[documentos] ([iddoc])
GO
ALTER TABLE [dbo].[cancelaciones] CHECK CONSTRAINT [FK_cancelaciones_documentos]
GO
ALTER TABLE [dbo].[documentos] WITH CHECK ADD CONSTRAINT [FK_documentos_carpetas] FOREIGN KEY([idcarpeta])
REFERENCES [dbo].[carpetas] ([idcarpeta])
GO
ALTER TABLE [dbo].[documentos] CHECK CONSTRAINT [FK_documentos_carpetas]
GO
ALTER TABLE [dbo].[documentos] WITH CHECK ADD CONSTRAINT [FK_documentos_personales] FOREIGN KEY([idpersonal])
REFERENCES [dbo].[personales] ([idpersonal])
GO
ALTER TABLE [dbo].[documentos] CHECK CONSTRAINT [FK_documentos_personales]
GO
ALTER TABLE [dbo].[documentos] WITH CHECK ADD CONSTRAINT [FK_documentos_ramas] FOREIGN KEY([idrama])
REFERENCES [dbo].[ramas] ([idrama])
GO
ALTER TABLE [dbo].[documentos] CHECK CONSTRAINT [FK_documentos_ramas]
GO
ALTER TABLE [dbo].[historial] WITH CHECK ADD CONSTRAINT [FK_historial_documentos] FOREIGN KEY([iddoc])
REFERENCES [dbo].[documentos] ([iddoc])
GO
ALTER TABLE [dbo].[historial] CHECK CONSTRAINT [FK_historial_documentos]
GO
ALTER TABLE [dbo].[personales] WITH CHECK ADD CONSTRAINT [FK_personales_arearps] FOREIGN KEY([idarearp])
REFERENCES [dbo].[arearps] ([idarearp])
GO
ALTER TABLE [dbo].[personales] CHECK CONSTRAINT [FK_personales_arearps]
GO
ALTER TABLE [dbo].[personales] WITH CHECK ADD CONSTRAINT [FK_personales_mos] FOREIGN KEY([idmo])
REFERENCES [dbo].[mos] ([idmo])
GO
ALTER TABLE [dbo].[personales] CHECK CONSTRAINT [FK_personales_mos]
GO
ALTER TABLE [dbo].[personales] WITH CHECK ADD CONSTRAINT [FK_personales_puestos] FOREIGN KEY([idpuesto])
REFERENCES [dbo].[puestos] ([idpuesto])
GO
ALTER TABLE [dbo].[personales] CHECK CONSTRAINT [FK_personales_puestos]
GO
/****** Object: StoredProcedure [dbo].[actDoc] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[actDoc]
-- Add the parameters for the stored procedure here
@p0 int,
@p1 varchar(50),
@p2 varchar(100),
@p3 varchar(100),
@p4 varchar(200),
@p5 varchar(100),
@p6 varchar(50),
@p7 varchar(20)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
declare @per int = (select personales.idpersonal from personales where personales.nombre = @p3)
declare @ram int = (select ramas.idrama from ramas where ramas.rama = @p6)
declare @car int = (select carpetas.idcarpeta from carpetas where carpetas.carpeta = @p7)
UPDATE documentos SET
codigo = @p1, doc = @p2, idpersonal = @per, comentarios = @p4, autorizo = @p5, idrama = @ram, idcarpeta = @car, activo = 1
where documentos.iddoc = @p0
insert into historial (iddoc, fecha, comentarios) values (@p0, CURRENT_TIMESTAMP, @p4)
END
GO
/****** Object: StoredProcedure [dbo].[buscarCodigo] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[buscarCodigo]
-- Add the parameters for the stored procedure here
@p1 varchar(100)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
select documentos.iddoc from documentos where documentos.codigo = @p1
END
GO
/****** Object: StoredProcedure [dbo].[buscarNombre] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[buscarNombre]
-- Add the parameters for the stored procedure here
@p1 varchar(100)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
select documentos.iddoc from documentos where documentos.doc = @p1
END
GO
/****** Object: StoredProcedure [dbo].[habDoc] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[habDoc]
-- Add the parameters for the stored procedure here
@p1 int,
@p2 varchar(200)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
update documentos set activo = 1 where documentos.iddoc = @p1
insert into historial(iddoc, fecha, comentarios) values (@p1, CURRENT_TIMESTAMP, @p2)
END
GO
/****** Object: StoredProcedure [dbo].[regArearp] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[regArearp]
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
insert into arearps (arearp) values ('Quebalix 1')
insert into arearps (arearp) values ('Quebalix 2')
insert into arearps (arearp) values ('Quebalix 3')
insert into arearps (arearp) values ('Quebalix 4')
insert into arearps (arearp) values ('Comunicaciones')
insert into arearps (arearp) values ('C. Herramientas')
insert into arearps (arearp) values ('U. Ligeras')
insert into arearps (arearp) values ('Oficinas')
END
GO
/****** Object: StoredProcedure [dbo].[regCan] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[regCan]
-- Add the parameters for the stored procedure here
@p1 int,
@p2 varchar(200)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
update documentos set activo = 0 where documentos.iddoc = @p1
insert into cancelaciones (iddoc, fecha, comentarios) values (@p1, CURRENT_TIMESTAMP, @p2)
insert into historial(iddoc, fecha, comentarios) values (@p1, CURRENT_TIMESTAMP, @p2)
END
GO
/****** Object: StoredProcedure [dbo].[regCarpetas] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[regCarpetas]
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
INSERT INTO carpetas (carpeta)VALUES('Formatos')
INSERT INTO carpetas (carpeta)VALUES('Procedimientos')
INSERT INTO carpetas (carpeta)VALUES('Instructivos')
INSERT INTO carpetas (carpeta)VALUES('Ayuda visual')
END
GO
/****** Object: StoredProcedure [dbo].[regDoc] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[regDoc]
-- Add the parameters for the stored procedure here
@p1 varchar(50),
@p2 varchar(100),
@p3 varchar(100),
@p4 varchar(200),
@p5 varchar(100),
@p6 varchar(50),
@p7 varchar(20)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
declare @per int = (select personales.idpersonal from personales where personales.nombre = @p3)
declare @ram int = (select ramas.idrama from ramas where ramas.rama = @p6)
declare @car int = (select carpetas.idcarpeta from carpetas where carpetas.carpeta = @p7)
insert into documentos (codigo, doc, idpersonal, comentarios, autorizo, idrama, idcarpeta, activo)
values (@p1, @p2, @per, @p4, @p5, @ram, @car, 1)
declare @idoc int = (select top (1) documentos.iddoc from documentos where documentos.codigo = @p1)
insert into historial (iddoc, fecha, comentarios) values (@idoc, CURRENT_TIMESTAMP, @p4)
END
GO
/****** Object: StoredProcedure [dbo].[regHis] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[regHis]
-- Add the parameters for the stored procedure here
@p1 int,
@p2 varchar(200)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
insert into historial (iddoc, fecha, comentarios) values (@p1, CURRENT_TIMESTAMP, @p2)
END
GO
/****** Object: StoredProcedure [dbo].[regMos] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[regMos]
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
INSERT INTO mos (mo)VALUES('Mantenimiento')
INSERT INTO mos (mo)VALUES('Operacion')
END
GO
/****** Object: StoredProcedure [dbo].[regPers] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[regPers]
-- Add the parameters for the stored procedure here
@p1 varchar(100),
@p2 varchar(30),
@p3 varchar(15),
@p4 varchar(20)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
declare @pues int = (select puestos.idpuesto from puestos where puestos.puesto = @p2)
declare @mu int = (select mos.idmo from mos where mos.mo = @p3)
declare @arp int = (select arearps.idarearp from arearps where arearps.arearp = @p4)
insert into personales (nombre, idpuesto, idmo, idarearp) values (@p1, @pues, @mu, @arp)
END
GO
/****** Object: StoredProcedure [dbo].[regPuestos] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[regPuestos]
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
INSERT INTO puestos (puesto)VALUES('Gerente')
INSERT INTO puestos (puesto)VALUES('Superintendente')
INSERT INTO puestos (puesto)VALUES('Jefe')
INSERT INTO puestos (puesto)VALUES('Supervisor')
INSERT INTO puestos (puesto)VALUES('Operador')
END
GO
/****** Object: StoredProcedure [dbo].[regRamas] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[regRamas]
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
INSERT INTO ramas (rama) VALUES ('Quebalix 1 - MTTO')
INSERT INTO ramas (rama) VALUES ('Quebalix 2 - MTTO')
INSERT INTO ramas (rama) VALUES ('Quebalix 3 - MTTO')
INSERT INTO ramas (rama) VALUES ('Quebalix 4 - MTTO')
INSERT INTO ramas (rama) VALUES ('Quebalix-Generales - MTTO')
INSERT INTO ramas (rama) VALUES ('Quebalix 1 - OP')
INSERT INTO ramas (rama) VALUES ('Quebalix 2 - OP')
INSERT INTO ramas (rama) VALUES ('Quebalix 3 - OP')
INSERT INTO ramas (rama) VALUES ('Quebalix 4 - OP')
INSERT INTO ramas (rama) VALUES ('Quebalix-Generales - OP')
INSERT INTO ramas (rama) VALUES ('Comunicaciones')
INSERT INTO ramas (rama) VALUES ('C. Herramientas')
INSERT INTO ramas (rama) VALUES ('U. Ligeras')
INSERT INTO ramas (rama) VALUES ('Oficinas')
END
GO
/****** Object: StoredProcedure [dbo].[validarDatos] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[validarDatos]
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
select count (ramas.idrama) from ramas
END
GO
/****** Object: StoredProcedure [dbo].[verCancelados] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[verCancelados]
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT cancelaciones.fecha, documentos.codigo, documentos.doc, cancelaciones.comentarios
FROM cancelaciones INNER JOIN
documentos ON cancelaciones.iddoc = documentos.iddoc
END
GO
/****** Object: StoredProcedure [dbo].[verDoc] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[verDoc]
-- Add the parameters for the stored procedure here
@p1 int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT documentos.iddoc, documentos.codigo, documentos.doc, personales.nombre, documentos.comentarios, documentos.autorizo, ramas.rama, carpetas.carpeta
FROM documentos INNER JOIN
personales ON documentos.idpersonal = personales.idpersonal INNER JOIN
ramas ON documentos.idrama = ramas.idrama INNER JOIN
carpetas ON documentos.idcarpeta = carpetas.idcarpeta
where documentos.iddoc = @p1
END
GO
/****** Object: StoredProcedure [dbo].[verDocs] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[verDocs]
-- Add the parameters for the stored procedure here
@p1 varchar(50),
@p2 varchar(20)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
declare @r int = (select ramas.idrama from ramas where ramas.rama = @p1)
declare @c int = (select carpetas.idcarpeta from carpetas where carpetas.carpeta = @p2)
select documentos.iddoc, documentos.codigo, documentos.doc from documentos where documentos.idrama = @r and documentos.idcarpeta = @c and documentos.activo = 1
END
GO
/****** Object: StoredProcedure [dbo].[verHist] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[verHist]
-- Add the parameters for the stored procedure here
@p1 int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
select historial.fecha, historial.comentarios from historial where historial.iddoc = @p1
END
GO
/****** Object: StoredProcedure [dbo].[verRevs] Script Date: 20/02/2020 01:11:22 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: emmanuel chavez
-- Create date:
-- Description:
-- =============================================
CREATE PROCEDURE [dbo].[verRevs]
-- Add the parameters for the stored procedure here
@p1 int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
select top (2) historial.fecha from historial where historial.iddoc = @p1 order by fecha desc
END
GO