Ejemplo n.º 1
0
        private void orderGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            btnAdd.Enabled  = false;
            btnEdit.Enabled = true;

            txtOrderId.Text      = Utility.CellValueByIndex(ZERO, orderGridView);
            customerCombo.Text   = Utility.CellValueByIndex(1, orderGridView);
            itemCombo.Text       = Utility.CellValueByIndex(2, orderGridView);
            txtInWeight.Text     = Utility.GetCells(orderGridView).GetCellValueFromColumnHeader("in_weight");
            txtOutWeight.Text    = Utility.GetCells(orderGridView).GetCellValueFromColumnHeader("out_weight");
            txtFine.Text         = Utility.GetCells(orderGridView).GetCellValueFromColumnHeader("fine");
            txtLabourRate.Text   = Utility.GetCells(orderGridView).GetCellValueFromColumnHeader("labour_rate");
            dateTimePicker.Value = ((DateTime)Utility.GetCells(orderGridView)["date"].Value);
            txtTotalAmt.Text     = Utility.GetCells(orderGridView).GetCellValueFromColumnHeader("total_amount");
            string customerName = Utility.GetCells(orderGridView).GetCellValueFromColumnHeader("Customer Name");
            string itemName     = Utility.GetCells(orderGridView).GetCellValueFromColumnHeader("Item Name");
            string status       = Utility.GetCells(orderGridView).GetCellValueFromColumnHeader("status");

            DateTime creationDate = ((DateTime)Utility.GetCells(orderGridView)["creation_date"].Value);
            DateTime upadtedDate  = ((DateTime)Utility.GetCells(orderGridView)["last_modified"].Value);

            lblCreated.Text = creationDate.TimeAgo();
            lblUpdate.Text  = upadtedDate.TimeAgo();


            Model.Order order = new Model.Order
            {
                OrderId     = txtOrderId.Text,
                InWeight    = txtInWeight.Text.ConvertElseZero(),
                ItemId      = itemCombo.SelectedValue.ToString(),
                ItemName    = itemName,
                CustomerId  = customerCombo.SelectedValue.ToString(),
                OutWeight   = txtOutWeight.Text.ConvertElseZero(),
                Fine        = txtFine.Text.ConvertElseZero(),
                TotalAmount = txtTotalAmt.Text.ConvertElseZero(),
                LabourRate  = txtLabourRate.Text.ConvertElseZero(),
                Status      = Utility.GetOrderStatus(txtOutWeight.Text.ConvertElseZero()),
                Date        = dateTimePicker.Value,
                CreatedDate = creationDate
            };
            List <Model.Order> orders = new();

            orders.Add(order);
            statastics = new Model.Stat
            {
                CustomerId     = customerCombo.SelectedValue.ToString(),
                CustomerName   = customerName,
                TotalAmt       = txtTotalAmt.Text.ConvertElseZero(),
                TotalFine      = txtFine.Text.ConvertElseZero(),
                TotalInWeight  = txtInWeight.Text.ConvertElseZero(),
                TotalOutWeight = txtOutWeight.Text.ConvertElseZero(),
                FromDate       = DateTime.Now.ToString("MMMM dd, yyyy"),
                ToDate         = DateTime.Now.ToString("MMMM dd, yyyy"),
                OrderStatus    = status,
                Orders         = orders,
                Address        = Utility.GetShopAddress()
            };
        }
Ejemplo n.º 2
0
        static bool CheckValidCustomerAndItem(Model.Order order)
        {
            bool valid = true;

            if (String.IsNullOrWhiteSpace(order.ItemId))
            {
                valid = false;
                MessageBox.Show("Item does not exists !", "Invalid Item", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(valid);
            }

            if (String.IsNullOrWhiteSpace(order.CustomerId))
            {
                valid = false;
                MessageBox.Show("Customer does not exists !", "Invalid Customer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(valid);
            }
            return(valid);
        }