Exemplo n.º 1
0
        private void getAndBindDetails()
        {
            try
            {
                int.TryParse(_selectedData[_rowNum]["TICKET_NUMBER"].ToString(), out _currentTicketNumber);
                _dataSet = RetailInquiry.getDetail(_currentTicketNumber);

                ItemsList_dg.DataSource = null;
                if (_dataSet.Tables.Contains("MDSE_INFO"))
                {
                    ItemsList_dg.AutoGenerateColumns = false;
                    ItemsList_dg.DataSource          = _dataSet.Tables["MDSE_INFO"];
                }

                History_dg.DataSource = null;
                if (_dataSet.Tables.Contains("HISTORY_INFO"))
                {
                    History_dg.AutoGenerateColumns = false;
                    DataTable dt = _dataSet.Tables["HISTORY_INFO"];
                    dt.Columns.Add("TOTAL_AMOUNT", typeof(double));
                    foreach (DataRow row in dt.Rows)
                    {
                        Decimal sale = 0.0m;
                        Decimal tax  = 0.0m;
                        Decimal.TryParse(row["AMOUNT"].ToString(), out sale);
                        Decimal.TryParse(row["SALES_TAX"].ToString(), out tax);

                        row["TOTAL_AMOUNT"] = sale + tax;
                    }
                    History_dg.DataSource = _dataSet.Tables["HISTORY_INFO"];

                    History_dg.Columns["TranAmount"].DefaultCellStyle.Format  = "c";
                    History_dg.Columns["SalesTax"].DefaultCellStyle.Format    = "c";
                    History_dg.Columns["TotalAmount"].DefaultCellStyle.Format = "c";
                }

                cust_name.Text  = String.Empty;
                cust_dob.Text   = String.Empty;
                cust_no.Text    = String.Empty;
                cust_id.Text    = String.Empty;
                cust_since.Text = String.Empty;
                if (_dataSet.Tables.Contains("CUSTOMER_INFO"))
                {
                    cust_name.Text  = _dataSet.Tables["CUSTOMER_INFO"].DefaultView[0]["CUST_NAME"].ToString();
                    cust_dob.Text   = _dataSet.Tables["CUSTOMER_INFO"].DefaultView[0]["DOB"].ToString();
                    cust_no.Text    = _dataSet.Tables["CUSTOMER_INFO"].DefaultView[0]["CUSTOMERNUMBER"].ToString();
                    cust_id.Text    = _dataSet.Tables["CUSTOMER_INFO"].DefaultView[0]["ID"].ToString();
                    cust_since.Text = System.DateTime.Parse(_dataSet.Tables["CUSTOMER_INFO"].DefaultView[0]["SINCE"].ToString()).ToString("MM/dd/yyyy");
                }

                txtTenderTypes.Text = String.Empty;
                if (_dataSet.Tables.Contains("TENDER_INFO"))
                {
                    foreach (DataRow row in _dataSet.Tables["TENDER_INFO"].Rows)
                    {
                        txtTenderTypes.Text += row["TENDER_TYPE"] + " $" + row["REF_AMT"] + Environment.NewLine;
                    }
                }

                //-------------------------------
                if (_dataSet.Relations.Contains("customerRelation"))
                {
                    _dataSet.Relations.Remove("customerRelation");
                }

                if (_dataSet.Tables.Contains("CUSTOMER_INFO") &&
                    _dataSet.Tables.Contains("MDSE_INFO"))
                {
                    _dataSet.Relations.Add("customerRelation",
                                           _dataSet.Tables["CUSTOMER_INFO"].Columns["CUSTOMERNUMBER"],
                                           _dataSet.Tables["MDSE_INFO"].Columns["CUSTOMERNUMBER"], false);
                }

                Double totalAmountWithTax = ((double)_selectedData[_rowNum]["AMOUNT"]) + ((double)_selectedData[_rowNum]["TAX"]);
                total_sale_amount_lbl.Text = totalAmountWithTax.ToString("c");
            }
            catch (Exception)
            {
                return;
            }
        }
        private void Find_btn_Click(object sender, EventArgs e)
        {
            try { validate(); }
            catch (BusinessLogicException blex)
            {
                MessageBox.Show(blex.Message);
                return;
            }

            Cursor.Current = Cursors.WaitCursor;

            var retailData = new RetailInquiry()
            {
                byDate  = dateOption_rb.Checked,
                status  = (RetailInquiry.searchStatus_enum)status_cb.SelectedIndex,
                userID  = userID_tb.Text,
                sortBy  = (RetailInquiry.sortField_enum)sortBy_cb.SelectedIndex,
                sortDir = (RetailInquiry.sortDir_enum)sortDir_cb.SelectedIndex
            };

            if (dateOption_rb.Checked)
            {
                retailData.startDate = dateCalendarStart.SelectedDate;
                retailData.endDate   = dateCalendarEnd.SelectedDate;
            }
            else
            {
                if (!string.IsNullOrEmpty(fromMSR_tb.Text))
                {
                    int.TryParse(fromMSR_tb.Text, out retailData.lowMSR);
                }

                if (!string.IsNullOrEmpty(toMSR_tb.Text))
                {
                    int.TryParse(toMSR_tb.Text, out retailData.highMSR);
                }
            }

            if (!string.IsNullOrEmpty(lowSaleAmt_tb.Text))
            {
                double.TryParse(lowSaleAmt_tb.Text, out retailData.lowSaleAmount);
            }

            if (!string.IsNullOrEmpty(highSaleAmt_tb.Text))
            {
                double.TryParse(highSaleAmt_tb.Text, out retailData.highSaleAmount);
            }

            if (!string.IsNullOrEmpty(lowCostAmt_tb.Text))
            {
                double.TryParse(lowCostAmt_tb.Text, out retailData.lowCostAmount);
            }

            if (!string.IsNullOrEmpty(highCostAmt_tb.Text))
            {
                double.TryParse(highCostAmt_tb.Text, out retailData.highCostAmount);
            }

            switch (layawayOriginated_cb.SelectedIndex)
            {
            case 0:
                retailData.layawayOriginated = "Y";
                break;

            case 1:
                retailData.layawayOriginated = "N";
                break;

            default:
                retailData.layawayOriginated = "";
                break;
            }

            switch (includeVoids_cb.SelectedIndex)
            {
            case 0:
                retailData.includeVoids = "Y";
                break;

            case 1:
                retailData.includeVoids = "N";
                break;

            default:
                retailData.includeVoids = "";
                break;
            }

            DataSet s = null;

            try
            {
                s = retailData.getData();

                if (s.IsNullOrEmpty())
                {
                    throw new BusinessLogicException(ReportConstants.NODATA);
                }
            }
            catch (BusinessLogicException blex)
            {
                MessageBox.Show(blex.Message);
                return;
            }

            Cursor.Current = Cursors.Default;

            this.Visible = false;
            var resultsDisplay = new RetailSearchResults(s, retailData, "RETAIL_INFO");

            resultsDisplay.ShowDialog();

            if (resultsDisplay.DialogResult == DialogResult.Cancel)
            {
                this.Close();
            }

            else
            {
                this.Visible = true;
            }
        }
