public static void CreateCustomerFPanel(CustomerFisico customer, FlowLayoutPanel flowLayoutPanel, EventHandler eventHandler) { uiPanel uiPanel = new uiPanel(); uiPanel.Name = "pnlCustomer" + customer.CustomerId; uiPanel.Size = new Size(241, 86); uiPanel.PanelRadius = 5; uiPanel.Tag = customer.CustomerId; uiPanel.BackColor = Color.Transparent; uiPanel.Click += new EventHandler(eventHandler); PictureBox pictureBox = new PictureBox(); pictureBox.Name = "picCustomer" + customer.CustomerId; pictureBox.Size = new Size(77, 77); pictureBox.Image = Resources.unknown; //pictureBox.Image = UtilImage.ByteToImage(new Archive { ArchiveId = customer.ArchiveId }.ObterPorCod().Blob); pictureBox.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox.Tag = customer.CustomerId; pictureBox.BackColor = Color.Transparent; uiPanel.Controls.Add(pictureBox); pictureBox.Location = new Point(4, 4); pictureBox.Click += new EventHandler(eventHandler); Label label = new Label(); label.Name = "lblCustomerName" + customer.CustomerId; label.Font = new Font("Gadugi", 14, FontStyle.Bold); label.ForeColor = Color.FromArgb(80, 63, 153); label.Tag = customer.CustomerId; label.BackColor = Color.FromArgb(242, 245, 255); label.Text = String.Format("{0} {1}", customer.FirstName, customer.LastName); label.AutoEllipsis = true; label.AutoSize = false; label.Size = new Size(133, 21); uiPanel.Controls.Add(label); label.Location = new Point(85, 6); label.Click += new EventHandler(eventHandler); Label labelBalance = new Label(); labelBalance.Name = "lblCustomerEmail" + customer.CustomerId; labelBalance.Font = new Font("Gadugi", 8); labelBalance.ForeColor = Color.FromArgb(180, 182, 194); labelBalance.BackColor = Color.FromArgb(242, 245, 255); labelBalance.Text = UtilConvert.ToString(customer.Email); labelBalance.AutoEllipsis = true; labelBalance.Tag = customer.CustomerId; labelBalance.AutoSize = false; labelBalance.Size = new Size(131, 14); uiPanel.Controls.Add(labelBalance); labelBalance.Location = new Point(87, 27); labelBalance.Click += new EventHandler(eventHandler); flowLayoutPanel.Controls.Add(uiPanel); //flowLayoutPanel.Controls.Add(uiPanelEmployee); }
private void uiTxtSearch_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab) { if (uiTxtSearch.TextLength == 11) { if (UtilValidar.validarCPF(uiTxtSearch.Text)) { currentCustomerFisico = new CustomerFisico() { CPF = uiTxtSearch.Text }.ObterPorCPF(); if (currentCustomerFisico != null) { UtilCreatePanel.CreateCustomerFPanel(currentCustomerFisico, uiFlowPanel, Customer_Click); flowPanelCustomerF.Visible = false; } else { new Alert("Não possui cliente com o CPF inserido.", uiCSB.Toastr.Type.Warning); uiTxtSearch.Text = string.Empty; } } else { new Alert("O CPF inserido é inválido.", uiCSB.Toastr.Type.Warning); uiTxtSearch.Text = string.Empty; } } else if (uiTxtSearch.TextLength == 14) { if (UtilValidar.validarCNPJ(uiTxtSearch.Text)) { currentCustomerJuridico = new CustomerJuridico() { CNPJ = uiTxtSearch.Text }.ObterPorCNPJ(); if (currentCustomerJuridico != null) { } else { new Alert("Não possui cliente com o CNPJ inserido.", uiCSB.Toastr.Type.Warning); uiTxtSearch.Text = string.Empty; } } else { new Alert("O CNPJ inserido é inválido.", uiCSB.Toastr.Type.Warning); uiTxtSearch.Text = string.Empty; } } } }
private void uiTxtSearch_TextChanged(object sender, EventArgs e) { uiFlowPanel.Controls.Clear(); currentCustomerJuridico = null; currentCustomerFisico = null; if (uiTxtSearch.TextLength == 11) { if (UtilValidar.validarCPF(uiTxtSearch.Text)) { currentCustomerFisico = new CustomerFisico() { CPF = uiTxtSearch.Text }.ObterPorCPF(); if (currentCustomerFisico != null) { UtilCreatePanel.CreateCustomerFPanel(currentCustomerFisico, uiFlowPanel, Customer_Click); flowPanelCustomerF.Visible = false; } else { new Alert("Não possui cliente com o CPF inserido.", uiCSB.Toastr.Type.Warning); } } } else if (uiTxtSearch.TextLength == 14) { if (UtilValidar.validarCNPJ(uiTxtSearch.Text)) { currentCustomerJuridico = new CustomerJuridico() { CNPJ = uiTxtSearch.Text }.ObterPorCNPJ(); if (currentCustomerJuridico != null) { UtilCreatePanel.CreateCustomerJPanel(currentCustomerJuridico, uiFlowPanel, Customer_Click); flowPanelCustomerJ.Visible = false; } else { new Alert("Não possui cliente com o CNPJ inserido.", uiCSB.Toastr.Type.Warning); uiTxtSearch.Text = string.Empty; } } else { new Alert("O CNPJ inserido é inválido.", uiCSB.Toastr.Type.Warning); uiTxtSearch.Text = string.Empty; uiTxtSearch.Focus(); } } }
// Trocar object pelo objeto do Cliente public void MostrarCliente(CustomerFisico customerFisico = null, CustomerJuridico customerJuridico = null) { flowPanelCustomerF.Visible = false; flowPanelCustomerJ.Visible = false; if (currentCustomerFisico != null) { lblDado.Text = "REGISTRO GERAL"; uiPanelSecurity.Visible = true; uiPanelSecurity.Location = new Point(109, 113); } else if (currentCustomerJuridico != null) { lblDado.Text = "RAZÃO SOCIAL"; uiPanelSecurity.Visible = true; uiPanelSecurity.Location = new Point(109, 113); } }