private void btn_AddToBills_Click(object sender, EventArgs e)
        {
            var product_query =
                (from p in context.products
                 where p.ProductName == name && p.status == false
                 select p).FirstOrDefault();

            if (double.Parse(numericQuantity.Value.ToString()) > product_query.quantityPerProducts)
            {
                MessageBox.Show("هذه الكميه غير متوفره");
            }
            else
            {
                product_query.quantityPerProducts = product_query.quantityPerProducts - double.Parse(numericQuantity.Value.ToString());
                context.SaveChanges();
                int row = 0;
                dgv_SalesBill.Rows.Add();
                row = dgv_SalesBill.Rows.Count - 2;

                dgv_SalesBill["ProductID", row].Value       = id.ToString();
                dgv_SalesBill["productName", row].Value     = cmb_ProductName.SelectedValue;
                dgv_SalesBill["productQuantity", row].Value = numericQuantity.Value;
                dgv_SalesBill["price", row].Value           = textBoxProductPrice.Text;
                dgv_SalesBill["discount", row].Value        = numericDiscount.Value;
            }
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "Customer_ID,Customer_Firstname,Customer_Lastname,Customer_Cell,Customer_Home,Customer_Address,Customer_State,Customer_Zip")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customer.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "ProductID,Product_name,Product_Description,Product_Wholesaler_Cost,Product_Min_Price,Product_Max_Price,Product_Quantity")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Product.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product));
        }
