-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeleteProduct.cs
103 lines (94 loc) · 3.39 KB
/
deleteProduct.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MundoMusical;
namespace MundoMusical.PRODUCT
{
public partial class deleteProduct : updateProduct
{
public deleteProduct()
{
InitializeComponent();
this.Text = "Eliminar Producto";
this.KeyPreview = true;
this.KeyPress += (s, a) => { if (a.KeyChar == (char)Keys.Enter) this.onAccept(); };
}
public deleteProduct(midformProduct origen)
{
InitializeComponent();
this.Text = "Eliminar Producto";
this.origen = origen;
this.origen.deletebtn.Enabled = false;
this.FormClosed += (x, y) => { this.origen.deletebtn.Enabled = true; };
this.KeyPreview = true;
this.KeyPress += (s, a) => { if (a.KeyChar == (char)Keys.Enter) this.onAccept(); };
this.stopBounds();
}
private void deleteProduct_Load(object sender, EventArgs e)
{
this.ActiveControl = this.txt1;
}
protected override void onAccept()
{
if(genericDefinitions.ask("Desea eliminar Producto con ID: " + this.prod.idproducto + "?", "Confirmacion de seguridad"))
{
if (db.deleteproduct(this.prod))
{
if (this.cbnotifica.Checked)
{
genericDefinitions.ok("Producto eliminado", "Echo");
}
this.onCancel();
}
}
else
{
this.onCancel();
}
}
protected override void setAtribs()
{
this.controls = new List<Control>() { this.txt1, this.txt2, this.txt3, this.cb1, this.txt4 };
this.tboxes = new List<TextBox>() { this.txt1, this.txt2, this.txt3, this.txt4 };
this.txt1.Enabled = false;
this.txt2.Enabled = false;
this.txt3.Enabled = false;
this.txt4.Enabled = false;
this.cb1.Enabled = false;
this.txtcosto.Enabled = false;
this.cbganancia.Enabled = false;
for (int x = 0; x < 101; ++x)
{
this.cbganancia.Items.Add(x.ToString() + "%");
}
this.baccept.Click += (x, y) => { this.onAccept(); };
this.bcancel.Click += (x, y) => { this.onCancel(); };
}
protected override void onshown()
{
if (!DesignMode)
{
productInternals pdi = new productInternals(this);
pdi.ShowDialog();
if (this.db.productisondetalles(this.idproduct))
{
genericDefinitions.dangerInfo("No se puede eliminar este producto, contacte al administrador!.", "Advertencia");
this.onCancel();
}
if (this.idproduct == -1)
this.Close();
else
{
this.getdata();
this.txt1.Focus();
}
}
}
}
}