Пример #1
0
        private void delete_Click(object sender, EventArgs e)
        {
            DataGridViewRow row      = dataGridView1.SelectedRows[0];
            Customer_DATA   castumer = new Customer_DATA();

            castumer.ID = Convert.ToInt16(row.Cells[0].Value);

            Customer_BLL.Delete_Customers(castumer);



            List <Customer_DATA> customer = new List <Customer_DATA>();

            customer = Customer_BLL.Select_ALL_Customers();
            DataTable table = new DataTable();

            table.Columns.Add("id");
            table.Columns.Add("name");
            table.Columns.Add("last name");
            table.Columns.Add("phone");
            table.Columns.Add("email");
            table.Columns.Add("image", typeof(byte[]));

            foreach (var item in customer)
            {
                table.Rows.Add(item.ID, item.First_Name, item.Last_Name, item.Tel, item.Email, item.Image);
            }


            dataGridView1.DataSource         = table;
            dataGridView1.Columns[5].Visible = false;
        }
        public static void Delete_Customers(Customer_DATA Customers)
        {
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("ID_CUSTOMER", Customers.ID));

            DBL.execute_query("CUSTOMER_delete", parameters);
        }
        public static void Insert_Customers(Customer_DATA Customers)
        {
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("IMAGE_CUSTOMER", Customers.Image));
            parameters.Add(new SqlParameter("FIRST_NAME", Customers.First_Name));
            parameters.Add(new SqlParameter("LAST_NAME", Customers.Last_Name));
            parameters.Add(new SqlParameter("TEL", Customers.Tel));
            parameters.Add(new SqlParameter("EMAIL", Customers.Email));
            DBL.execute_query("CUSTOMER_insert", parameters);
        }
Пример #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            Orders_DATA order = new Orders_DATA();

            order.User_id    = user_name.Id;
            order.Order_date = Convert.ToDateTime(dateTimePicker1.Text);
            Customer_DATA customer = new Customer_DATA();

            customer.ID       = Convert.ToInt16(id.Text);
            order.Customer    = customer;
            order.Total_paied = Convert.ToDouble(total_value.Text);
            Orders_BLL.Insert_Orders(order);

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                Products_DATA product = new Products_DATA();
                product.Id = Convert.ToInt16(row.Cells[0].Value);
                Orders_DATA orders = new Orders_DATA();
                orders = Orders_BLL.Select_ALL_Orders().Last();
                Order_Details_DATA order_details = new Order_Details_DATA();
                order_details.Quantity    = Convert.ToInt16(row.Cells[3].Value);
                order_details.Total_price = Convert.ToDouble(row.Cells[4].Value);
                order_details.Discount    = Convert.ToDouble(row.Cells[5].Value);
                order_details.Total_price_after_discount = Convert.ToDouble(row.Cells[6].Value);
                order_details.Order   = orders;
                order_details.Product = product;
                Order_Details_BLL.Insert_Order_Details(order_details);
            }


            id.Text                  = "";
            name.Text                = "";
            lastname.Text            = "";
            phone.Text               = "";
            email.Text               = "";
            textBox2.Text            = "";
            product_id.Text          = "";
            product_name.Text        = "";
            product_price.Text       = "";
            product_quantety.Text    = "";
            product_total_price.Text = "";
            product_discount.Text    = "";
            product_total.Text       = "";
            total_value.Text         = "";
            pictureBox1.Image        = null;
            button2.Enabled          = true;
            button3.Enabled          = false;
            table.Clear();
            dataGridView1.DataSource = table;
        }
Пример #5
0
        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            DataGridViewRow row      = dataGridView1.SelectedRows[0];
            Customer_DATA   Customer = new Customer_DATA();

            Customer.ID          = Convert.ToInt16(row.Cells[0].Value);
            Customer.First_Name  = row.Cells[1].Value.ToString();
            Customer.Last_Name   = row.Cells[2].Value.ToString();
            Customer.Tel         = row.Cells[3].Value.ToString();
            Customer.Email       = row.Cells[4].Value.ToString();
            Customer.Image       = (byte[])row.Cells[5].Value;
            Form_orders.Customer = Customer;
            Form_orders.Show();
            this.Close();
        }
        public static Customer_DATA Select_Item_Customers(int Id)
        {
            Customer_DATA       Customers  = new Customer_DATA();
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("ID_CUSTOMER", Id));

            Customers.ID         = (int)DBL.get_DATA_row("CUSTOMER_select", parameters)[0];
            Customers.First_Name = DBL.get_DATA_row("CUSTOMER_select", parameters)[1].ToString();
            Customers.Last_Name  = DBL.get_DATA_row("CUSTOMER_select", parameters)[2].ToString();
            Customers.Tel        = DBL.get_DATA_row("CUSTOMER_select", parameters)[3].ToString();
            Customers.Email      = DBL.get_DATA_row("CUSTOMER_select", parameters)[4].ToString();

            return(Customers);
        }