Esempio n. 4
0
        public ActionResult Create(Order order)
        {
            if (ModelState.IsValid)
            {
                db.Order.Add(order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(order));
        }
        private void btn_Savebuy_Click(object sender, EventArgs e)
        {
            if (dgv_SalesBillbuy.SelectedRows.Count == 0)
            {
                MessageBoxIcon.Warning.ToString();
                MessageBox.Show("قائمة المنتجات فارغة");
            }
            else
            {
                //numTotalCost.Value = decimal.Parse(numTotalCost.Value.ToString());
                //numResCost.Value = numTotalCost.Value - numericPaiedCost.Value;
                SalesOrder salesOrder = new SalesOrder();
                salesOrder.SalesRepresentative_id = int.Parse(cmb_companyName.SelectedValue.ToString());
                // check==> salesOrder.salesRepresentative_ID = int.Parse(cmb_companyName.SelectedValue.ToString());
                salesOrder.SalesOrderDate        = dtp_BillDate.Value;
                salesOrder.SalesOrederTotalPrice = double.Parse(numericResCostbuy.Value.ToString());
                salesOrder.status = false;
                context.SalesOrder.Add(salesOrder);
                context.SaveChanges();
                context = new store();
                ///sales order payment
                SalesOredersPaymment oredersPaymment = new SalesOredersPaymment();
                oredersPaymment.Paied         = double.Parse(numericPaiedCostbuy.Value.ToString());
                oredersPaymment.Rest          = double.Parse(numericResCostbuy.Value.ToString());
                oredersPaymment.SalesOrder_id = salesOrder.ID;
                context.SalesOredersPaymments.Add(oredersPaymment);
                context.SaveChanges();
                context = new store();
                for (var item = 0; item < dgv_SalesBillbuy.Rows.Count - 1; item++)
                {
                    SalesOrderDetails orderDetail = new SalesOrderDetails();
                    orderDetail.products_id   = int.Parse(dgv_SalesBillbuy.Rows[item].Cells[4].Value.ToString());
                    orderDetail.quantity      = int.Parse(dgv_SalesBillbuy.Rows[item].Cells[2].Value.ToString());
                    orderDetail.salesOrder_id = salesOrder.ID;
                    context.SalesOrderDetails.Add(orderDetail);
                }

                context.SaveChanges();

                context = new store();
                for (var item = 0; item <= dgv_SalesBillbuy.Rows.Count - 1; item++)
                {
                    int      pidd    = Int32.Parse(dgv_SalesBillbuy.Rows[item].Cells[4].Value.ToString());
                    Products product = context.products.FirstOrDefault(d => d.ID == pidd);
                    product.quantityPerProducts += int.Parse(dgv_SalesBillbuy.Rows[item].Cells[2].Value.ToString());
                }
                context.SaveChanges();

                MessageBox.Show("تم العمليه بنجاح");
                clearFields();
            }
        }
Esempio n. 6
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            store.SaveChanges();
            details = store.SalesOrderDetails.Where(s => s.salesOrder_id == SalesOrder.ID).ToList();

            double totalCost = 0;

            numericResCost.Value.ToString();
            numericTotalCost.Value.ToString();
            for (var item = 0; item < dgv_SalesBill.Rows.Count - 1; item++)
            {
                totalCost +=
                    double.Parse(dgv_SalesBill.Rows[item].Cells[1].Value.ToString()) *
                    double.Parse(dgv_SalesBill.Rows[item].Cells[2].Value.ToString()) -
                    double.Parse(dgv_SalesBill.Rows[item].Cells[0].Value.ToString());
            }
            numericTotalCost.Value = decimal.Parse(totalCost.ToString());
            numericResCost.Value   = numericTotalCost.Value - numericPaiedCost.Value;

            /// salesOrder.customers_Id = store.customers.FirstOrDefault(c => c.Name == cmb_CustomerName.Text).ID;
            SalesOrder.SalesOrderDate        = dtp_BillDate.Value;
            SalesOrder.SalesOrederTotalPrice = double.Parse(numericTotalCost.Value.ToString());

            //  salesOrder.SalesRepresentative.ID = store.SalesRepresentatives.FirstOrDefault(s => s.ID == int.Parse(mandobCompobox.SelectedValue.ToString())).ID;

            store.SaveChanges();
            // store = new store();
            ///sales order payment
            //SalesOredersPaymment salesOredersPaymment = new SalesOredersPaymment();
            SalesOredersPaymment.Paied = double.Parse(numericPaiedCost.Value.ToString());
            SalesOredersPaymment.Rest  = double.Parse(numericResCost.Value.ToString());
            //  SalesOredersPaymment.SalesOrder_id = SalesOrder.ID;
            //store.SalesOredersPaymments.Add(SalesOredersPaymment);
            store.SaveChanges();
            //store = new store();
            var i = 0;

            foreach (var item in details)
            {
                //  SalesOrderDetails salesOrderDetails = new SalesOrderDetails();
                item.products_id = int.Parse(dgv_SalesBill.Rows[i].Cells[4].Value.ToString());
                item.quantity    = int.Parse(dgv_SalesBill.Rows[i].Cells[2].Value.ToString());
                //item.salesOrder_id = SalesOrder.ID;
                i++;

                // store.SalesOrderDetails.Add(salesOrderDetails);
            }

            store.SaveChanges();
            MessageBox.Show("تم العمليه بنجاح");
        }
        private void btn_Save_Click(object sender, EventArgs e)
        {
            context.SaveChanges();
            details = context.GeneralBillDetails.Where(s => s.generalBill_Id == GeneralBill.ID).ToList();

            double totalCost = 0;

            numResCost.Value.ToString();
            numTotalCost.Value.ToString();
            for (var item = 0; item <= dgv_SalesBill.Rows.Count - 1; item++)
            {
                totalCost +=
                    double.Parse(dgv_SalesBill.Rows[item].Cells[1].Value.ToString()) *
                    double.Parse(dgv_SalesBill.Rows[item].Cells[2].Value.ToString()) -
                    double.Parse(dgv_SalesBill.Rows[item].Cells[0].Value.ToString());
            }
            numTotalCost.Value = decimal.Parse(totalCost.ToString());
            numResCost.Value   = numTotalCost.Value - numericPaiedCost.Value;

            /// salesOrder.customers_Id = store.customers.FirstOrDefault(c => c.Name == cmb_CustomerName.Text).ID;
            GeneralBill.BillDate  = dtp_GBillDate.Value;
            GeneralBill.totalCost = double.Parse(numTotalCost.Value.ToString());
            var id = int.Parse(Cmb_Employee.SelectedValue.ToString());

            GeneralBill.employee_Id = context.employee.FirstOrDefault(s => s.ID == id).ID;

            context.SaveChanges();
            GeneralBillPayment.Paied = double.Parse(numericPaiedCost.Value.ToString());
            GeneralBillPayment.Rest  = double.Parse(numResCost.Value.ToString());
            //  SalesOredersPaymment.SalesOrder_id = SalesOrder.ID;
            //store.SalesOredersPaymments.Add(SalesOredersPaymment);
            context.SaveChanges();
            //store = new store();
            var i = 0;

            foreach (var item in details)
            {
                //  SalesOrderDetails salesOrderDetails = new SalesOrderDetails();
                item.Product_Id = int.Parse(dgv_SalesBill.Rows[i].Cells[4].Value.ToString());
                item.Quantity   = int.Parse(dgv_SalesBill.Rows[i].Cells[2].Value.ToString());
                //item.salesOrder_id = SalesOrder.ID;
                i++;
                // store.SalesOrderDetails.Add(salesOrderDetails);
            }

            context.SaveChanges();
            MessageBox.Show("تم العمليه بنجاح");
        }