Exemplo n.º 3
0
        public RetailSearchResults(DataSet s, RetailInquiry criteria, string dataTableName)
            : base(s, criteria, dataTableName, "Records")
        {
            windowHeading_lb.Text = "Retail Inquiry List";

            #region Data Grid Initialization

            ds             = s;
            sortedByColumn = criteria.sortBy.ToString();

            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();

            this.MSR        = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.DateTime   = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.SaleAmount = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.CostAmount = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Status     = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.UserID     = new System.Windows.Forms.DataGridViewTextBoxColumn();

            this.resultsGrid_dg.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
                this.MSR,
                this.DateTime,
                this.SaleAmount,
                this.CostAmount,
                this.Status,
                this.UserID
            });

            //
            // Shop
            //
            this.MSR.DataPropertyName = "TICKET_NUMBER";
            this.MSR.HeaderText       = "MSR";
            this.MSR.Name             = "MSR";
            this.MSR.ReadOnly         = true;
            this.MSR.Width            = 125;
            //
            // DateTime
            //
            this.DateTime.DataPropertyName   = "TIME_MADE";
            dataGridViewCellStyle3.Format    = "g";
            dataGridViewCellStyle3.NullValue = null;
            this.DateTime.DefaultCellStyle   = dataGridViewCellStyle3;
            this.DateTime.HeaderText         = "Date Made";
            this.DateTime.Name     = "DateTime";
            this.DateTime.ReadOnly = true;
            this.DateTime.Width    = 150;
            //
            // SaleAmount
            //
            this.SaleAmount.DataPropertyName = "AMOUNT";
            dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            dataGridViewCellStyle4.Format    = "C2";
            dataGridViewCellStyle4.NullValue = null;
            this.SaleAmount.DefaultCellStyle = dataGridViewCellStyle4;
            this.SaleAmount.HeaderText       = "Sale Amount";
            this.SaleAmount.Name             = "SaleAmount";
            this.SaleAmount.ReadOnly         = true;
            this.SaleAmount.Width            = 125;
            //
            // CostAmount
            //
            this.CostAmount.DataPropertyName = "COST";
            dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            dataGridViewCellStyle4.Format    = "C2";
            dataGridViewCellStyle4.NullValue = null;
            this.CostAmount.DefaultCellStyle = dataGridViewCellStyle4;
            this.CostAmount.HeaderText       = "Cost Amount";
            this.CostAmount.Name             = "CostAmount";
            this.CostAmount.ReadOnly         = true;
            this.CostAmount.Width            = 125;
            //
            // Status
            //
            this.Status.DataPropertyName = "STATUS_CD";
            this.Status.HeaderText       = "Status";
            this.Status.Name             = "Status";
            this.Status.ReadOnly         = true;
            this.Status.Width            = 125;
            //
            // UserID
            //
            this.UserID.DataPropertyName = "ENT_ID";
            this.UserID.HeaderText       = "UserID";
            this.UserID.Name             = "UserID";
            this.UserID.ReadOnly         = true;
            this.UserID.Width            = 125;

            this.resultsGrid_dg.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.resultsGrid_dg_CellContentClick);
            #endregion

            this.Print_btn.Enabled = true;
            this.Print_btn.Click  += new System.EventHandler(this.Print_btn_Click);
        }