public UserForm(user u) { InitializeComponent(); ControlsUtil.SetBackColor(this.Controls); if (u == null) { u = new user(); btnInactive.Visible = false; IsNew = true; } NewPassword = u.password; if (u.inactive) { panelControl1.Enabled = false; btnInactive.Visible = false; btnSave.Visible = false; IsNew = false; } bdgUser.DataSource = u; //validations Validations.ValidatorCPFCNPJ vldCPF = new Validations.ValidatorCPFCNPJ() { ErrorText = "O CPF informado é inválido.", ErrorType = ErrorType.Warning }; validator.SetValidationRule(tfCPF, vldCPF); }
public CustomerForm(customer c) { try { SplashScreenManager.ShowForm(null, typeof(PleaseWaitForm), false, false, false); address ad; InitializeComponent(); ControlsUtil.SetBackColor(this.Controls); if (c == null) { c = new customer(); ad = new address(); IsNew = true; } else { IsNew = false; ad = address.SingleOrDefault(c.address_id); foreach (phones_customer pc in phones_customer.Fetch("WHERE customer_id=@0", c.id)) listPhones.Items.Add(pc.phone); pePicture.Image = new FTPUtil().getImageFromFile(c.directory_picture); cbOrganEmitter.EditValue = c.organ_emitter_rg.Split('/')[0]; cbStateRG.EditValue = c.organ_emitter_rg.Split('/')[1]; } List<state> listS = state.Fetch(""); bdgStates.DataSource = listS; foreach (state e in listS) cbStateRG.Properties.Items.Add(e.symbol); bdgOrganEmitter.DataSource = organ_emitter.Fetch(""); bdgAddress.DataSource = ad; bdgCustomer.DataSource = c; Validations.ValidatorCPFCNPJ vcpf = new Validations.ValidatorCPFCNPJ() { ErrorText = "O CPF informado é inválido." }; validatorCustomer.SetValidationRule(tfCPF, vcpf); } catch (Exception ex) { XtraMessageBox.Show(String.Format("Ocorreu um erro.\n\n{0}\n{1}", ex.Message, ex.InnerException)); } finally { SplashScreenManager.CloseForm(false); } }