Esempio n. 8
0
        private void BtupdateCustomer_Click(object sender, EventArgs e)
        {
            var query2 = store.employee.FirstOrDefault(m => m.EmployeeName == MandobNametextBox1.Text);
            var check  = store.SalesRepresentatives.FirstOrDefault(s => s.Employee_Id == query2.ID);

            if (check != null)
            {
                store = new store();
                p_id  = int.Parse(DGV_Customer.SelectedRows[0].Cells[0].Value.ToString());
                var query = store.SalesRepresentatives.FirstOrDefault(p => p.ID == p_id);
                var q     = store.employee.FirstOrDefault(m => m.ID == query.Employee_Id);
                q.EmployeeName = MandobNametextBox1.Text.ToString();
                q.Address      = CustomerAddressTxt.Text.ToString();
                q.Phone        = CustomerPhoneTxt.Text.ToString();

                store.SaveChanges();

                bindGridView();
                CustomerAddressTxt.Text = "";
                CustomerPhoneTxt.Text   = "";
                MandobNametextBox1.Text = "";
            }
            else
            {
                MessageBox.Show("هذا المندوب موجود  بالفعل");
                MandobNametextBox1.Text = "";
            }
        }
Esempio n. 9
0
        private void BtupdateCustomer_Click(object sender, EventArgs e)
        {
            if (CustomerNameTxt.Text == null || CustomerAddressTxt.Text == null || CustomerPhoneTxt.Text == null ||
                CustomerTypecomboBox.SelectedItem == null)

            {
                MessageBox.Show("يجب ان تدخل كل البيانات");
            }
            else
            {
                store = new store();
                p_id  = int.Parse(DGV_Customer.SelectedRows[0].Cells[0].Value.ToString());
                var query = store.customers.FirstOrDefault(p => p.ID == p_id);
                query.Name    = CustomerNameTxt.Text.ToString();
                query.addrees = CustomerAddressTxt.Text.ToString();
                query.Phone   = CustomerPhoneTxt.Text.ToString();
                query.type    = CustomerTypecomboBox.SelectedItem.ToString();
                store.SaveChanges();
                MessageBox.Show("تم التعديل بنجاح");
                CustomerNameTxt.Text    = "";
                CustomerAddressTxt.Text = "";
                CustomerPhoneTxt.Text   = "";
                bindGridView();
            }
        }
        private void Btn_SaveSupplier_Click(object sender, EventArgs e)
        {
            if (Txt_SupplierName.Text == "" || Txt_SupplierPhone.Text == "" ||
                Txt_SupplierAdress.Text == "" ||
                Txt_companyReponSupplier.Text == "")
            {
                MessageBox.Show("يجب إدخال جميع البيانات بشكل صحيح");
            }
            else
            {
                if (flagSave == false)
                {
                    Suppliers suppliers = new Suppliers();
                    suppliers.Name                  = Txt_SupplierName.Text;
                    suppliers.SupplierPhone         = Txt_SupplierPhone.Text;
                    suppliers.Address               = Txt_SupplierAdress.Text;
                    suppliers.CompanyRepresentative = Txt_companyReponSupplier.Text;
                    store.suppliers.Add(suppliers);
                    store.SaveChanges();
                    Txt_companyReponSupplier.Text = "";
                    Txt_SupplierAdress.Text       = "";
                    Txt_SupplierName.Text         = "";
                    Txt_SupplierPhone.Text        = "";
                    RefreshDataGridViewSupplier();
                }
                else
                {
                    int       id        = int.Parse(DGV_SupplierHome.SelectedRows[0].Cells[4].Value.ToString());
                    Suppliers suppliers = store.suppliers.FirstOrDefault(s => s.ID == id);
                    suppliers.Name                  = Txt_SupplierName.Text;
                    suppliers.SupplierPhone         = Txt_SupplierPhone.Text;
                    suppliers.Address               = Txt_SupplierAdress.Text;
                    suppliers.CompanyRepresentative = Txt_companyReponSupplier.Text;
                    store.SaveChanges();

                    Txt_companyReponSupplier.Text = "";
                    Txt_SupplierAdress.Text       = "";
                    Txt_SupplierName.Text         = "";
                    Txt_SupplierPhone.Text        = "";

                    RefreshDataGridViewSupplier();
                }
            }
        }
