//recebe as informaçoes do usuario selecionado e passa todas as suas informçoes para o formulario de cadastro para atualizaçao ou deletar private void usersDataG_DoubleClick(object sender, EventArgs e) { if (usersDataG.CurrentRow.Index != -1) { var frm = new RegisterForm(); frm.Location = this.Location; frm.StartPosition = FormStartPosition.Manual; frm.FormClosing += delegate { this.Search(); this.Show(); }; PassData del = new PassData(frm.PassedData); byte[] img = (byte[])usersDataG.CurrentRow.Cells[13].Value; MemoryStream ms = new MemoryStream(img); frm.pictureBox1.Image = Image.FromStream(ms); del(usersDataG.CurrentRow.Cells[1].Value.ToString(), usersDataG.CurrentRow.Cells[2].Value.ToString(), usersDataG.CurrentRow.Cells[3].Value.ToString(), usersDataG.CurrentRow.Cells[4].Value.ToString(), usersDataG.CurrentRow.Cells[5].Value.ToString(), usersDataG.CurrentRow.Cells[6].Value.ToString(), usersDataG.CurrentRow.Cells[7].Value.ToString(), usersDataG.CurrentRow.Cells[8].Value.ToString(), usersDataG.CurrentRow.Cells[9].Value.ToString(), usersDataG.CurrentRow.Cells[10].Value.ToString(), usersDataG.CurrentRow.Cells[11].Value.ToString(), usersDataG.CurrentRow.Cells[12].Value.ToString(), usersDataG.CurrentRow.Cells[14].Value.ToString(), usersDataG.CurrentRow.Cells[15].Value.ToString(), Convert.ToInt32(usersDataG.CurrentRow.Cells[0].Value) ); frm.Show(); this.Hide(); } }
//fecha o formulario de pesquisa e volta o relatorio de cadastro private void backBtn_Click(object sender, EventArgs e) { var frm = new RegisterForm(); frm.Location = this.Location; frm.StartPosition = FormStartPosition.Manual; frm.FormClosing += delegate { this.Show(); }; this.Close(); }
public bool isValid() { switch (usersDataG.CurrentCellAddress.X) { case 1: if (usersDataG.CurrentRow.Cells[1].Value.ToString().Trim() == "") { usersDataG.CurrentRow.Cells[1].Style.BackColor = Color.IndianRed; return(false); } else { usersDataG.CurrentRow.Cells[1].Style.BackColor = Color.White; sqlSave(); return(true); } case 2: if (usersDataG.CurrentCell.Value.ToString().Trim().Length == 8) { CepIsValid(); sqlSave(); return(true); } else { usersDataG.CurrentRow.Cells[2].Style.BackColor = Color.IndianRed; return(false); } case 3: if (usersDataG.CurrentRow.Cells[3].Value.ToString().Trim() == "") { usersDataG.CurrentRow.Cells[3].Style.BackColor = Color.IndianRed; return(false); } else { usersDataG.CurrentRow.Cells[3].Style.BackColor = Color.White; sqlSave(); return(true); } case 4: if (usersDataG.CurrentRow.Cells[4].Value.ToString().Trim() == "") { usersDataG.CurrentRow.Cells[4].Style.BackColor = Color.IndianRed; return(false); } else { usersDataG.CurrentRow.Cells[4].Style.BackColor = Color.White; sqlSave(); return(true); } case 5: if (usersDataG.CurrentRow.Cells[5].Value.ToString().Trim() == "") { usersDataG.CurrentRow.Cells[5].Style.BackColor = Color.IndianRed; return(false); } else { usersDataG.CurrentRow.Cells[5].Style.BackColor = Color.White; sqlSave(); return(true); } case 6: if (usersDataG.CurrentRow.Cells[6].Value.ToString().Trim() == "") { usersDataG.CurrentRow.Cells[6].Style.BackColor = Color.IndianRed; return(false); } else { usersDataG.CurrentRow.Cells[6].Style.BackColor = Color.White; sqlSave(); return(true); } case 7: if (usersDataG.CurrentRow.Cells[7].Value.ToString().Trim() == "") { usersDataG.CurrentRow.Cells[7].Style.BackColor = Color.IndianRed; return(false); } else { if (RegisterForm.Cpf(usersDataG.CurrentRow.Cells[7].Value.ToString().Trim())) { usersDataG.CurrentRow.Cells[7].Style.BackColor = Color.White; sqlSave(); return(true); } else if (RegisterForm.Cnpj(usersDataG.CurrentRow.Cells[7].Value.ToString().Trim())) { usersDataG.CurrentRow.Cells[7].Style.BackColor = Color.White; sqlSave(); return(true); } else { usersDataG.CurrentRow.Cells[7].Style.BackColor = Color.IndianRed; return(false); } } case 8: if (usersDataG.CurrentRow.Cells[8].Value.ToString().Trim() == "") { usersDataG.CurrentRow.Cells[8].Style.BackColor = Color.IndianRed; return(false); } else { //se o usuario sair sem digitar nada usersDataG.CurrentRow.Cells[8].Style.BackColor = Color.IndianRed; if (usersDataG.CurrentRow.Cells[8].Value.ToString().Trim().Length >= 8) { //verifica se o usuario é uma pessoa juridica e faz a validaçao do IE if (!RegisterForm.fncValida_Inscricao_Estadual(uF, usersDataG.CurrentRow.Cells[8].Value.ToString().Trim())) { usersDataG.CurrentRow.Cells[8].Style.BackColor = Color.IndianRed; MessageBox.Show("IE invalido"); return(false); } else { usersDataG.CurrentRow.Cells[8].Style.BackColor = Color.White; sqlSave(); return(true); } } else if (usersDataG.CurrentRow.Cells[8].Value.ToString().Trim() != "") { usersDataG.CurrentRow.Cells[8].Style.BackColor = Color.White; sqlSave(); return(true); } else { usersDataG.CurrentRow.Cells[8].Style.BackColor = Color.White; sqlSave(); return(true); } } case 9: // verifica se o email indicado é valido if (RegisterForm.emailValidator(usersDataG.CurrentRow.Cells[9].Value.ToString().Trim())) { usersDataG.CurrentRow.Cells[9].Style.BackColor = Color.White; sqlSave(); return(true); } else { usersDataG.CurrentRow.Cells[9].Style.BackColor = Color.IndianRed; return(false); } case 10: if (usersDataG.CurrentRow.Cells[10].Value.ToString().Trim() == "") { usersDataG.CurrentRow.Cells[10].Style.BackColor = Color.IndianRed; return(false); } else { usersDataG.CurrentRow.Cells[10].Style.BackColor = Color.White; sqlSave(); return(true); } case 11: //muda a cor de fundo se o usuario entrar no campo e nao digitar nada ou digitar um numero invalido if (numberIsValid(usersDataG.CurrentRow.Cells[11].Value.ToString().Trim())) { usersDataG.CurrentRow.Cells[11].Style.BackColor = Color.White; sqlSave(); return(true); } else { usersDataG.CurrentRow.Cells[11].Style.BackColor = Color.IndianRed; return(false); } case 12: if (numberIsValid(usersDataG.CurrentRow.Cells[12].Value.ToString().Trim())) { usersDataG.CurrentRow.Cells[12].Style.BackColor = Color.White; sqlSave(); return(true); } else { usersDataG.CurrentRow.Cells[12].Style.BackColor = Color.IndianRed; return(false); } case 13: if (usersDataG.CurrentRow.Cells[13].Value.ToString().Trim() == "") { usersDataG.CurrentRow.Cells[13].Style.BackColor = Color.IndianRed; return(false); } else { usersDataG.CurrentRow.Cells[13].Style.BackColor = Color.White; sqlSave(); return(true); } default: return(false); } }