private void LoadButton_Click(object sender, EventArgs e)
        {
            var startDate = StartDateField.Value.Date;
            var endDate   = EndDateField.Value;

            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var orders = db.Orders.Where(aa => aa.OrderDate >= startDate && aa.OrderDate <= endDate).OrderBy(aa => aa.OrderDate).ToList();



            var orderDataGrid = orders.Select(aa => new
            {
                Order_Id       = StationIdHelper.StationIdJoined(aa.StationOrderId, aa.OrderId),
                Customer_Name  = aa.Customer.Name,
                Date           = aa.OrderDate,
                IsAdvanceOrder = IsAdvance(aa.IsAdvanceOrder),
                DeliveryDate   = DeliveryDate(aa),
                IsDelivered    = IsDelivered(aa),
                Total_Bill     = CalculateTotalBill(StationIdHelper.StationIdJoined(aa.StationOrderId, aa.OrderId))
            }
                                              ).ToList();


            dataGridView1.DataSource = orderDataGrid;
        }
Example #2
0
        private void LoadDataGrid(string joinedCustomerId)
        {
            var customerIds = StationIdHelper.SeperateStationId(CustomerDropDown.SelectedValue.ToString());

            int customerId        = int.Parse(customerIds[1]);
            int stationCustomerId = int.Parse(customerIds[0]);


            var orders = db.Orders.Where(aa => aa.CustomerId == customerId && aa.StationCustomerId == stationCustomerId).OrderByDescending(aa => aa.OrderDate).ToList();

            if (orders.Count == 0)
            {
                MessageBox.Show("No Order to show");
                dataGridView1.DataSource = null;
                return;
            }

            var orderDataGrid = orders.Select(aa => new
            {
                Order_Id       = StationIdHelper.StationIdJoined(aa.StationOrderId, aa.OrderId),
                Customer_Name  = aa.Customer.Name,
                Date           = aa.OrderDate,
                IsAdvanceOrder = IsAdvance(aa.IsAdvanceOrder),
                DeliveryDate   = DeliveryDate(aa),
                IsDelivered    = IsDelivered(aa),
                Total_Bill     = CalculateTotalBill(StationIdHelper.StationIdJoined(aa.StationOrderId, aa.OrderId))
            }
                                              ).ToList();


            dataGridView1.DataSource = orderDataGrid;
        }
Example #3
0
        // event for save button
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(NameField.Text) || string.IsNullOrEmpty(PhoneField.Text) || string.IsNullOrEmpty(CityField.Text) || string.IsNullOrEmpty(AddressField.Text))
            {
                MessageBox.Show("Please fill mendatory fields.");
            }
            else
            {
                Customer cust = new Customer();
                cust.Name              = NameField.Text;
                cust.Phone             = PhoneField.Text;
                cust.Address           = AddressField.Text;
                cust.City              = CityField.Text;
                cust.StationCustomerId = (int)Station.StationId;
                cust.StatusCode        = (int)LocalDBStatusCode.Added;
                db.Customers.Add(cust);
                db.SaveChanges();
                MessageBox.Show("User Added");

                LoadCustomers();
                var joinedCustomerId = StationIdHelper.StationIdJoined(cust.StationCustomerId, cust.CustomerId);
                if (orderForm != null)
                {
                    orderForm.SetCustomer(joinedCustomerId);
                }
                this.Close();
            }
        }
        private async void LoadButton_Click(object sender, EventArgs e)
        {
            label1.Visible = true;
            await Task.Yield();


            var customersIds = db.Customers.Select(ss => new
            {
                customerId        = ss.CustomerId,
                stationCustomerId = ss.StationCustomerId
            }
                                                   );

            List <customerPayments> customerPaymentsList = new List <customerPayments>();

            foreach (var custId in customersIds)
            {
                int duePayment = LoadDuePayments(custId.customerId, custId.stationCustomerId);
                if (duePayment < 0)
                {
                    customerPayments custPayment = new customerPayments();
                    custPayment.CustomerName     = db.Customers.Where(aa => aa.CustomerId == custId.customerId && aa.StationCustomerId == custId.stationCustomerId).FirstOrDefault().Name;
                    custPayment.JoinedCustomerId = StationIdHelper.StationIdJoined(custId.stationCustomerId, custId.customerId);
                    custPayment.DuePayment       = duePayment;
                    customerPaymentsList.Add(custPayment);
                }
            }

            dataGridView1.DataSource = customerPaymentsList;
            label1.Visible           = false;
        }
Example #5
0
        private void LoadDataGrid(string joinedCustomerId)
        {
            var customerIds       = StationIdHelper.SeperateStationId(joinedCustomerId);
            int stationCustomerId = int.Parse(customerIds[0]);
            int customerId        = int.Parse(customerIds[1]);


            var payments = db.OrderPaymentMades.Where(aa => aa.CustomerId == customerId && aa.StationCustomerId == stationCustomerId).ToList();

            if (payments.Count > 0)
            {
                var paymentGrid = payments.Select(
                    aa => new
                {
                    CustomerName = aa.Customer.Name,
                    CustomerId   = StationIdHelper.StationIdJoined(aa.StationCustomerId, aa.CustomerId),
                    Date         = aa.Date,
                    Payment      = aa.PaymentMade
                }
                    ).ToList();
                dataGridView1.DataSource = paymentGrid;
            }

            else
            {
                MessageBox.Show("No payment to show");
            }
        }
