/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmPermissoesUsu)); this.tabPage1 = new System.Windows.Forms.TabPage(); this.grpBxInfor = new System.Windows.Forms.GroupBox(); this.chckBxPriv = new System.Windows.Forms.CheckBox(); this.chckBxUsublq = new System.Windows.Forms.CheckBox(); this.lblUsua = new System.Windows.Forms.Label(); this.tbCntrlCtrUsu = new System.Windows.Forms.TabControl(); this.cOMERCIALDataSet = new Comercial.COMERCIALDataSet(); this.uSUARIOBindingSource = new System.Windows.Forms.BindingSource(this.components); this.uSUARIOTableAdapter = new Comercial.COMERCIALDataSetTableAdapters.USUARIOTableAdapter(); this.tableAdapterManager = new Comercial.COMERCIALDataSetTableAdapters.TableAdapterManager(); this.txtUsu = new Comercial.TextButton(); this.tabPage1.SuspendLayout(); this.grpBxInfor.SuspendLayout(); this.tbCntrlCtrUsu.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.cOMERCIALDataSet)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.uSUARIOBindingSource)).BeginInit(); this.SuspendLayout(); // // tabPage1 // this.tabPage1.AutoScroll = true; this.tabPage1.Controls.Add(this.grpBxInfor); this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); this.tabPage1.Size = new System.Drawing.Size(522, 212); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Permissões"; this.tabPage1.UseVisualStyleBackColor = true; // // grpBxInfor // this.grpBxInfor.Controls.Add(this.chckBxPriv); this.grpBxInfor.Controls.Add(this.txtUsu); this.grpBxInfor.Controls.Add(this.chckBxUsublq); this.grpBxInfor.Controls.Add(this.lblUsua); this.grpBxInfor.ForeColor = System.Drawing.Color.CornflowerBlue; this.grpBxInfor.Location = new System.Drawing.Point(6, 6); this.grpBxInfor.Name = "grpBxInfor"; this.grpBxInfor.Size = new System.Drawing.Size(443, 108); this.grpBxInfor.TabIndex = 0; this.grpBxInfor.TabStop = false; this.grpBxInfor.Text = "Informação"; // // chckBxPriv // this.chckBxPriv.AutoSize = true; this.chckBxPriv.ForeColor = System.Drawing.Color.CadetBlue; this.chckBxPriv.Location = new System.Drawing.Point(198, 35); this.chckBxPriv.Name = "chckBxPriv"; this.chckBxPriv.Size = new System.Drawing.Size(80, 17); this.chckBxPriv.TabIndex = 45; this.chckBxPriv.Text = "Privilegiado"; this.chckBxPriv.UseVisualStyleBackColor = true; // // chckBxUsublq // this.chckBxUsublq.AutoSize = true; this.chckBxUsublq.ForeColor = System.Drawing.Color.CadetBlue; this.chckBxUsublq.Location = new System.Drawing.Point(284, 35); this.chckBxUsublq.Name = "chckBxUsublq"; this.chckBxUsublq.Size = new System.Drawing.Size(116, 17); this.chckBxUsublq.TabIndex = 43; this.chckBxUsublq.Text = "Usuário Bloqueado"; this.chckBxUsublq.UseVisualStyleBackColor = true; // // lblUsua // this.lblUsua.AutoSize = true; this.lblUsua.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblUsua.ForeColor = System.Drawing.Color.CadetBlue; this.lblUsua.Location = new System.Drawing.Point(11, 19); this.lblUsua.Name = "lblUsua"; this.lblUsua.Size = new System.Drawing.Size(50, 13); this.lblUsua.TabIndex = 36; this.lblUsua.Text = "Usuário"; // // tbCntrlCtrUsu // this.tbCntrlCtrUsu.Controls.Add(this.tabPage1); this.tbCntrlCtrUsu.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.tbCntrlCtrUsu.Location = new System.Drawing.Point(12, 5); this.tbCntrlCtrUsu.Name = "tbCntrlCtrUsu"; this.tbCntrlCtrUsu.SelectedIndex = 0; this.tbCntrlCtrUsu.Size = new System.Drawing.Size(530, 238); this.tbCntrlCtrUsu.TabIndex = 0; // // cOMERCIALDataSet // this.cOMERCIALDataSet.DataSetName = "COMERCIALDataSet"; this.cOMERCIALDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; // // uSUARIOBindingSource // this.uSUARIOBindingSource.DataMember = "USUARIO"; this.uSUARIOBindingSource.DataSource = this.cOMERCIALDataSet; // // uSUARIOTableAdapter // this.uSUARIOTableAdapter.ClearBeforeFill = true; // // tableAdapterManager // this.tableAdapterManager.ACESSOTableAdapter = null; this.tableAdapterManager.ATUCUBOTableAdapter = null; this.tableAdapterManager.BackupDataSetBeforeUpdate = false; this.tableAdapterManager.CLIENTETableAdapter = null; this.tableAdapterManager.CONDICAOPAGAMENTOTableAdapter = null; this.tableAdapterManager.GRUPOPRODUTOTableAdapter = null; this.tableAdapterManager.ICMSTableAdapter = null; this.tableAdapterManager.ItemNotaFiscalTableAdapter = null; this.tableAdapterManager.ITEMPEDIDOTableAdapter = null; this.tableAdapterManager.modeloCampoTableAdapter = null; this.tableAdapterManager.modeloTableAdapter = null; this.tableAdapterManager.MODULOTableAdapter = null; this.tableAdapterManager.NOTAFISCALTableAdapter = null; this.tableAdapterManager.PEDIDOTableAdapter = null; this.tableAdapterManager.PRODUTOTableAdapter = null; this.tableAdapterManager.REGIAOTableAdapter = null; this.tableAdapterManager.TRANSPORTADORATableAdapter = null; this.tableAdapterManager.TRANSPORTADORAVIATableAdapter = null; this.tableAdapterManager.UNIDADEMEDIDATableAdapter = null; this.tableAdapterManager.UpdateOrder = Comercial.COMERCIALDataSetTableAdapters.TableAdapterManager.UpdateOrderOption.InsertUpdateDelete; this.tableAdapterManager.USUARIOTableAdapter = this.uSUARIOTableAdapter; this.tableAdapterManager.VENDEDORTableAdapter = null; this.tableAdapterManager.VIATRANSPORTETableAdapter = null; // // txtUsu // this.txtUsu.getText = ""; this.txtUsu.Image = ((System.Drawing.Image)(resources.GetObject("txtUsu.Image"))); this.txtUsu.Location = new System.Drawing.Point(11, 35); this.txtUsu.Name = "txtUsu"; this.txtUsu.ShowButton = false; this.txtUsu.Size = new System.Drawing.Size(181, 25); this.txtUsu.TabIndex = 44; this.txtUsu.ButtonClick += new System.EventHandler(this.txtBtnUsu_ButtonClick); // // FrmPermissoesUsu // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(589, 348); this.ControlBox = false; this.Controls.Add(this.tbCntrlCtrUsu); this.Name = "FrmPermissoesUsu"; this.Text = "Controle de usuários"; this.Load += new System.EventHandler(this.FrmPermissoesUsu_Load); this.Shown += new System.EventHandler(this.FrmPermissoesUsu_Shown); this.Leave += new System.EventHandler(this.FrmPermissoesUsu_Leave); this.tabPage1.ResumeLayout(false); this.grpBxInfor.ResumeLayout(false); this.grpBxInfor.PerformLayout(); this.tbCntrlCtrUsu.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.cOMERCIALDataSet)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.uSUARIOBindingSource)).EndInit(); this.ResumeLayout(false); }
private void BtnSalvar_Click(object sender, EventArgs e) { int retorno = 0; Form frm = this.ActiveMdiChild; if (frm == null) return; try { // METODOS QUE NECESSITAM DE LOGICA ANTES DE SALVAR if (frm is FrmCadVen) { FrmCadVen frmVen = (FrmCadVen)frm; retorno = frmVen.salvar(edit); } #region Form's Claudio if (frm is FrmCadCli) { FrmCadCli frmCli = (FrmCadCli)frm; retorno = frmCli.salvar(edit); } #endregion #region Transportadora if (frm is FrmCadTra) { FrmCadTra frmTra = (FrmCadTra)frm; retorno = frmTra.salvarcep(); } #endregion #region CondicaoPagamento if (frm is FrmCadConPag) { FrmCadConPag frmCon = (FrmCadConPag)frm; retorno = frmCon.Salvar(); } if (frm is FrmCadUniMed) { FrmCadUniMed frmCon = (FrmCadUniMed)frm; retorno = frmCon.Salvar(); } #endregion if (frm is FrmCadProd && edit == false) { FrmCadProd frmCadProd = (FrmCadProd)frm; retorno = frmCadProd.salvar(); } if (frm is FrmPermissoesUsu && edit == false) { FrmPermissoesUsu frmCadven = (FrmPermissoesUsu)frm; retorno = frmCadven.salvar(); } if (frm is FrmCadPed && edit == false) { FrmCadPed frmPed = (FrmCadPed)frm; string DataEmissão = frmPed.dtpEmissao.Value.ToShortDateString(); string DataSistema = DateTime.Now.ToShortDateString(); string DataEntrega = frmPed.dtpEntrega.Value.ToShortDateString(); if (Convert.ToDateTime(DataEntrega) < Convert.ToDateTime(DataEmissão)) { throw new Exception("DataInvalida"); } if (Convert.ToDateTime(DataEmissão) < Convert.ToDateTime(DataSistema)) { throw new Exception("DataSistema"); } retorno = frmPed.SalvarPedidoCab(); } if (frm is FrmCadPed && edit == true) { FrmCadPed frmPed = (FrmCadPed)frm; retorno = frmPed.AtualizarPedido(); } if (retorno == 0) { bindingNavigator1.BindingSource.EndEdit(); // // CADA UM COLOCA O BLOCO DO SEU FORM... if (frm is FrmCadConPag) { COMERCIALDataSetTableAdapters.CONDICAOPAGAMENTOTableAdapter table = new Comercial.COMERCIALDataSetTableAdapters.CONDICAOPAGAMENTOTableAdapter(); table.Update(_dataset); FrmCadConPag frmCond = (FrmCadConPag)frm; retorno = frmCond.Salvar(); } if (frm is FrmCadGrpProd) { COMERCIALDataSetTableAdapters.GRUPOPRODUTOTableAdapter table = new Comercial.COMERCIALDataSetTableAdapters.GRUPOPRODUTOTableAdapter(); table.Update(_dataset); } #region Form's Claudio if (frm is FrmCadCli) { COMERCIALDataSetTableAdapters.CLIENTETableAdapter table = new Comercial.COMERCIALDataSetTableAdapters.CLIENTETableAdapter(); table.Update(_dataset); FrmCadCli cli = (FrmCadCli)frm; cli.pictureBox1.Visible = false; cli.pictureBox2.Visible = false; } if (frm is FrmCadRegiao) { COMERCIALDataSetTableAdapters.REGIAOTableAdapter table = new Comercial.COMERCIALDataSetTableAdapters.REGIAOTableAdapter(); table.Update(_dataset); } #endregion if (frm is FrmCadUniMed) { COMERCIALDataSetTableAdapters.UNIDADEMEDIDATableAdapter table = new Comercial.COMERCIALDataSetTableAdapters.UNIDADEMEDIDATableAdapter(); table.Update(_dataset); } if (frm is FrmCadVen) { COMERCIALDataSetTableAdapters.VENDEDORTableAdapter table = new Comercial.COMERCIALDataSetTableAdapters.VENDEDORTableAdapter(); table.Update(_dataset); FrmCadVen ven = (FrmCadVen)frm; ven.pictureBox1.Visible = false; ven.pictureBox2.Visible = false; } if (frm is FrmCadProd) { COMERCIALDataSetTableAdapters.PRODUTOTableAdapter table = new Comercial.COMERCIALDataSetTableAdapters.PRODUTOTableAdapter(); table.Update(_dataset); } Util.Interface.ChangeControlStatus(frm, false); bindingNavigator1.Refresh(); edit = false; cancelEdicao(); if (frm is FrmPermissoesUsu) { COMERCIALDataSetTableAdapters.USUARIOTableAdapter table = new Comercial.COMERCIALDataSetTableAdapters.USUARIOTableAdapter(); table.Update(_dataset); } if (frm is FrmCadTra) { FrmCadTra frmTrans = (FrmCadTra)frm; retorno = frmTrans.ValidaCNPJ(); if (retorno == 1) { MessageBox.Show("CNPJ Inválido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); Util.Interface.ChangeControlStatus(frm, true); bindingNavigator1.Refresh(); btnPesquisar.Enabled = false; BtnDeletar.Enabled = false; btnNovo.Enabled = false; BtnPrincipal.Enabled = false; btnEditar.Enabled = false; btnSalvar.Enabled = true; btnCancelEdicao.Enabled = true; } else { COMERCIALDataSetTableAdapters.TRANSPORTADORATableAdapter table = new Comercial.COMERCIALDataSetTableAdapters.TRANSPORTADORATableAdapter(); table.Update(_dataset); retorno = frmTrans.salvar(); } } } } catch (SqlException sqlex) { Validacoes valida = new Validacoes(); valida.tratarSqlExceções(sqlex); } catch (Exception ex) { Validacoes valida = new Validacoes(); valida.tratarSystemExceções(ex); } }
public int salvar(bool edit) { DataRowView x; x = (DataRowView)cLIENTEBindingSource.Current; Validacoes valida = new Validacoes(); string c = ConfigurationManager.ConnectionStrings["Comercial.Properties.Settings.COMERCIALConnectionString"].ConnectionString; //Valida CNPJ if (!String.IsNullOrEmpty(txtCnpjCli.Text) && txtCnpjCli.Text.Trim().Length == 14) { int cnpj = valida.ValidaCNPJ(txtCnpjCli.Text); if (cnpj == 1) { //MessageBox.Show("CNPJ Inválido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); //return 1; throw new Exception("cnpj invalido"); } } else { throw new Exception("cnpj invalido"); } // Valida IE if (!String.IsNullOrEmpty(txtIeCli.Text)) { string ie = txtIeCli.Text; string uf = cmbUfCli.SelectedItem.ToString(); int returnIe = ConsisteInscricaoEstadual(ie, uf); if (returnIe == 1) { //MessageBox.Show("I.E. Inválida.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); //return 1; throw new Exception("ie invalida"); } //if (string.IsNullOrEmpty(txtRazaoSocialCli.Text)) //{ // MessageBox.Show("Campo(s) obrigatório(s) não preenchido(s).", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); // return 1; //} } // Valida limite de crédito // string va = txtLimCredCli.Te if(!String.IsNullOrEmpty(txtLimCredCli.Text)) { double valor = double.Parse(txtLimCredCli.Text,System.Globalization.NumberStyles.Currency); if (valor<=0) { throw new Exception("valor invalido"); } } // Valida email if (!string.IsNullOrEmpty(txtEmailCli.Text)) { Boolean emailOk = valida.ValidaEmail(txtEmailCli.Text); if (emailOk == false) { //MessageBox.Show("Email Inválido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); //return 1; throw new Exception("email invalido"); } #region Salva Usuario if (edit == false) { if (!string.IsNullOrEmpty(txtUsuarioCli.Text) && !string.IsNullOrEmpty(txtSenhaCli.Text)) { SqlConnection conn = new SqlConnection(c); conn.Open(); SqlCommand cmd = new SqlCommand("select * from usuario where usuario = @usu", conn); SqlParameter param = new SqlParameter(); param.ParameterName = "@usu"; param.Value = txtUsuarioCli.Text; cmd.Parameters.Add(param); SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); if (reader.HasRows) { MessageBox.Show("Usuário ja cadastrado.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return 1; } else { COMERCIALDataSetTableAdapters.USUARIOTableAdapter usu = new Comercial.COMERCIALDataSetTableAdapters.USUARIOTableAdapter(); usu.Insert(txtUsuarioCli.Text, txtSenhaCli.Text, "N", "S"); } reader.Dispose(); reader.Close(); conn.Close(); conn.Dispose(); } SqlConnection conn1 = new SqlConnection(c); conn1.Open(); SqlCommand cmd1 = new SqlCommand("select * from usuario where usuario = @usu", conn1); SqlParameter param1 = new SqlParameter(); param1.ParameterName = "@usu"; param1.Value = txtUsuarioCli.Text; cmd1.Parameters.Add(param1); SqlDataReader reader1 = cmd1.ExecuteReader(); reader1.Read(); x["CodUSUARIO"] = reader1["codusuario"]; reader1.Dispose(); reader1.Close(); conn1.Close(); conn1.Dispose(); } #endregion if (chckBxCred.Checked) { x["APROVADOCRED"] = "S"; } else { x["APROVADOCRED"] = "N"; } x["CEP"] = txtCepCli.getText; txtSenhaCli.Text = ""; txtUsuarioCli.Text = ""; } return 0; }
public int salvar(bool edit) { DataRowView x; x = (DataRowView)cLIENTEBindingSource.Current; Validacoes valida = new Validacoes(); string c = ConfigurationManager.ConnectionStrings["Comercial.Properties.Settings.COMERCIALConnectionString"].ConnectionString; //Valida CNPJ if (!String.IsNullOrEmpty(txtCnpjCli.Text) && txtCnpjCli.Text.Trim().Length == 14) { int cnpj = valida.ValidaCNPJ(txtCnpjCli.Text); if (cnpj == 1) { //MessageBox.Show("CNPJ Inválido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); //return 1; throw new Exception("cnpj invalido"); } } else { throw new Exception("cnpj invalido"); } // Valida IE if (!String.IsNullOrEmpty(txtIeCli.Text)) { string ie = txtIeCli.Text; string uf = cmbUfCli.SelectedItem.ToString(); int returnIe = ConsisteInscricaoEstadual(ie, uf); if (returnIe == 1) { //MessageBox.Show("I.E. Inválida.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); //return 1; throw new Exception("ie invalida"); } //if (string.IsNullOrEmpty(txtRazaoSocialCli.Text)) //{ // MessageBox.Show("Campo(s) obrigatório(s) não preenchido(s).", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); // return 1; //} } // Valida limite de crédito // string va = txtLimCredCli.Te if (!String.IsNullOrEmpty(txtLimCredCli.Text)) { double valor = double.Parse(txtLimCredCli.Text, System.Globalization.NumberStyles.Currency); if (valor <= 0) { throw new Exception("valor invalido"); } } // Valida email if (!string.IsNullOrEmpty(txtEmailCli.Text)) { Boolean emailOk = valida.ValidaEmail(txtEmailCli.Text); if (emailOk == false) { //MessageBox.Show("Email Inválido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); //return 1; throw new Exception("email invalido"); } #region Salva Usuario if (edit == false) { if (!string.IsNullOrEmpty(txtUsuarioCli.Text) && !string.IsNullOrEmpty(txtSenhaCli.Text)) { SqlConnection conn = new SqlConnection(c); conn.Open(); SqlCommand cmd = new SqlCommand("select * from usuario where usuario = @usu", conn); SqlParameter param = new SqlParameter(); param.ParameterName = "@usu"; param.Value = txtUsuarioCli.Text; cmd.Parameters.Add(param); SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); if (reader.HasRows) { MessageBox.Show("Usuário ja cadastrado.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return(1); } else { COMERCIALDataSetTableAdapters.USUARIOTableAdapter usu = new Comercial.COMERCIALDataSetTableAdapters.USUARIOTableAdapter(); usu.Insert(txtUsuarioCli.Text, txtSenhaCli.Text, "N", "S"); } reader.Dispose(); reader.Close(); conn.Close(); conn.Dispose(); } SqlConnection conn1 = new SqlConnection(c); conn1.Open(); SqlCommand cmd1 = new SqlCommand("select * from usuario where usuario = @usu", conn1); SqlParameter param1 = new SqlParameter(); param1.ParameterName = "@usu"; param1.Value = txtUsuarioCli.Text; cmd1.Parameters.Add(param1); SqlDataReader reader1 = cmd1.ExecuteReader(); reader1.Read(); x["CodUSUARIO"] = reader1["codusuario"]; reader1.Dispose(); reader1.Close(); conn1.Close(); conn1.Dispose(); } #endregion if (chckBxCred.Checked) { x["APROVADOCRED"] = "S"; } else { x["APROVADOCRED"] = "N"; } x["CEP"] = txtCepCli.getText; txtSenhaCli.Text = ""; txtUsuarioCli.Text = ""; } return(0); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("Criar Usúario"); System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("Alterar Senha"); System.Windows.Forms.TreeNode treeNode3 = new System.Windows.Forms.TreeNode("Controle Usúario", new System.Windows.Forms.TreeNode[] { treeNode1, treeNode2}); System.Windows.Forms.TreeNode treeNode4 = new System.Windows.Forms.TreeNode("Backup"); System.Windows.Forms.TreeNode treeNode5 = new System.Windows.Forms.TreeNode("Calculadora"); System.Windows.Forms.TreeNode treeNode6 = new System.Windows.Forms.TreeNode("Notepad"); System.Windows.Forms.TreeNode treeNode7 = new System.Windows.Forms.TreeNode("Excel"); System.Windows.Forms.TreeNode treeNode8 = new System.Windows.Forms.TreeNode("Utilitários", new System.Windows.Forms.TreeNode[] { treeNode5, treeNode6, treeNode7}); System.Windows.Forms.TreeNode treeNode9 = new System.Windows.Forms.TreeNode("Arquivo", new System.Windows.Forms.TreeNode[] { treeNode3, treeNode4, treeNode8}); System.Windows.Forms.TreeNode treeNode10 = new System.Windows.Forms.TreeNode("Cliente"); System.Windows.Forms.TreeNode treeNode11 = new System.Windows.Forms.TreeNode("Produto"); System.Windows.Forms.TreeNode treeNode12 = new System.Windows.Forms.TreeNode("Pedido"); System.Windows.Forms.TreeNode treeNode13 = new System.Windows.Forms.TreeNode("Vendedor"); System.Windows.Forms.TreeNode treeNode14 = new System.Windows.Forms.TreeNode("Unidade Medida"); System.Windows.Forms.TreeNode treeNode15 = new System.Windows.Forms.TreeNode("Condição Pagamento"); System.Windows.Forms.TreeNode treeNode16 = new System.Windows.Forms.TreeNode("Transportadora"); System.Windows.Forms.TreeNode treeNode17 = new System.Windows.Forms.TreeNode("Grupo de produto"); System.Windows.Forms.TreeNode treeNode18 = new System.Windows.Forms.TreeNode("Ajustes", new System.Windows.Forms.TreeNode[] { treeNode14, treeNode15, treeNode16, treeNode17}); System.Windows.Forms.TreeNode treeNode19 = new System.Windows.Forms.TreeNode("Cadastros", new System.Windows.Forms.TreeNode[] { treeNode10, treeNode11, treeNode12, treeNode13, treeNode18}); System.Windows.Forms.TreeNode treeNode20 = new System.Windows.Forms.TreeNode("Cliente"); System.Windows.Forms.TreeNode treeNode21 = new System.Windows.Forms.TreeNode("Produto"); System.Windows.Forms.TreeNode treeNode22 = new System.Windows.Forms.TreeNode("Pedido"); System.Windows.Forms.TreeNode treeNode23 = new System.Windows.Forms.TreeNode("Vendedor"); System.Windows.Forms.TreeNode treeNode24 = new System.Windows.Forms.TreeNode("Consultas", new System.Windows.Forms.TreeNode[] { treeNode20, treeNode21, treeNode22, treeNode23}); System.Windows.Forms.TreeNode treeNode25 = new System.Windows.Forms.TreeNode("Gerar NF"); System.Windows.Forms.TreeNode treeNode26 = new System.Windows.Forms.TreeNode("Devolução NF"); System.Windows.Forms.TreeNode treeNode27 = new System.Windows.Forms.TreeNode("Liberação Pedido"); System.Windows.Forms.TreeNode treeNode28 = new System.Windows.Forms.TreeNode("Gerar Modelo"); System.Windows.Forms.TreeNode treeNode29 = new System.Windows.Forms.TreeNode("Consultar"); System.Windows.Forms.TreeNode treeNode30 = new System.Windows.Forms.TreeNode("Mineração Dados", new System.Windows.Forms.TreeNode[] { treeNode28, treeNode29}); System.Windows.Forms.TreeNode treeNode31 = new System.Windows.Forms.TreeNode("Processos", new System.Windows.Forms.TreeNode[] { treeNode25, treeNode26, treeNode27, treeNode30}); System.Windows.Forms.TreeNode treeNode32 = new System.Windows.Forms.TreeNode("Sistema Comercial", new System.Windows.Forms.TreeNode[] { treeNode9, treeNode19, treeNode24, treeNode31}); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmCadUsu)); this.tabPage1 = new System.Windows.Forms.TabPage(); this.grpBxMenu = new System.Windows.Forms.GroupBox(); this.trVwMenu = new System.Windows.Forms.TreeView(); this.btnDesAll = new System.Windows.Forms.Button(); this.btnMarAll = new System.Windows.Forms.Button(); this.grpBxInfor = new System.Windows.Forms.GroupBox(); this.txtBxSenhaAntiga = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.chckBxPriv = new System.Windows.Forms.CheckBox(); this.txtUsu = new Comercial.TextButton(); this.chckBxUsublq = new System.Windows.Forms.CheckBox(); this.txtConSenha = new System.Windows.Forms.TextBox(); this.lblConSenha = new System.Windows.Forms.Label(); this.txtSenha = new System.Windows.Forms.TextBox(); this.lblUsua = new System.Windows.Forms.Label(); this.lblSenha = new System.Windows.Forms.Label(); this.tbCntrlCtrUsu = new System.Windows.Forms.TabControl(); this.cOMERCIALDataSet = new Comercial.COMERCIALDataSet(); this.uSUARIOBindingSource = new System.Windows.Forms.BindingSource(this.components); this.uSUARIOTableAdapter = new Comercial.COMERCIALDataSetTableAdapters.USUARIOTableAdapter(); this.tableAdapterManager = new Comercial.COMERCIALDataSetTableAdapters.TableAdapterManager(); this.tabPage1.SuspendLayout(); this.grpBxMenu.SuspendLayout(); this.grpBxInfor.SuspendLayout(); this.tbCntrlCtrUsu.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.cOMERCIALDataSet)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.uSUARIOBindingSource)).BeginInit(); this.SuspendLayout(); // // tabPage1 // this.tabPage1.AutoScroll = true; this.tabPage1.Controls.Add(this.grpBxMenu); this.tabPage1.Controls.Add(this.grpBxInfor); this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); this.tabPage1.Size = new System.Drawing.Size(529, 277); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Identificação"; this.tabPage1.UseVisualStyleBackColor = true; // // grpBxMenu // this.grpBxMenu.Controls.Add(this.trVwMenu); this.grpBxMenu.Controls.Add(this.btnDesAll); this.grpBxMenu.Controls.Add(this.btnMarAll); this.grpBxMenu.ForeColor = System.Drawing.Color.CornflowerBlue; this.grpBxMenu.Location = new System.Drawing.Point(273, 6); this.grpBxMenu.Name = "grpBxMenu"; this.grpBxMenu.Size = new System.Drawing.Size(250, 265); this.grpBxMenu.TabIndex = 3; this.grpBxMenu.TabStop = false; this.grpBxMenu.Text = "Menu"; // // trVwMenu // this.trVwMenu.CheckBoxes = true; this.trVwMenu.Cursor = System.Windows.Forms.Cursors.Default; this.trVwMenu.Location = new System.Drawing.Point(6, 13); this.trVwMenu.Name = "trVwMenu"; treeNode1.Name = "criarSenha"; treeNode1.Text = "Criar Usúario"; treeNode2.Name = "altSenha"; treeNode2.Text = "Alterar Senha"; treeNode3.Name = "controle usuario"; treeNode3.Text = "Controle Usúario"; treeNode4.Name = "backup"; treeNode4.Text = "Backup"; treeNode5.Name = "Nó14"; treeNode5.Text = "Calculadora"; treeNode6.Name = "Nó15"; treeNode6.Text = "Notepad"; treeNode7.Name = "Nó16"; treeNode7.Text = "Excel"; treeNode8.Name = "utilitario"; treeNode8.Text = "Utilitários"; treeNode9.Name = "arquivo"; treeNode9.Text = "Arquivo"; treeNode10.Name = "cadcli"; treeNode10.Text = "Cliente"; treeNode11.Name = "cadprod"; treeNode11.Text = "Produto"; treeNode12.Name = "cadped"; treeNode12.Text = "Pedido"; treeNode13.Name = "cadven"; treeNode13.Text = "Vendedor"; treeNode14.Name = "cadmed"; treeNode14.Text = "Unidade Medida"; treeNode15.Name = "cadcondpag"; treeNode15.Text = "Condição Pagamento"; treeNode16.Name = "cadtransp"; treeNode16.Text = "Transportadora"; treeNode17.Name = "cadgrupoprod"; treeNode17.Text = "Grupo de produto"; treeNode18.Name = "ajustes"; treeNode18.Text = "Ajustes"; treeNode19.Name = "cadastros"; treeNode19.Text = "Cadastros"; treeNode20.Name = "concli"; treeNode20.Text = "Cliente"; treeNode21.Name = "conprod"; treeNode21.Text = "Produto"; treeNode22.Name = "conped"; treeNode22.Text = "Pedido"; treeNode23.Name = "conven"; treeNode23.Text = "Vendedor"; treeNode24.Name = "consultas"; treeNode24.Text = "Consultas"; treeNode25.Name = "Gerar NF"; treeNode25.Text = "Gerar NF"; treeNode26.Name = "Dev NF"; treeNode26.Text = "Devolução NF"; treeNode27.Name = "LibPedido"; treeNode27.Text = "Liberação Pedido"; treeNode28.Name = "gerar min"; treeNode28.Text = "Gerar Modelo"; treeNode29.Name = "consultar min"; treeNode29.Text = "Consultar"; treeNode30.Name = "Min"; treeNode30.Text = "Mineração Dados"; treeNode31.Name = "processos"; treeNode31.Text = "Processos"; treeNode32.Name = "todos"; treeNode32.Text = "Sistema Comercial"; this.trVwMenu.Nodes.AddRange(new System.Windows.Forms.TreeNode[] { treeNode32}); this.trVwMenu.Size = new System.Drawing.Size(238, 217); this.trVwMenu.TabIndex = 3; // // btnDesAll // this.btnDesAll.ForeColor = System.Drawing.Color.Black; this.btnDesAll.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.btnDesAll.Location = new System.Drawing.Point(134, 236); this.btnDesAll.Name = "btnDesAll"; this.btnDesAll.Size = new System.Drawing.Size(110, 23); this.btnDesAll.TabIndex = 2; this.btnDesAll.Text = "Desmarcar Todos"; this.btnDesAll.UseVisualStyleBackColor = true; this.btnDesAll.Click += new System.EventHandler(this.btnDesAll_Click); // // btnMarAll // this.btnMarAll.ForeColor = System.Drawing.Color.Black; this.btnMarAll.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; this.btnMarAll.Location = new System.Drawing.Point(6, 236); this.btnMarAll.Name = "btnMarAll"; this.btnMarAll.Size = new System.Drawing.Size(122, 23); this.btnMarAll.TabIndex = 1; this.btnMarAll.Text = "Marcar Todos"; this.btnMarAll.UseVisualStyleBackColor = true; this.btnMarAll.Click += new System.EventHandler(this.btnMarAll_Click); // // grpBxInfor // this.grpBxInfor.Controls.Add(this.txtBxSenhaAntiga); this.grpBxInfor.Controls.Add(this.label1); this.grpBxInfor.Controls.Add(this.chckBxPriv); this.grpBxInfor.Controls.Add(this.txtUsu); this.grpBxInfor.Controls.Add(this.chckBxUsublq); this.grpBxInfor.Controls.Add(this.txtConSenha); this.grpBxInfor.Controls.Add(this.lblConSenha); this.grpBxInfor.Controls.Add(this.txtSenha); this.grpBxInfor.Controls.Add(this.lblUsua); this.grpBxInfor.Controls.Add(this.lblSenha); this.grpBxInfor.ForeColor = System.Drawing.Color.CornflowerBlue; this.grpBxInfor.Location = new System.Drawing.Point(6, 6); this.grpBxInfor.Name = "grpBxInfor"; this.grpBxInfor.Size = new System.Drawing.Size(261, 265); this.grpBxInfor.TabIndex = 0; this.grpBxInfor.TabStop = false; this.grpBxInfor.Text = "Informação"; // // txtBxSenhaAntiga // this.txtBxSenhaAntiga.Location = new System.Drawing.Point(11, 74); this.txtBxSenhaAntiga.Name = "txtBxSenhaAntiga"; this.txtBxSenhaAntiga.PasswordChar = '*'; this.txtBxSenhaAntiga.Size = new System.Drawing.Size(100, 20); this.txtBxSenhaAntiga.TabIndex = 47; // // label1 // this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label1.ForeColor = System.Drawing.Color.CadetBlue; this.label1.Location = new System.Drawing.Point(11, 58); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(90, 13); this.label1.TabIndex = 46; this.label1.Text = "Senha antiga: "; this.label1.Click += new System.EventHandler(this.label1_Click); // // chckBxPriv // this.chckBxPriv.AutoSize = true; this.chckBxPriv.ForeColor = System.Drawing.Color.CadetBlue; this.chckBxPriv.Location = new System.Drawing.Point(11, 213); this.chckBxPriv.Name = "chckBxPriv"; this.chckBxPriv.Size = new System.Drawing.Size(80, 17); this.chckBxPriv.TabIndex = 45; this.chckBxPriv.Text = "Privilegiado"; this.chckBxPriv.UseVisualStyleBackColor = true; // // txtUsu // this.txtUsu.getText = ""; this.txtUsu.Image = ((System.Drawing.Image)(resources.GetObject("txtUsu.Image"))); this.txtUsu.Location = new System.Drawing.Point(11, 35); this.txtUsu.Name = "txtUsu"; this.txtUsu.ShowButton = false; this.txtUsu.Size = new System.Drawing.Size(181, 25); this.txtUsu.TabIndex = 44; this.txtUsu.ButtonClick += new System.EventHandler(this.txtBtnUsu_ButtonClick); // // chckBxUsublq // this.chckBxUsublq.AutoSize = true; this.chckBxUsublq.ForeColor = System.Drawing.Color.CadetBlue; this.chckBxUsublq.Location = new System.Drawing.Point(11, 184); this.chckBxUsublq.Name = "chckBxUsublq"; this.chckBxUsublq.Size = new System.Drawing.Size(116, 17); this.chckBxUsublq.TabIndex = 43; this.chckBxUsublq.Text = "Usuário Bloqueado"; this.chckBxUsublq.UseVisualStyleBackColor = true; // // txtConSenha // this.txtConSenha.Location = new System.Drawing.Point(11, 152); this.txtConSenha.Name = "txtConSenha"; this.txtConSenha.PasswordChar = '*'; this.txtConSenha.Size = new System.Drawing.Size(100, 20); this.txtConSenha.TabIndex = 42; // // lblConSenha // this.lblConSenha.AutoSize = true; this.lblConSenha.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblConSenha.ForeColor = System.Drawing.Color.CadetBlue; this.lblConSenha.Location = new System.Drawing.Point(11, 136); this.lblConSenha.Name = "lblConSenha"; this.lblConSenha.Size = new System.Drawing.Size(108, 13); this.lblConSenha.TabIndex = 41; this.lblConSenha.Text = "Confirmar Senha :"; // // txtSenha // this.txtSenha.Location = new System.Drawing.Point(11, 113); this.txtSenha.Name = "txtSenha"; this.txtSenha.PasswordChar = '*'; this.txtSenha.Size = new System.Drawing.Size(100, 20); this.txtSenha.TabIndex = 40; // // lblUsua // this.lblUsua.AutoSize = true; this.lblUsua.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblUsua.ForeColor = System.Drawing.Color.CadetBlue; this.lblUsua.Location = new System.Drawing.Point(11, 19); this.lblUsua.Name = "lblUsua"; this.lblUsua.Size = new System.Drawing.Size(58, 13); this.lblUsua.TabIndex = 36; this.lblUsua.Text = "Usuário :"; // // lblSenha // this.lblSenha.AutoSize = true; this.lblSenha.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblSenha.ForeColor = System.Drawing.Color.CadetBlue; this.lblSenha.Location = new System.Drawing.Point(11, 97); this.lblSenha.Name = "lblSenha"; this.lblSenha.Size = new System.Drawing.Size(55, 13); this.lblSenha.TabIndex = 31; this.lblSenha.Text = "Senha : "; // // tbCntrlCtrUsu // this.tbCntrlCtrUsu.Controls.Add(this.tabPage1); this.tbCntrlCtrUsu.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.tbCntrlCtrUsu.Location = new System.Drawing.Point(12, 12); this.tbCntrlCtrUsu.Name = "tbCntrlCtrUsu"; this.tbCntrlCtrUsu.SelectedIndex = 0; this.tbCntrlCtrUsu.Size = new System.Drawing.Size(537, 303); this.tbCntrlCtrUsu.TabIndex = 0; // // cOMERCIALDataSet // this.cOMERCIALDataSet.DataSetName = "COMERCIALDataSet"; this.cOMERCIALDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; // // uSUARIOBindingSource // this.uSUARIOBindingSource.DataMember = "USUARIO"; this.uSUARIOBindingSource.DataSource = this.cOMERCIALDataSet; // // uSUARIOTableAdapter // this.uSUARIOTableAdapter.ClearBeforeFill = true; // // tableAdapterManager // this.tableAdapterManager.ACESSOTableAdapter = null; this.tableAdapterManager.ATUCUBOTableAdapter = null; this.tableAdapterManager.BackupDataSetBeforeUpdate = false; this.tableAdapterManager.CLIENTETableAdapter = null; this.tableAdapterManager.CONDICAOPAGAMENTOTableAdapter = null; this.tableAdapterManager.GRUPOPRODUTOTableAdapter = null; this.tableAdapterManager.ICMSTableAdapter = null; this.tableAdapterManager.ItemNotaFiscalTableAdapter = null; this.tableAdapterManager.ITEMPEDIDOTableAdapter = null; this.tableAdapterManager.modeloCampoTableAdapter = null; this.tableAdapterManager.modeloTableAdapter = null; this.tableAdapterManager.MODULOTableAdapter = null; this.tableAdapterManager.NOTAFISCALTableAdapter = null; this.tableAdapterManager.PEDIDOTableAdapter = null; this.tableAdapterManager.PRODUTOTableAdapter = null; this.tableAdapterManager.REGIAOTableAdapter = null; this.tableAdapterManager.TRANSPORTADORATableAdapter = null; this.tableAdapterManager.TRANSPORTADORAVIATableAdapter = null; this.tableAdapterManager.UNIDADEMEDIDATableAdapter = null; this.tableAdapterManager.UpdateOrder = Comercial.COMERCIALDataSetTableAdapters.TableAdapterManager.UpdateOrderOption.InsertUpdateDelete; this.tableAdapterManager.USUARIOTableAdapter = this.uSUARIOTableAdapter; this.tableAdapterManager.VENDEDORTableAdapter = null; this.tableAdapterManager.VIATRANSPORTETableAdapter = null; // // FrmCadUsu // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(589, 348); this.Controls.Add(this.tbCntrlCtrUsu); this.Name = "FrmCadUsu"; this.Text = "Controle de usuários"; this.Load += new System.EventHandler(this.FrmCadUsu_Load); this.Shown += new System.EventHandler(this.FrmCadUsu_Shown); this.Leave += new System.EventHandler(this.FrmCadUsu_Leave); this.tabPage1.ResumeLayout(false); this.grpBxMenu.ResumeLayout(false); this.grpBxInfor.ResumeLayout(false); this.grpBxInfor.PerformLayout(); this.tbCntrlCtrUsu.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.cOMERCIALDataSet)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.uSUARIOBindingSource)).EndInit(); this.ResumeLayout(false); }
/* * SALVAR RETORNA: * 0 - OK * 1 - ERRO */ public int salvar(bool edit) { #region Validaçoes //Valida CPFe email string c = ConfigurationManager.ConnectionStrings["Comercial.Properties.Settings.COMERCIALConnectionString"].ConnectionString; Validacoes valida = new Validacoes(); if (!string.IsNullOrEmpty(txtCPF.Text) && !string.IsNullOrEmpty(txtComissao.Text)) { int cpf = valida.ValidaCPF(txtCPF.Text); bool email = true; if (!string.IsNullOrEmpty(txtEmail.Text)) { email = valida.ValidaEmail(txtEmail.Text); } if (cpf == 1) { MessageBox.Show("CPF Inválido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return(1); } if (email == false) { MessageBox.Show("E-mail Inválido.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return(1); } if (Convert.ToDouble(txtComissao.Text) < 0) { MessageBox.Show("Comissão Inválida.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return(1); } } else { throw new Exception("campo vazio"); } #endregion DataRowView x; x = (DataRowView)vENDEDORBindingSource.Current; #region Salva Usuario if (edit == false) { if (!string.IsNullOrEmpty(txtUsu.Text) && !string.IsNullOrEmpty(txtSenha.Text)) { SqlConnection conn = new SqlConnection(c); conn.Open(); SqlCommand cmd = new SqlCommand("select * from usuario where usuario = @usu", conn); SqlParameter param = new SqlParameter(); param.ParameterName = "@usu"; param.Value = txtUsu.Text; cmd.Parameters.Add(param); SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); if (reader.HasRows) { MessageBox.Show("Usuário ja cadastrado.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return(1); } else { COMERCIALDataSetTableAdapters.USUARIOTableAdapter usu = new Comercial.COMERCIALDataSetTableAdapters.USUARIOTableAdapter(); usu.Insert(txtUsu.Text, txtSenha.Text, "N", "S"); } reader.Dispose(); reader.Close(); conn.Close(); conn.Dispose(); } SqlConnection conn1 = new SqlConnection(c); conn1.Open(); SqlCommand cmd1 = new SqlCommand("select * from usuario where usuario = @usu", conn1); SqlParameter param1 = new SqlParameter(); param1.ParameterName = "@usu"; param1.Value = txtUsu.Text; cmd1.Parameters.Add(param1); SqlDataReader reader1 = cmd1.ExecuteReader(); reader1.Read(); x["CodUSUARIO"] = reader1["codusuario"]; reader1.Dispose(); reader1.Close(); conn1.Close(); conn1.Dispose(); } #endregion x["CEP"] = txtcep.getText; x["ATIVO"] = "S"; if (radioButton1.Checked) { x["SEXO"] = "M"; } else { x["SEXO"] = "F"; } txtSenha.Text = ""; txtUsu.Text = ""; return(0); }