-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaddPayMode.cs
More file actions
147 lines (128 loc) · 4.32 KB
/
addPayMode.cs
File metadata and controls
147 lines (128 loc) · 4.32 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
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.DB;
using MundoMusical.CUSTOM_CONTROLS;
namespace MundoMusical.PAYMODE
{
public partial class addPayMode : XBASE.paymodeBase
{
protected dbop db;
protected modo_pago modo;
protected Central2 central;
public addPayMode()
{
InitializeComponent();
this.Text = "Agregar Modo de pago";
this.db = new dbop();
this.modo = new modo_pago();
behaviorDefinitions.txtUPPER(this.txtnombre);
this.txtnombre.KeyPress += (sender, args) =>
{
if(args.KeyChar == (char)Keys.Enter && this.txtnombre.Text != "")
{
this.rtb.Focus();
}
};
this.rtb.PreviewKeyDown += (sender, args) =>
{
if (this.rtb.Text.Trim() != "" && args.KeyCode == Keys.F1)
{
this.onaccept();
}
};
this.bcancel.Click += (x, y) => { this.oncancel(); };
this.baccept.Click += (x, y) => { this.onaccept(); };
}
public addPayMode(Central2 central)
{
InitializeComponent();
this.central = central;
this.Text = "Agregar Modo de pago";
this.db = new dbop();
this.modo = new modo_pago();
behaviorDefinitions.txtUPPER(this.txtnombre);
this.txtnombre.KeyPress += (sender, args) =>
{
if (args.KeyChar == (char)Keys.Enter && this.txtnombre.Text != "")
{
this.rtb.Focus();
}
};
this.rtb.PreviewKeyDown += (sender, args) =>
{
if (this.rtb.Text.Trim() != "" && args.KeyCode == Keys.F1)
{
this.onaccept();
}
};
this.bcancel.Click += (x, y) => { this.oncancel(); };
this.baccept.Click += (x, y) => { this.onaccept(); };
this.FormClosed += (x, y) =>
{
this.onclosed();
};
this.stopBounds();
}
protected virtual void onclosed()
{
this.central.addpay = null;
}
protected virtual void oncancel()
{
this.clear();
}
protected virtual void onaccept()
{
if (this.validatedata())
{
if (this.db.existmodopago(this.modo.nombre))
{
genericDefinitions.error("Este modo de pago ya existe", "Error");
this.txtnombre.SelectionStart = this.txtnombre.Text.Length;
this.txtnombre.Focus();
}
else
{
if (this.db.insertmodopago(this.modo))
{
genericDefinitions.ok("Se ha dado de alta el modo de pago", "Echo");
this.clear();
}
}
}
else
{
genericDefinitions.dangerInfo("Llene todos los campos.", "Advertencia");
this.txtnombre.SelectionStart=this.txtnombre.Text.Length;
this.txtnombre.Focus();
}
}
private void clear()
{
this.rtb.Text = "";
this.txtnombre.Text = "";
this.txtnombre.Focus();
}
protected bool validatedata()
{
if (this.txtnombre.Text.Trim() != "" && this.rtb.Text.Trim() != "")
{
this.modo.nombre = this.txtnombre.Text;
this.modo.otros_detalles = this.rtb.Text.Trim();
return true;
}
return false;
}
private void addPayMode_Load(object sender, EventArgs e)
{
this.ActiveControl = this.txtnombre;
}
}
}