Example #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     Console.WriteLine(comboBox1.SelectedIndex);
     if (comboBox1.SelectedIndex == 0)
     {
         SearchNaturalClient snc = new SearchNaturalClient();
         this.Hide();
         snc.ShowDialog();
         this.Show();
         NaturalClient nc = snc.ClientSelected;
         if (nc != null)
         {
             textBox1.Text = nc.Dni;
             textBox3.Text = nc.Name + " " + nc.Surname;
         }
     }
     else
     {
         Console.WriteLine("Searching Legal Client");
         SearchLegalClient slc = new SearchLegalClient();
         this.Hide();
         slc.ShowDialog();
         this.Show();
         LegalClient lc = slc.SelectedClient;
         if (lc != null)
         {
             textBox1.Text = lc.RUC;
             textBox3.Text = lc.CompanyName;
         }
     }
 }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            String ruc         = rucTextBox.Text;
            String phone       = phoneTextBox.Text;
            String email       = emailTextBox.Text;
            String address     = addressTextBox.Text;
            String companyName = companyNameTextBox.Text;

            bool flagOK = true;

            if (!DataValidation.ValidField(Constants.RucRegex, ruc, ref flagOK))
            {
                label3.ForeColor = Color.Red;
            }
            if (!DataValidation.ValidField(Constants.CompanyNameRegex, companyName, ref flagOK))
            {
                label5.ForeColor = Color.Red;
            }
            if (!DataValidation.ValidField(Constants.PlaceRegex, address, ref flagOK))
            {
                label8.ForeColor = Color.Red;
            }
            if (!DataValidation.ValidField(Constants.PhoneRegex, phone, ref flagOK))
            {
                label4.ForeColor = Color.Red;
            }
            if (!DataValidation.ValidField(Constants.EmailRegex, email, ref flagOK))
            {
                label6.ForeColor = Color.Red;
            }

            if (flagOK)
            {
                LegalClient lc = new LegalClient();
                lc.RUC = ruc; lc.PhoneNumber = phone; lc.Email = email; lc.Address = address; lc.CompanyName = companyName;
                try {
                    legalClientBL.addLegalClient(lc);
                    dataGridView1.DataSource = legalClientBL.listLegalClients("", "");
                    MessageBox.Show("El cliente ha sido registrado", "Registro de cliente nuevo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex) {
                    MessageBox.Show("Ya existe este cliente con RUC " + ruc, "Error al añadir cliente jurídico", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Error en uno o más campos. Revise los campos en rojo.", "Campos incompletas", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #3
0
 public EditLegalClient(LegalClient lc)
 {
     InitializeComponent();
     legalClientBL    = new LegalClientBL();
     selectedClient   = lc;
     textBox1.Text    = Constants.CurrentUserText;
     textBox2.Text    = selectedClient.CompanyName;
     textBox4.Text    = selectedClient.Address;
     textBox5.Text    = selectedClient.PhoneNumber;
     textBox6.Text    = selectedClient.Email;
     textBox2.Enabled = false;
     textBox4.Enabled = false;
     textBox5.Enabled = false;
     textBox6.Enabled = false;
     this.CenterToScreen();
 }
Example #4
0
        public BindingList <LegalClient> listLegalClients(string ruc, string name)
        {
            BindingList <LegalClient> list = new BindingList <LegalClient>();
            MySqlConnection           con  = new MySqlConnection(Constants.connectionString);

            con.Open();
            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection  = con;
            cmd.CommandText = "listLegalClients";
            cmd.CommandType = System.Data.CommandType.StoredProcedure;

            if (ruc.Length == 0)
            {
                cmd.Parameters.Add("_ruc", MySqlDbType.String).Value = DBNull.Value;
            }
            else
            {
                cmd.Parameters.Add("_ruc", MySqlDbType.String).Value = ruc;
            }

            if (name.Length == 0)
            {
                cmd.Parameters.Add("_companyName", MySqlDbType.String).Value = DBNull.Value;
            }
            else
            {
                cmd.Parameters.Add("_companyName", MySqlDbType.String).Value = name;
            }

            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                LegalClient lc = new LegalClient();
                lc.Address     = reader.GetString("Address");
                lc.CompanyName = reader.GetString("CompanyName");
                lc.Email       = reader.GetString("Email");
                lc.IdPerson    = reader.GetInt32("IdPerson");
                lc.PhoneNumber = reader.GetString("PhoneNumber");
                lc.RUC         = reader.GetString("Ruc");
                lc.Points      = reader.GetInt32("Points");
                list.Add(lc);
            }
            con.Close();
            return(list);
        }
Example #5
0
        private void button1_Click_2(object sender, EventArgs e)
        {
            Console.WriteLine(comboBox1.SelectedIndex);
            if (comboBox1.SelectedIndex == 0)
            {
                SearchNaturalClient snc = new SearchNaturalClient();
                this.Hide();
                snc.ShowDialog();
                this.Show();
                NaturalClient nc = snc.ClientSelected;
                if (nc != null)
                {
                    textBox1.Text      = nc.Dni;
                    textBox3.Text      = nc.Name + " " + nc.Surname;
                    pointsTextBox.Text = nc.Points.ToString();

                    nc.IdPerson = naturalClientBL.searchNaturalClient(nc.Dni);

                    idClient = nc.IdPerson;
                    Console.WriteLine("ID del cliente natural: " + nc.IdPerson);
                }
            }
            else
            {
                Console.WriteLine("Searching Legal Client");
                SearchLegalClient slc = new SearchLegalClient();
                this.Hide();
                slc.ShowDialog();
                this.Show();
                LegalClient lc = slc.SelectedClient;
                if (lc != null)
                {
                    textBox1.Text      = lc.RUC;
                    textBox3.Text      = lc.CompanyName;
                    pointsTextBox.Text = lc.Points.ToString();

                    lc.IdPerson = legalClientBL.searchLegalClient(lc.RUC);
                    idClient    = lc.IdPerson;
                    Console.WriteLine("ID del cliente legal: " + lc.IdPerson);
                }
            }
        }
Example #6
0
        public void addLegalClient(LegalClient lc)
        {
            MySqlConnection con = new MySqlConnection(Constants.connectionString);

            con.Open();
            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection  = con;
            cmd.CommandText = "addToBDLegalClient";
            cmd.CommandType = System.Data.CommandType.StoredProcedure;

            cmd.Parameters.Add("_address", MySqlDbType.String).Value     = lc.Address;
            cmd.Parameters.Add("_phoneNumber", MySqlDbType.String).Value = lc.PhoneNumber;
            cmd.Parameters.Add("_email", MySqlDbType.String).Value       = lc.Email;
            cmd.Parameters.Add("_companyName", MySqlDbType.String).Value = lc.CompanyName;
            cmd.Parameters.Add("_ruc", MySqlDbType.String).Value         = lc.RUC;

            cmd.ExecuteNonQuery();
            con.Close();
        }
Example #7
0
 public void updateLegalClient(LegalClient lc)
 {
     dataAccess.updateLegalClient(lc);
 }
Example #8
0
 public void addLegalClient(LegalClient lc)
 {
     dataAccess.addLegalClient(lc);
 }