Example #6
0
        private void AddOldPayment_Load(object sender, EventArgs e)
        {
            FaridiaIronStoreEntities db = new FaridiaIronStoreEntities();
            var customer = db.Customers.Where(aa => aa.CustomerId == customerId && aa.StationCustomerId == stationCustomerId).FirstOrDefault();

            CustomerNameLabel.Text  = customer.Name;
            CustomerIdLabel.Text    = StationIdHelper.StationIdJoined(stationCustomerId, customerId);
            OldDuePaymentLabel.Text = LoadPreviousBill().ToString();
        }
        private void OnLoad()
        {
            var Pending = db.Orders.Where(aa => aa.IsAdvanceOrder == true && aa.IsDelivered == false)
                          .OrderBy(aa => aa.DeliveryDate).ToList();

            var pendingOrder = Pending.Select(aa => new
            {
                Order_Id      = StationIdHelper.StationIdJoined(aa.StationOrderId, aa.OrderId),
                Customer_Name = aa.Customer.Name,
                Date          = aa.OrderDate,
                DeliveryDate  = aa.DeliveryDate,
                Total_Bill    = CalculateTotalBill(aa.OrderId, aa.StationOrderId)
            }
                                              ).ToList();

            dataGridView1.DataSource = pendingOrder;
        }
Example #8
0
        private void InitializeOrderDetails()
        {
            CustomerLabel.Text = order.Customer.Name;
            OrderIdLabel.Text  = StationIdHelper.StationIdJoined(order.StationOrderId, order.OrderId);

            if (order.Address != null)
            {
                AddressField.Text = order.Address;
            }

            if (order.Description != null)
            {
                DescriptionField.Text = order.Description;
            }

            if (order.IsAdvanceOrder)
            {
                AdvanceOrderLabel.Text = "Yes";
                DeliveryDateLabel.Text = order.DeliveryDate.ToString();
                if (order.IsDelivered)
                {
                    DeliveredLabel.Text = "Yes";
                }
                else
                {
                    DeliveredLabel.Text = "No";
                }
            }

            else
            {
                AdvanceOrderLabel.Text = "No";
                DeliveredLabel.Text    = "--";
                DeliveryDateLabel.Text = "--";
            }

            OrderDateLabel.Text = order.OrderDate.ToString();

            int TotalBill = (int)db.OrderLines.Where(aa => aa.OrderId == order.OrderId && aa.StationOrderId == order.StationOrderId).Select(aa => aa.PricePerUnit * aa.WeightInKg).Sum();

            TotalBillLabel.Text = TotalBill.ToString();
        }
Example #9
0
        private void SaveAndPrintButton_Click(object sender, EventArgs e)
        {
            SaveButton_Click(null, null);

            if (_order == null)
            {
                MessageBox.Show("Order not saved");
                return;
            }

            List <InvoiceOrderList> OrdersList = new List <InvoiceOrderList>();


            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                InvoiceOrderList order = new InvoiceOrderList();
                if (row.Cells["ItemColumn"].Value != null)
                {
                    order.Item = row.Cells["ItemColumn"].Value.ToString();
                }
                else
                {
                    order.Item = " ";
                }
                if (row.Cells["KiloColumn"].Value != null)
                {
                    order.Kilo = row.Cells["KiloColumn"].Value.ToString();
                }
                else
                {
                    order.Kilo = " ";
                }
                if (row.Cells["GramColumn"].Value != null)
                {
                    order.Gram = row.Cells["GramColumn"].Value.ToString();
                }
                else
                {
                    order.Gram = " ";
                }
                if (row.Cells["PricePerUnitColumn"].Value != null)
                {
                    order.PricePerUnit = row.Cells["PricePerUnitColumn"].Value.ToString();
                }
                else
                {
                    order.PricePerUnit = " ";
                }
                if (row.Cells["TotalPriceColumn"].Value != null)
                {
                    order.TotalPrice = row.Cells["TotalPriceColumn"].Value.ToString();
                }
                else
                {
                    order.TotalPrice = " ";
                }
                if (row.Cells["BundleColumn"].Value != null)
                {
                    order.Bundle = row.Cells["BundleColumn"].Value.ToString();
                }
                else
                {
                    order.Bundle = " ";
                }
                if (row.Cells["LengthColumn"].Value != null)
                {
                    order.Length = row.Cells["LengthColumn"].Value.ToString();
                }
                else
                {
                    order.Length = " ";
                }
                if (row.Cells["PieceCutColumn"].Value != null)
                {
                    order.PieceCut = row.Cells["PieceCutColumn"].Value.ToString();
                }
                else
                {
                    order.PieceCut = " ";
                }
                OrdersList.Add(order);
            }

            string total        = TotalField.Value.ToString();
            string bill         = BillField.Value.ToString();
            string paymentMade  = PaymentMadeField.Value.ToString().Trim();
            string oldpayments  = OldPaymentField.Value.ToString().Trim();
            string customer     = CustomerComboBox.Text.ToString().Trim();
            string adress       = AddressTextBox.Text.Trim();
            string invoiceId    = StationIdHelper.StationIdJoined(_order.StationOrderId, _order.OrderId);
            string detail       = DescriptionTextBox.Text.Trim();
            string orderDate    = DateTime.Today.ToShortDateString();
            string deliveryDate = string.Empty;

            if (AdvanceOrderCheck.Checked)
            {
                DateTime dateTime = DeliveryDateField.Value;
                deliveryDate = dateTime.ToShortDateString();
            }
            else
            {
                deliveryDate = DateTime.Today.ToShortDateString();
            }
            Invoice invoice = new Invoice(OrdersList, total, bill, paymentMade, oldpayments, customer, adress, invoiceId, detail, deliveryDate, orderDate);

            invoice.Show();
            this.Close();
        }