Esempio n. 11
0
        private void UpdateBtnEmployee_Click_1(object sender, EventArgs e)
        {
            // save
            var query = store.employee.FirstOrDefault(p => p.ID == p_id);

            query.EmployeeName = EmployeeNamrTxt.Text.ToString();
            query.Address      = EmployeeAddressTxt.Text.ToString();
            query.NationalId   = EmployeeNationalIDTxt.Text.ToString();
            query.Salary       = float.Parse(EmployeeSalaryTxt.Text.ToString());
            query.Phone        = EmployeePhoneTxt.Text.ToString();
            store.SaveChanges();
            bindGridView();
            EmployeeAddressTxt.Text    = "";
            EmployeeNamrTxt.Text       = "";
            EmployeeSalaryTxt.Text     = "";
            EmployeeNationalIDTxt.Text = "";
            EmployeePhoneTxt.Text      = "";
            UpdateBtnEmployee.Show();
        }
        private void btn_Save_Click(object sender, EventArgs e)
        {
            numTotalCost.Value = decimal.Parse(numTotalCost.Value.ToString());
            numResCost.Value   = numTotalCost.Value - numericPaiedCost.Value;
            GeneralBill generalBill = new GeneralBill();

            generalBill.customers_Id = int.Parse(cmb_CustomerN.SelectedValue.ToString());
            generalBill.employee_Id  = int.Parse(Cmb_Employee.SelectedValue.ToString());
            generalBill.BillDate     = dtp_GBillDate.Value;
            generalBill.totalCost    = double.Parse(numTotalCost.Value.ToString());
            generalBill.status       = false;
            context.GeneralBills.Add(generalBill);
            context.SaveChanges();
            context = new store();
            ///sales order payment
            GeneralBillPayment billPayment = new GeneralBillPayment();

            billPayment.Paied          = double.Parse(numericPaiedCost.Value.ToString());
            billPayment.Rest           = double.Parse(numResCost.Value.ToString());
            billPayment.generalBill_Id = generalBill.ID;
            context.GeneralBillPayments.Add(billPayment);
            context.SaveChanges();
            context = new store();
            for (var item = 0; item <= dgv_SalesBill.Rows.Count - 1; item++)
            {
                GeneralBillDetails billDetail = new GeneralBillDetails();
                billDetail.Product_Id     = int.Parse(dgv_SalesBill.Rows[item].Cells[4].Value.ToString());
                billDetail.Quantity       = int.Parse(dgv_SalesBill.Rows[item].Cells[2].Value.ToString());
                billDetail.generalBill_Id = generalBill.ID;
                context.GeneralBillDetails.Add(billDetail);
                var product = context.products.FirstOrDefault(p => p.ID == billDetail.Product_Id);
                product.quantityPerProducts -= billDetail.Quantity;
            }

            context.SaveChanges();

            context = new store();
            for (var item = 0; item < dgv_SalesBill.Rows.Count - 1; item++)
            {
                int      pidd    = Int32.Parse(dgv_SalesBill.Rows[item].Cells[4].Value.ToString());
                Products product = context.products.FirstOrDefault(d => d.ID == pidd);
                product.quantityPerGroup -= int.Parse(dgv_SalesBill.Rows[item].Cells[2].Value.ToString());
            }
            context.SaveChanges();

            MessageBox.Show("تم العمليه بنجاح");
            numericPaiedCost.Value = 0;
            numericDiscount.Value  = 0;
            numericQuantity.Value  = 0;
            numResCost.Value       = 0;
            numTotalCost.Value     = 0;
            dgv_SalesBill.Rows.Clear();
        }
Esempio n. 13
0
        private void deleteBtnEmp_Click_1(object sender, EventArgs e)
        {
            store = new store();
            DGV_EmployeeHome.DataSource = null;
            DGV_EmployeeHome.Update();
            DGV_EmployeeHome.Refresh();
            var id    = int.Parse(DGV_EmployeeHome.SelectedRows[0].Cells[4].Value.ToString());
            var query = store.employee.FirstOrDefault(p => p.ID == id);

            query.Status = true;
            store.SaveChanges();
            bindGridView();
        }
