void LoadPaymentInfo()
        {
            customerAccount = dataAccess.LoadSingleData <Model.CustomerAccount, dynamic>(
                Repository.Queries.SELECT_AMT_INVENTORY_BY_CUSTOMER,
                new { CustomerId = txtCustId.Text });
            int res = Utility.checkAccountTypeAndReturnValue(customerAccount.Type);

            txtPaidAmt.Text = customerAccount.OrderTotalAmt.ToString("F");
            if (res == 1)
            {
                txtDebitAmt.Text  = customerAccount.Amount.ToString();
                txtCreditAmt.Text = "0";
            }
            else if (res == 2)
            {
                txtCreditAmt.Text         = customerAccount.Amount.ToString();
                txtDebitAmt.Text          = "0";
                checkBoxUseCredit.Enabled = true;
            }
            else
            {
                txtDebitAmt.Text  = customerAccount.Amount.ToString();
                txtCreditAmt.Text = customerAccount.Amount.ToString();
            }
        }
Example #2
0
        void FillStat()
        {
            Model.CustomerAccount customerAccount = Repository
                                                    .DataAccess.Instance.LoadSingleData <Model.CustomerAccount, dynamic>(
                Repository.Queries.SELECT_AMT_INVENTORY_BY_CUSTOMER,
                new { statastics.CustomerId });

            int res = Utility.checkAccountTypeAndReturnValue(customerAccount.Type);

            statastics.DebitAmt      = res == 1 ? customerAccount.Amount : 0;
            statastics.CreditAmt     = res == 2 ? customerAccount.Amount : 0;
            statastics.GrandAmt      = res == 3 ? "0" : customerAccount.Amount.ToString("F") + "-" + customerAccount.Type;
            statastics.RemainingFine = customerAccount.RemainingFine;
            statastics.TotalAmt      = customerAccount.OrderTotalAmt;
            if (res == 0)
            {
                statastics.GrandAmt = txtTotalAmt.Text.ConvertElseZero().ToString("F");
            }
        }
Example #3
0
        Model.Stat CalculateStats()
        {
            Model.Stat         stat      = new();
            List <Model.Order> orderList = new();

            double totalOutWeight = ZERO, totalFine = ZERO, totalInWeight = ZERO, totalAmt = ZERO;

            for (int i = ZERO; i < reportGridView.RowCount; i++)
            {
                DataGridViewRow dataGridViewRow = reportGridView.Rows[i];
                string          outWeightStr    = dataGridViewRow.Cells["out_weight"].Value.ToString();
                string          inWeightStr     = dataGridViewRow.Cells["in_weight"].Value.ToString();
                string          fineStr         = dataGridViewRow.Cells["fine"].Value.ToString();
                string          amtStr          = dataGridViewRow.Cells["total_amount"].Value.ToString();
                DateTime        date            = ((DateTime)dataGridViewRow.Cells["date"].Value).Date;
                string          customerName    = dataGridViewRow.Cells.GetCellValueFromColumnHeader("Customer Name");
                string          itemName        = dataGridViewRow.Cells.GetCellValueFromColumnHeader("Item Name");


                double outWeight = outWeightStr.ConvertElseZero();
                double inWeight  = inWeightStr.ConvertElseZero();
                double fine      = fineStr.ConvertElseZero();
                double amt       = amtStr.ConvertElseZero();

                // setting up order
                Model.Order order = new()
                {
                    OutWeight   = outWeight,
                    InWeight    = inWeight,
                    Fine        = fine,
                    TotalAmount = amt,
                    ItemName    = itemName,
                    Date        = date
                };
                orderList.Add(order);

                totalOutWeight   += outWeight;
                totalInWeight    += inWeight;
                totalFine        += fine;
                totalAmt         += amt;
                stat.CustomerName = customerName;
                stat.CustomerId   = customerCombo.SelectedValue.ToString();
            }
            stat.TotalInWeight  = totalInWeight;
            stat.TotalOutWeight = totalOutWeight;
            stat.TotalFine      = totalFine;
            stat.TotalAmt       = totalAmt;
            stat.Orders         = orderList;

            return(stat);
        }

        void LoadCustomers()
        {
            DataTable dataTable = new BaseDao().PopulateDataSourceData(Queries.CUSTOMER_SELECT_QUERY);

            this.customerCombo.DataSource    = dataTable;
            this.customerCombo.DisplayMember = "name";
            this.customerCombo.ValueMember   = "customerId";
        }

        void LoadCustomerAccount()
        {
            customerAccount = DataAccess.Instance.LoadSingleData <Model.CustomerAccount, dynamic>(
                Queries.SELECT_AMT_INVENTORY_BY_CUSTOMER,
                new { CustomerId = customerCombo.SelectedValue.ToString() });
            int res = Utility.checkAccountTypeAndReturnValue(customerAccount.Type);

            lblAmt.Text  = "Rs. " + customerAccount.OrderTotalAmt.ToString("F");
            lblFine.Text = customerAccount.RemainingFine.ToString();
        }

        void ClearForm()
        {
            fromDatePicker.Value = DateTime.Now.Date;
            toDatePicker.Value   = DateTime.Now.Date;
            btnGenerate.Enabled  = false;
            statastics           = null;
            isPaymentDone        = false;
        }

        void LoadStats()
        {
            // double totalAmt = orderService.FetchOrderByType(AppConstants.TOTAL_AMOUNT);
            // double totalFine = orderService.FetchOrderByType(AppConstants.TOTAL_FINE);
            Model.Stat stat = CalculateStats();
            lblAmt.Text       = "Rs. " + stat.TotalAmt.ToString("F");
            lblInWeight.Text  = stat.TotalInWeight.ToString();
            lblOutWeight.Text = stat.TotalOutWeight.ToString();
            lblFine.Text      = stat.TotalFine.ToString();

            string date = DataAccess.Instance.LoadSingleData <string, dynamic>(
                Queries.ORDER_LAST_PLACED_BY_CUSTOMER,
                new { customerId = customerCombo.SelectedValue.ToString() });

            lblLastOrderPlaced.Text = date.FormatDate();
        }

        void PopulateReportGrid()
        {
            DataTable dataTable;

            if (cmbType.SelectedItem.ToString() == "ALL")
            {
                dataTable = DataAccess.Instance.PopulateGrid <dynamic>(
                    Queries.ORDER_SELECT_QUERY_BY_CUSTOMER,
                    new
                {
                    customerId = customerCombo.SelectedValue.ToString()
                });
            }
            else
            {
                dataTable = DataAccess.Instance.PopulateGrid <dynamic>(
                    Queries.ORDER_SELECT_QUERY_BY_CUSTOMER_AND_DATE,
                    new
                {
                    customerId = customerCombo.SelectedValue.ToString(),
                    fromDate   = fromDatePicker.Value.Date,
                    toDate     = toDatePicker.Value.Date
                });
            }

            reportGridView.DataSource = dataTable;
            reportGridView.Columns["date"].DefaultCellStyle.Format = "dd-MMM-yyyy";
            reportGridView.Columns["orderId"].Visible       = false;
            reportGridView.Columns["customerId"].Visible    = false;
            reportGridView.Columns["itemId"].Visible        = false;
            reportGridView.Columns["creation_date"].Visible = false;
            reportGridView.Columns["last_modified"].Visible = false;
            reportGridView.Columns["date"].Visible          = false;
            reportGridView.Columns["Customer Name"].Visible = false;
            reportGridView.Columns["labour_rate"].Visible   = false;
            reportGridView.Columns["status"].Visible        = false;

            LoadStats();
            LoadCustomerAccount();
        }