Пример #7
0
        private void update_Click(object sender, EventArgs e)
        {
            int current_count;

            current_count = count;
            DataGridViewRow row      = dataGridView1.SelectedRows[0];
            Customer_DATA   castumer = new Customer_DATA();

            castumer.ID         = Convert.ToInt16(row.Cells[0].Value);
            castumer.First_Name = name.Text;
            castumer.Last_Name  = surname.Text;
            castumer.Tel        = phone.Text;
            castumer.Email      = email.Text;
            MemoryStream memory = new MemoryStream();

            image.Image.Save(memory, image.Image.RawFormat);
            byte[] byte_image = memory.ToArray();
            castumer.Image = byte_image;
            Customer_BLL.Update_Customers(castumer);



            List <Customer_DATA> customer = new List <Customer_DATA>();

            customer = Customer_BLL.Select_ALL_Customers();
            DataTable table = new DataTable();

            table.Columns.Add("id");
            table.Columns.Add("name");
            table.Columns.Add("last name");
            table.Columns.Add("phone");
            table.Columns.Add("email");
            table.Columns.Add("image", typeof(byte[]));

            foreach (var item in customer)
            {
                table.Rows.Add(item.ID, item.First_Name, item.Last_Name, item.Tel, item.Email, item.Image);
            }


            dataGridView1.DataSource         = table;
            dataGridView1.Columns[5].Visible = false;
            bmb          = BindingContext[table];
            bmb.Position = current_count;
        }
        public static List <Customer_DATA> Select_ALL_Customers()
        {
            List <Customer_DATA> Categories = new List <Customer_DATA>();

            DataTable table = DBL.get_DATA("CUSTOMER_select_All");

            foreach (DataRow item in table.Rows)
            {
                Customer_DATA Customer = new Customer_DATA();
                Customer.ID         = Convert.ToInt16(item["ID_CUSTOMER"]);
                Customer.First_Name = item["FIRST_NAME"].ToString();
                Customer.Last_Name  = item["LAST_NAME"].ToString();
                Customer.Tel        = item["TEL"].ToString();
                Customer.Image      = (byte[])item["IMAGE_CUSTOMER"];
                Customer.Email      = item["EMAIL"].ToString();
                Categories.Add(Customer);
            }
            return(Categories);
        }
Пример #9
0
        public static Orders_DATA Select_Item_Orders(int Id)
        {
            Orders_DATA         Orders     = new Orders_DATA();
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("ID_ORDER", Id));

            Orders.Id         = Convert.ToInt16(DBL.get_DATA_row("ORDERS_select", parameters)[0]);
            Orders.Order_date = (DateTime)DBL.get_DATA_row("ORDERS_select", parameters)[1];
            Customer_DATA customer = new Customer_DATA();

            customer.ID = Convert.ToInt16(DBL.get_DATA_row("ORDERS_select", parameters)[2]);

            Orders.Customer    = customer;
            Orders.User_id     = Convert.ToInt16(DBL.get_DATA_row("ORDERS_select", parameters)[3]);
            Orders.Total_paied = Convert.ToDouble(DBL.get_DATA_row("ORDERS_select", parameters)[4]);
            Orders.Customer    = new Customer_DATA();
            return(Orders);
        }
Пример #10
0
        private void add_Click(object sender, EventArgs e)
        {
            Customer_DATA castumer = new Customer_DATA();

            castumer.First_Name = name.Text;
            castumer.Last_Name  = surname.Text;
            castumer.Tel        = phone.Text;
            castumer.Email      = email.Text;
            MemoryStream memory = new MemoryStream();

            image.Image.Save(memory, image.Image.RawFormat);
            byte[] byte_image = memory.ToArray();
            castumer.Image = byte_image;
            Customer_BLL.Insert_Customers(castumer);


            List <Customer_DATA> customer = new List <Customer_DATA>();

            customer = Customer_BLL.Select_ALL_Customers();
            DataTable table = new DataTable();

            table.Columns.Add("id");
            table.Columns.Add("name");
            table.Columns.Add("last name");
            table.Columns.Add("phone");
            table.Columns.Add("email");
            table.Columns.Add("image", typeof(byte[]));

            foreach (var item in customer)
            {
                table.Rows.Add(item.ID, item.First_Name, item.Last_Name, item.Tel, item.Email, item.Image);
            }


            dataGridView1.DataSource         = table;
            dataGridView1.Columns[5].Visible = false;


            add.Enabled     = false;
            add_new.Enabled = true;
            bmb             = BindingContext[table];
            bmb.Position    = count_ALL_items;
        }
Пример #11
0
        public static List <Orders_DATA> Select_ALL_Orders_By_Customer_Id(int Customer_Id)
        {
            List <Orders_DATA> Orders = new List <Orders_DATA>();
            Orders_DATA        Order  = new Orders_DATA();
            DataTable          table  = DBL.get_DATA("ORDERS_select_All");

            foreach (DataRow item in table.Rows)
            {
                Order.Id         = Convert.ToInt16(item["ID_ORDER"]);
                Order.Order_date = (DateTime)item["DATE_ORDERS"];
                Customer_DATA customer = new Customer_DATA();
                customer.ID       = Convert.ToInt16(item["ID_CUSTOMER"]);
                Order.Customer    = customer;
                Order.Total_paied = Convert.ToDouble(item["Total_paied"]);

                Orders.Add(Order);
            }

            Orders = Orders.Where(x => x.Customer.ID == Customer_Id).ToList();
            return(Orders);
        }
