-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConsManuAr.aspx.cs
157 lines (131 loc) · 4.91 KB
/
ConsManuAr.aspx.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
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Text;
namespace SlnArCond
{
public partial class ConsManuAr : System.Web.UI.Page
{
//string teste;
int Codigo;
protected void Page_Load(object sender, EventArgs e)
{
List<pFuncionario> Lp = Session["Login"] as List<pFuncionario>;
if (Lp == null)
{
Response.Redirect("Login.aspx");
}
else if (Lp[0].Cargo == "Atendente")
{
ConManuAr.Visible = true;
}
else if (Lp[0].Cargo == "Gerente")
{
ConManuAr.Visible = true;
}
else if (Lp[0].Cargo == "Administrador")
{
ConManuAr.Visible = true;
}
}
private void Msg(string Aviso)
{
Response.Write("<script>alert('" + Aviso + "');</script>");
}
protected void btnBuscar_Click(object sender, EventArgs e)
{
BuscaCpf();
}
public void BuscaCpf()
{
int Cod = 0;
Dao D = new Dao();
SqlConnection Cn = D.SqlConn();
StringBuilder Sb = new StringBuilder();
Sb.Append("Select Cod_Cliente from tbCliente Where Cpf=@Cpf");
SqlCommand cmd = new SqlCommand(Sb.ToString(), Cn);
cmd.Parameters.AddWithValue("@Cpf", txtBuscaCpf.Text);
Cod = Convert.ToInt32(cmd.ExecuteScalar());
Cn.Close();
if (Cod <= 0)
{
lblCpf.Visible = true;
hpCadCliente.Visible = true;
}
else
{
mManuAr M = new mManuAr();
List<pManuAr> Lc = M.SelManu(Cod);
gdvManu.DataSource = Lc;
gdvManu.DataBind();
}
}
protected void gdvManu_SelectedIndexChanged(object sender, EventArgs e)
{
lblCod.Text = gdvManu.SelectedRow.Cells[0].Text;
txtCodCliente.Text = gdvManu.SelectedRow.Cells[1].Text;
txtModelo.Text = gdvManu.SelectedRow.Cells[2].Text;
txtMarca.Text = gdvManu.SelectedRow.Cells[3].Text;
txtNumSerie.Text = gdvManu.SelectedRow.Cells[4].Text;
txtDataEntrada.Text = gdvManu.SelectedRow.Cells[5].Text;
txtDataSaida.Text = gdvManu.SelectedRow.Cells[6].Text;
ddlStatus.Text = gdvManu.SelectedRow.Cells[7].Text;
txtObs.Text = gdvManu.SelectedRow.Cells[8].Text;
txtValorMObra.Text = gdvManu.SelectedRow.Cells[9].Text;
ddlFormaPagamento.Text = gdvManu.SelectedRow.Cells[10].Text;
txtMatrFunc.Text = gdvManu.SelectedRow.Cells[11].Text;
}
protected void btnEditar_Click(object sender, EventArgs e)
{
Msg("Alterado com sucesso !");
Codigo = Convert.ToInt32(lblCod.Text);
pManuAr P = new pManuAr();
P.Cod_Manutencao = Convert.ToInt32(lblCod.Text);
P.Cod_ClienteFK = Convert.ToInt32(txtCodCliente.Text);
P.Modelo = txtModelo.Text;
P.Marca = txtMarca.Text;
P.NumSerie = txtNumSerie.Text;
P.DataEntrada = Convert.ToDateTime(txtDataEntrada.Text);
P.DataSaida = Convert.ToDateTime(txtDataSaida.Text);
P.Status = ddlStatus.Text;
P.Observacao = txtObs.Text;
P.ValorMObra = Convert.ToDecimal(txtValorMObra.Text);
P.FormaPagamento = ddlFormaPagamento.Text;
P.Matr_FuncFK = Convert.ToInt32(txtMatrFunc.Text);
mManuAr M = new mManuAr();
M.AtuManu(P);
LimparContatos();
}
protected void btnExluir_Click(object sender, EventArgs e)
{
Msg("Exclusão efetuada com sucesso!");
Codigo = Convert.ToInt32(lblCod.Text);
mManuAr M = new mManuAr();
M.ExcManuAr(Codigo);
LimparContatos();
}
private void LimparContatos()
{
lblCod.Text = string.Empty;
txtCodCliente.Text = string.Empty;
txtModelo.Text = string.Empty;
txtMarca.Text = string.Empty;
txtNumSerie.Text = string.Empty;
txtDataEntrada.Text = string.Empty;
txtDataSaida.Text = string.Empty;
ddlStatus.Text = string.Empty;
txtObs.Text = string.Empty;
txtValorMObra.Text = string.Empty;
ddlFormaPagamento.Text = string.Empty;
txtMatrFunc.Text = string.Empty;
}
//private void txtValorMObra_Leave(object sender, EventArgs e)
//{
// txtValorMObra.Text = Convert.ToDecimal(txtValorMObra.Text).ToString("C");
//}
}
}