Esempio n. 14
0
        private void delCustomer_Click(object sender, EventArgs e)
        {
            store = new store();
            DGV_Customer.DataSource = null;
            DGV_Customer.Update();
            DGV_Customer.Refresh();
            var id    = int.Parse(DGV_Customer.SelectedRows[0].Cells[0].Value.ToString());
            var query = store.customers.FirstOrDefault(p => p.ID == id);

            query.Status = true;
            store.SaveChanges();
            bindGridView();
        }
        private void deleteBtnSupplier_Click(object sender, EventArgs e)
        {
            store = new store();
            DGV_SupplierHome.DataSource = null;
            DGV_SupplierHome.Update();
            DGV_SupplierHome.Refresh();
            var id    = int.Parse(DGV_SupplierHome.SelectedRows[0].Cells[4].Value.ToString());
            var query = store.suppliers.FirstOrDefault(p => p.ID == id);

            query.status = true;
            store.SaveChanges();
            RefreshDataGridViewSupplier();
        }
Esempio n. 16
0
        private void EditBtn_Click(object sender, EventArgs e)
        {
            var      P_id     = int.Parse(dgv_SalesBill.SelectedRows[0].Cells[6].Value.ToString());
            Products products = store.products.FirstOrDefault(p => p.ID == P_id);

            products.ProductName            = Txt_ProductNameUp.Text;
            products.Discount               = double.Parse(numericDiscountProUp.Text);
            products.IncomePrice            = double.Parse(numericIncomingPriceProUp.Text);
            products.NumberOfProductInGroup = int.Parse(numericQuantityPackageProUp.Value.ToString());
            products.quantityPerProducts    = int.Parse(numericQuantityProUp.Value.ToString());
            products.Price_customer         = double.Parse(numericIndvidualPriceProUp.Text);
            int s_id = int.Parse(Como_productBuySupplierUp.SelectedValue.ToString());

            products.supplier_id    = s_id;
            products.categories_id  = int.Parse(Como_productCategoryUpdate.SelectedValue.ToString());
            products.ProductUnit_id = int.Parse(Como_productUnitUpdate.SelectedValue.ToString());
            // store.products.Add(products);
            store.SaveChanges();
            MessageBox.Show("تم تعديل المنتج");
            AddProPanel.Hide();

            bindGridView();
        }