Пример #12
0
        private void button1_Click(object sender, EventArgs e)
        {
            bill_2      bill  = new bill_2();
            Orders_DATA Order = new Orders_DATA();

            Order.Id = Convert.ToInt16(dataGridView1.SelectedRows[0].Cells[0].Value);
            //Order.Order_date = DateTime.ParseExact(dataGridView1.SelectedRows[0].Cells[1].Value.ToString(), "dd/MM/yyyy", null);
            Customer_DATA Customer = new Customer_DATA();

            Customer.ID = Convert.ToInt16(dataGridView1.SelectedRows[0].Cells[2].Value);

            Customer.First_Name = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();

            Customer.Last_Name = dataGridView1.SelectedRows[0].Cells[4].Value.ToString();
            Order.User_id      = Convert.ToInt16(dataGridView1.SelectedRows[0].Cells[5].Value);
            Order.Total_paied  = Convert.ToDouble(dataGridView1.SelectedRows[0].Cells[6].Value);

            bill.Order          = Order;
            bill.Order.Customer = Customer;

            bill.Show();
        }
Пример #13
0
 public static Customer_DATA Select_Item_Customers(Customer_DATA Customers)
 {
     return(Customer_DAL.Select_Item_Customers(Customers.ID));
 }
Пример #14
0
 public static void Update_Customers(Customer_DATA Customers)
 {
     Customer_DAL.Update_Customers(Customers);
 }
Пример #15
0
 public static void Delete_Customers(Customer_DATA Customers)
 {
     Customer_DAL.Delete_Customers(Customers);
 }
Пример #16
0
        private void bills_Load(object sender, EventArgs e)
        {
            DataTable table = new DataTable();

            table.Columns.Add("Id");
            table.Columns.Add("first_Name");
            table.Columns.Add("last_Name");
            table.Columns.Add("tel");
            table.Columns.Add("email");
            table.Columns.Add("order_date");
            table.Columns.Add("user_name");

            DataTable details_table = new DataTable();

            details_table.Columns.Add("quantity");
            details_table.Columns.Add("total_price");
            details_table.Columns.Add("discount");
            details_table.Columns.Add("total_price_after_discount");
            details_table.Columns.Add("label_product");
            details_table.Columns.Add("price");



            Order_Details_DATA order_details = new Order_Details_DATA();

            order_details.Order          = new Orders_DATA();
            order_details.Order.Customer = new Customer_DATA();
            order_details = Order_Details_BLL.Select_ALL_Order_Details().Last();
            Customer_DATA customer = new Customer_DATA();


            List <Orders_DATA> order = new List <Orders_DATA>();

            order = Orders_BLL.Select_ALL_Orders();

            foreach (var item in order)
            {
                if (order_details.Order.Id == item.Id)
                {
                    order_details.Order.Customer = Customer_BLL.Select_Item_Customers(item.Customer);
                }
            }

            List <Order_Details_DATA> list_order_details = new List <Order_Details_DATA>();

            list_order_details = Order_Details_BLL.Select_ALL_Order_Details();

            list_order_details = Order_Details_BLL.Select_ALL_Order_Details().Where(x => x.Order.Id == order_details.Order.Id).ToList();

            Users user = new Users();


            List <Users> user_list = new List <Users>();
            DataTable    tables    = DBL.get_DATA("Select_Users");

            foreach (DataRow item in tables.Rows)
            {
                user_list.Add(new Users(item["Name"].ToString(), item["Password"].ToString(), Convert.ToInt16(item["ID_User"])));
            }



            user.Id = order_details.Order.User_id;
            user    = user_list.Single(x => x.Id == user.Id);


            table.Rows.Add(
                order_details.Order.Id,
                order_details.Order.Customer.First_Name,
                order_details.Order.Customer.Last_Name,
                order_details.Order.Customer.Tel,
                order_details.Order.Customer.Email,
                order_details.Order.Order_date,
                user.Name
                );
            foreach (var item in list_order_details)
            {
                details_table.Rows.Add(
                    item.Quantity,
                    item.Total_price,
                    item.Discount,
                    item.Total_price_after_discount,
                    item.Product.Label_product,
                    item.Product.Price
                    );
            }

            CrystalReport_bill s = new CrystalReport_bill();



            s.Subreports[0].SetDataSource(details_table);
            s.Subreports[0].AfterFormatPage += Bills_AfterFormatPage;
            s.SetDataSource(table);
            crystalReportViewer1.ReportSource = s;
        }
Пример #17
0
 public static void Insert_Customers(Customer_DATA Customers)
 {
     Customer_DAL.Insert_Customers(Customers);
 }