Esempio n. 1
0
        public static List<PersonObj> getAllByKindId(int kind)
        {
            List<PersonObj> list = new List<PersonObj>();
                try
                {
                    Connection c = new Connection();
                    MySqlCommand cmd = c.con.CreateCommand();
                    cmd.CommandText = "select * from person where kind=" + kind;
                    c.con.Open();
                    MySqlDataReader r = cmd.ExecuteReader();
                    while (r.Read())
                    {
                        PersonObj product = new PersonObj();
                        product.id = r.GetInt32("id");
                        product.name = r.GetString("name");
                        product.lastname = r.GetString("lastname");

                        product.address = r.GetString("address1");
                        product.phone = r.GetString("phone1");
                        product.email = r.GetString("email1");
                        list.Add(product);
                    }
                }
                catch (MySqlException me)
                {

                    MessageBox.Show(me.Message);

                }
            return list;
        }
Esempio n. 2
0
        public SellDialog()
        {
            InitializeComponent();
            data.Columns.Add("id", "Id");
            data.Columns.Add("cant", "Cant");
            data.Columns.Add("producto", "Producto");
            data.Columns.Add("unidad", "Unidad");
            data.Columns.Add("pu", "Precio Unitario");
            data.Columns.Add("total", "Total");
            data.Columns[0].Width = 50;
            data.Columns[1].Width = 50;
            data.Columns[2].Width = 200;
            data.Columns[3].Width = 100;
            data.Columns[4].Width = 100;
            data.Columns[5].Width = 100;

            lp = PersonObj.getAllByKindId(1);
            foreach (PersonObj p in lp)
            {
                client_.Items.Add(p.name + " " + p.lastname);
            }


            List <SellObj> sell  = SellObj.sell;
            float          total = 0;

            for (int i = 0; i < sell.Count; i++)
            {
                ProductObj product = ProductObj.getById(sell[i].product_id);
                data.Rows.Add(product.id, sell[i].q, product.name, product.unit, product.price_out, sell[i].q * product.price_out);
                total += sell[i].q * product.price_out;
            }
            data.Rows.Add("", "", "Total", "", "", total);
        }
Esempio n. 3
0
        public static List <PersonObj> getAllByKindId(int kind)
        {
            List <PersonObj> list = new List <PersonObj>();

            try
            {
                Connection   c   = new Connection();
                MySqlCommand cmd = c.con.CreateCommand();
                cmd.CommandText = "select * from person where kind=" + kind;
                c.con.Open();
                MySqlDataReader r = cmd.ExecuteReader();
                while (r.Read())
                {
                    PersonObj product = new PersonObj();
                    product.id       = r.GetInt32("id");
                    product.name     = r.GetString("name");
                    product.lastname = r.GetString("lastname");

                    product.address = r.GetString("address1");
                    product.phone   = r.GetString("phone1");
                    product.email   = r.GetString("email1");
                    list.Add(product);
                }
            }
            catch (MySqlException me)
            {
                MessageBox.Show(me.Message);
            }
            return(list);
        }
Esempio n. 4
0
        public void load_persons()
        {
            dataGridView1.Rows.Clear();
            List <PersonObj> list = PersonObj.getAllByKindId(kind);

            for (int i = 0; i < list.Count; i++)
            {
                //MessageBox.Show(input + " - " + output);
                dataGridView1.Rows.Add(list[i].id, list[i].name, list[i].lastname, list[i].address, list[i].email, list[i].phone);
            }
        }
Esempio n. 5
0
        public static PersonObj getById(int product_id)
        {
            Connection c = new Connection();
            MySqlCommand cmd = c.con.CreateCommand();
            cmd.CommandText = "select * from product where id=" + product_id;
            c.con.Open();
            MySqlDataReader r = cmd.ExecuteReader();
            PersonObj product = new PersonObj();
            while (r.Read())
            {

                product.id= r.GetInt32("id");
                product.name = r.GetString("name");
                product.lastname = r.GetString("lastname");

                product.address = r.GetString("address1");
                product.phone = r.GetString("phone1");
                product.email = r.GetString("email1");
                break;

            }
            return product;
        }
Esempio n. 6
0
        public static PersonObj getById(int product_id)
        {
            Connection   c   = new Connection();
            MySqlCommand cmd = c.con.CreateCommand();

            cmd.CommandText = "select * from product where id=" + product_id;
            c.con.Open();
            MySqlDataReader r       = cmd.ExecuteReader();
            PersonObj       product = new PersonObj();

            while (r.Read())
            {
                product.id       = r.GetInt32("id");
                product.name     = r.GetString("name");
                product.lastname = r.GetString("lastname");

                product.address = r.GetString("address1");
                product.phone   = r.GetString("phone1");
                product.email   = r.GetString("email1");
                break;
            }
            return(product);
        }
Esempio n. 7
0
 public Re()
 {
     InitializeComponent();
     prods = ProductObj.getAll();
     provs = PersonObj.getAllByKindId(2);
     foreach (ProductObj p in prods)
     {
         product.Items.Add(p.name);
     }
     foreach (PersonObj p in provs)
     {
         provider.Items.Add(p.name + " " + p.lastname);
     }
     data.Columns.Add("id", "Id");
     data.Columns.Add("unidad", "Unidad");
     data.Columns.Add("nombre", "Nombre");
     data.Columns.Add("cantidad", "Cantidad");
     data.Columns.Add("precio", "Precio");
     data.Columns[0].Width = 50;
     data.Columns[1].Width = 100;
     data.Columns[2].Width = 350;
     data.Columns[3].Width = 100;
     data.Columns[4].Width = 100;
 }