Esempio n. 17
0
        private void SaveBTn_Click(object sender, EventArgs e)
        {
            double totalCost = 0;

            for (var item = 0; item < DGV_SpendProducts.Rows.Count - 1; item++)
            {
                totalCost +=
                    double.Parse(DGV_SpendProducts.Rows[item].Cells[0].Value.ToString()) *
                    double.Parse(DGV_SpendProducts.Rows[item].Cells[1].Value.ToString());
            }
            ;
            var id     = int.Parse(CMB_MndobName.SelectedValue.ToString());
            var SaleID = store.SalesRepresentatives.FirstOrDefault(c => c.ID == id).ID;

            Orders.SalesRepresentative_Id = SaleID;
            Orders.OrderDate = DTV_ٍSpendDate.Value;
            Orders.TotalCost = totalCost;

            //  salesOrder.SalesRepresentative.ID = context.SalesRepresentatives.FirstOrDefault(s => s.ID == int.Parse(mandobCompobox.SelectedValue.ToString())).ID;
            store.SaveChanges();
            ///sales order payment
            var i = 0;

            foreach (var item in OrdersDetails)
            {
                //  SalesOrderDetails salesOrderDetails = new SalesOrderDetails();
                item.products_id = int.Parse(DGV_SpendProducts.Rows[i].Cells[3].Value.ToString());
                item.quantity    = int.Parse(DGV_SpendProducts.Rows[i].Cells[1].Value.ToString());
                //item.salesOrder_id = SalesOrder.ID;
                i++;
                // store.SalesOrderDetails.Add(salesOrderDetails);
            }

            store.SaveChanges();
            MessageBox.Show("تم العمليه بنجاح");
        }
        private void btn_Save_Click(object sender, EventArgs e)
        {
            double totalCost = 0;

            for (var item = 0; item < dgv_SalesBill.Rows.Count - 1; item++)
            {
                totalCost +=
                    double.Parse(dgv_SalesBill.Rows[item].Cells[1].Value.ToString()) *
                    double.Parse(dgv_SalesBill.Rows[item].Cells[2].Value.ToString()) -
                    double.Parse(dgv_SalesBill.Rows[item].Cells[0].Value.ToString());
            }
            numericTotalCost.Value = decimal.Parse(totalCost.ToString());
            numericResCost.Value   = numericTotalCost.Value - numericPaiedCost.Value;
            SalesOrder salesOrder = new SalesOrder();

            salesOrder.customers_Id          = context.customers.FirstOrDefault(c => c.Name == cmb_CustomerName.Text).ID;
            salesOrder.SalesOrderDate        = dtp_BillDate.Value;
            salesOrder.SalesOrederTotalPrice = double.Parse(numericTotalCost.Value.ToString());

            //  salesOrder.SalesRepresentative.ID = context.SalesRepresentatives.FirstOrDefault(s => s.ID == int.Parse(mandobCompobox.SelectedValue.ToString())).ID;
            context.SalesOrder.Add(salesOrder);
            context.SaveChanges();
            context = new store();
            ///sales order payment
            SalesOredersPaymment salesOredersPaymment = new SalesOredersPaymment();

            salesOredersPaymment.Paied         = double.Parse(numericPaiedCost.Value.ToString());
            salesOredersPaymment.Rest          = double.Parse(numericResCost.Value.ToString());
            salesOredersPaymment.SalesOrder_id = salesOrder.ID;
            context.SalesOredersPaymments.Add(salesOredersPaymment);
            context.SaveChanges();
            context = new store();
            for (var item = 0; item < dgv_SalesBill.Rows.Count - 1; item++)
            {
                SalesOrderDetails salesOrderDetails = new SalesOrderDetails();
                salesOrderDetails.products_id   = int.Parse(dgv_SalesBill.Rows[item].Cells[4].Value.ToString());
                salesOrderDetails.quantity      = int.Parse(dgv_SalesBill.Rows[item].Cells[2].Value.ToString());
                salesOrderDetails.salesOrder_id = salesOrder.ID;
                var product = context.products.FirstOrDefault(p => p.ID == salesOrderDetails.products_id);
                product.quantityPerProducts -= salesOrderDetails.quantity;
                context.SalesOrderDetails.Add(salesOrderDetails);
            }

            context.SaveChanges();
            MessageBox.Show("تم العمليه بنجاح");
        }
Esempio n. 19
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (DGV_Customer.SelectedRows.Count == 0)
            {
                MessageBoxIcon.Warning.ToString();
                MessageBox.Show("يجب ان تختار المندوب من المندوبين");
                bt_addCustomer.Show();
            }
            store = new store();
            DGV_Customer.DataSource = null;
            DGV_Customer.Update();
            DGV_Customer.Refresh();
            var id    = int.Parse(DGV_Customer.SelectedRows[0].Cells[0].Value.ToString());
            var query = store.SalesRepresentatives.FirstOrDefault(p => p.ID == id);

            query.status = true;
            store.SaveChanges();
            bindGridView();
        }
Esempio n. 20
0
        private void bt_addCustomer_Click(object sender, EventArgs e)
        {
            var query = store.employee.FirstOrDefault(m => m.EmployeeName == MandobNametextBox1.Text);
            var check = store.SalesRepresentatives.FirstOrDefault(s => s.Employee_Id == query.ID);

            if (check == null)
            {
                SalesRepresentative SalesRepresentative = new SalesRepresentative();
                SalesRepresentative.Employee_Id = query.ID;
                SalesRepresentative.status      = false;
                store.SalesRepresentatives.Add(SalesRepresentative);
                store.SaveChanges();
                bindGridView();
            }
            else
            {
                MessageBox.Show("هذا المندوب موجود  بالفعل");
                MandobNametextBox1.Text = "";
            }
        }
