Exemple #1
0
        private void Lst_Datos_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Cada cambio en el index de la lista carga por el ID los datos
            customersOP CuoP = new customersOP();

            Charge(CuoP.GetCustomerById(Ids[Lst_Datos.SelectedIndex]));
        }
Exemple #2
0
        private void Btn_Crear_Click(object sender, EventArgs e)
        {
            //-----------------------Crear Customer------------------
            Customer    NewCust = ChargeC();
            customersOP CuoP    = new customersOP();

            CuoP.CreateCustomer(NewCust);
            cleaner();
            Charge();
        }
Exemple #3
0
        public void Charge()//carga datos al list y ala lista
        {
            customersOP Custop = new customersOP();

            Lst_Datos.Items.Clear();
            foreach (Customer c in Custop.GetCustomers())
            {
                Lst_Datos.Items.Add(c.ContactName);
                Ids.Add(c.CustomerID);
            }
            Lst_Datos.SelectedIndex = 0;
            Charge(Custop.GetCustomerById(Ids[0]));//cargo el primero objeto de la lsita de strings ids
        }
Exemple #4
0
        private void Btn_Buscar_Click(object sender, EventArgs e)
        {
            string      identificador;
            customersOP Cuop = new customersOP();

            if (Txb_Id.Text != "")
            {
                identificador = Txb_Id.Text;
                Charge(Cuop.GetCustomerById(identificador));//metodo de carga de datos a textbox
            }
            else if (Txb_ContactName.Text != "")
            {
                identificador = Txb_ContactName.Text;
                Charge(Cuop.GetCustomerByName(identificador));
            }
        }
Exemple #5
0
        public void Edit(Customer cust)
        {
            customersOP Cuop = new customersOP();

            if (Txb_Addres.Text != "" && Txb_Addres.Text != cust.Address)
            {
                Cuop.UpdateCustomerAdress(cust.CustomerID, Txb_Addres.Text);
            }
            if (Txb_CompanyName.Text != "" && Txb_CompanyName.Text != cust.CompanyName)
            {
                Cuop.UpdateCustomerCompanyName(cust.CustomerID, Txb_CompanyName.Text);
            }
            if (Txb_ContactName.Text != "" && Txb_ContactName.Text != cust.ContactName)
            {
                Cuop.UpdateCustomerContactN(cust.CustomerID, Txb_ContactName.Text);
            }
            if (Txb_ContactTitle.Text != "" && Txb_ContactTitle.Text != cust.ContactTitle)
            {
                Cuop.UpdateCustomerCTitle(cust.CustomerID, Txb_ContactTitle.Text);
            }
            if (Txb_city.Text != cust.City)
            {
                Cuop.UpdateCustomerCity(cust.CustomerID, Txb_city.Text);
            }
            if (Txb_Region.Text != cust.Region)
            {
                Cuop.UpdateCustomerReg(cust.CustomerID, Txb_Region.Text);
            }
            if (Txb_Pc.Text != cust.PostalCode)
            {
                Cuop.UpdateCustomerCpostal(cust.CustomerID, Txb_Pc.Text);
            }
            if (Txb_Country.Text != "" && Txb_Country.Text != cust.Country)
            {
                Cuop.UpdateCustomerCountry(cust.CustomerID, Txb_Country.Text);
            }
            if (Txb_Phone.Text != cust.Phone)
            {
                Cuop.UpdateCustomerPnum(cust.CustomerID, Txb_Phone.Text);
            }
            if (Txb_Fax.Text != cust.Fax)
            {
                Cuop.UpdateCustomerFax(cust.CustomerID, Txb_Fax.Text);
            }
        }
Exemple #6
0
        private void Btn_Delete_Click(object sender, EventArgs e)
        {
            //--------------------Borrado de Customers--------------
            string      identificador;
            customersOP Cuop = new customersOP();

            if (Txb_Id.Text != "")
            {
                identificador = Txb_Id.Text;
                Cuop.DeleteCustomer(identificador);
            }
            else
            {
                MessageBox.Show("Escriba un ID para borrar");
            }
            Ids.RemoveRange(0, Lst_Datos.Items.Count);
            Charge();
        }
Exemple #7
0
        private void Btn_edit_Click(object sender, EventArgs e)
        {
            string      identificador;
            customersOP Cuop = new customersOP();

            if (Txb_Id.Text != "")
            {
                identificador = Txb_Id.Text;
                Edit(Cuop.GetCustomerById(identificador));//Metodo para editar los campos del objeto
            }
            else if (Txb_ContactName.Text != "")
            {
                identificador = Txb_ContactName.Text;
                Edit(Cuop.GetCustomerByName(identificador));
            }
            else
            {
                MessageBox.Show("Escriba un ID o un Nombre para actualizar");
            }
        }