Esempio n. 21
0
        private void bt_addCustomer_Click_1(object sender, EventArgs e)
        {
            if (CustomerNameTxt.Text == null || CustomerAddressTxt.Text == null || CustomerPhoneTxt.Text == null ||
                CustomerTypecomboBox.SelectedItem == null)

            {
                MessageBox.Show("يجب ان تدخل كل البيانات");
            }
            else
            {
                // add
                var nameFilter = store.customers.FirstOrDefault(p => p.Name == CustomerNameTxt.Text);
                if (nameFilter == null)
                {
                    var       date      = new DateTime();
                    Customers customers = new Customers();
                    customers.addrees      = CustomerAddressTxt.Text;
                    customers.Name         = CustomerNameTxt.Text;
                    customers.PurchaseDate = date;
                    customers.Phone        = CustomerPhoneTxt.Text;
                    // employee.Salary = float.Parse(Txt_EmployeeSalary.Text);
                    customers.type   = CustomerTypecomboBox.SelectedItem.ToString();
                    customers.Status = false;

                    store.customers.Add(customers);

                    store.SaveChanges();
                    MessageBox.Show("تم الحفظ بنجاح");
                    CustomerNameTxt.Text    = "";
                    CustomerAddressTxt.Text = "";
                    CustomerPhoneTxt.Text   = "";
                    bindGridView();
                }
                else
                {
                    MessageBox.Show("هذا الموظف  موجود  بالفعل");
                    CustomerNameTxt.Text = null;
                    // AllPro allPro = new AllPro();
                }
            }
        }
Esempio n. 22
0
        private void deleteBtnProduct_Click(object sender, EventArgs e)
        {
            if (dgv_SalesBill.SelectedRows.Count == 0)
            {
                MessageBoxIcon.Warning.ToString();
                MessageBox.Show("يجب ان تختار منتج من المنتجات");
            }
            else
            {
                store = new store();
                dgv_SalesBill.DataSource = null;
                dgv_SalesBill.Update();
                dgv_SalesBill.Refresh();
                var id    = int.Parse(dgv_SalesBill.SelectedRows[0].Cells[6].Value.ToString());
                var query = store.products.FirstOrDefault(p => p.ID == id);
                query.status = true;
                store.SaveChanges();

                bindGridView();
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            double totalCost = 0;

            for (var item = 0; item < DGV_SpendProducts.Rows.Count - 1; item++)
            {
                totalCost +=
                    double.Parse(DGV_SpendProducts.Rows[item].Cells[0].Value.ToString()) *
                    double.Parse(DGV_SpendProducts.Rows[item].Cells[1].Value.ToString());
            }
            Orders Orders = new Orders();
            var    id     = int.Parse(CMB_MndobName.SelectedValue.ToString());
            var    SaleID = store.SalesRepresentatives.FirstOrDefault(c => c.ID == id).ID;

            Orders.SalesRepresentative_Id = SaleID;
            Orders.OrderDate = DTV_ٍSpendDate.Value;
            Orders.TotalCost = totalCost;

            //  salesOrder.SalesRepresentative.ID = context.SalesRepresentatives.FirstOrDefault(s => s.ID == int.Parse(mandobCompobox.SelectedValue.ToString())).ID;
            store.Orders.Add(Orders);
            store.SaveChanges();
            store = new store();
            ///sales order payment
            for (var item = 0; item <= DGV_SpendProducts.Rows.Count - 1; item++)
            {
                OrderDetails OrderDetails = new OrderDetails();
                OrderDetails.products_id = int.Parse(DGV_SpendProducts.Rows[item].Cells[3].Value.ToString());
                OrderDetails.quantity    = int.Parse(DGV_SpendProducts.Rows[item].Cells[1].Value.ToString());
                OrderDetails.Order_id    = Orders.ID;
                store.OrderDetails.Add(OrderDetails);
                var product = store.products.FirstOrDefault(p => p.ID == OrderDetails.products_id);
                product.quantityPerProducts -= OrderDetails.quantity;
            }

            store.SaveChanges();
            MessageBox.Show("تم العمليه بنجاح");
        }
Esempio n. 24
0
        public ActionResult AddressAndPayment(FormCollection values)
        {
            var order = new Order();

            TryUpdateModel(order);

            try
            {
                if (string.Equals(values["PromoCode"], PromoCode,
                                  StringComparison.OrdinalIgnoreCase) == false)
                {
                    return(View(order));
                }
                else
                {
                    order.Username  = User.Identity.Name;
                    order.OrderDate = DateTime.Now;

                    //Save Order
                    db.Order.Add(order);
                    db.SaveChanges();

                    //Process the order
                    var cart = ShoppingCart.GetCart(this.HttpContext);
                    cart.CreateOrder(order);

                    return(RedirectToAction("Complete",
                                            new { id = order.OrderId }));
                }
            }
            catch
            {
                //Invalid - redisplay with errors
                return(View(order));
            }
        }