Example #1
0
        void loadReport(DateTime?FromDate, DateTime?ToDate, string ItemCode)
        {
            FromDate = FromDate ?? DateTime.MinValue;
            ToDate   = ToDate ?? DateTime.Now;
            ItemCode = string.IsNullOrEmpty(ItemCode) ? "" : ItemCode;
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();

            builder.DataSource     = SettingsProvider.GetDataSource();
            builder.InitialCatalog = SettingsProvider.GetDatabase();
            builder.UserID         = SettingsProvider.GetUserName();
            builder.Password       = SettingsProvider.GetPassword();

            int type               = 2;
            int entryStatus        = 0;
            int transactionStatus  = 0;
            int defaultAddressType = 0;

            using (DelivaryDataProvider db = new DelivaryDataProvider(builder.ConnectionString))
            {
                List <DelivaryTransactionView> result = db.getDelivaryTransactionView();

                var transactionLine = from x in result
                                      select
                                      new ReportTransactionLine()
                {
                    ReceiptID      = x.RECEIPTID,
                    ItemId         = x.ITEMID,
                    Description    = x.DESCRIPTION,
                    Qty            = x.QUANTITY == null?0:(decimal)x.QUANTITY,
                    TaxInckInPrice = x.SEIINGPRICE == null ? 0 : (decimal)x.SEIINGPRICE,
                    Comment        = x.COMMENT.Replace("\r\n", " "),
                    ExtraInfo      = x.DELIVARYTYPE
                    , CustomerName = x.NAME
                };
                this.TransactionLines = transactionLine.Count() > 0 ? new ReprotTransactionLines(transactionLine.ToList()) : null;
            }

            /*
             *  using (var db = new DeliveryDbContext(builder.ConnectionString))
             * {   //LINENUM changed to LINEID IN in line 103 col 155 by rafeeq
             *
             *  var transactionCustomer = from tra_h in db.RBOTRANSACTIONTABLE
             *                            join tra_i in db.RBOTRANSACTIONINFOCODETRANS
             *                            on
             *                            new { tra_h.TRANSACTIONID, INFOCODEID =  } equals new { tra_i.TRANSACTIONID, tra_i.INFOCODEID } into info_d
             *                            from info in info_d.DefaultIfEmpty()
             *                            join cust in db.CUSTTABLE on new { CUSTACCOUNT = string.IsNullOrEmpty(info.INFORMATION) ? tra_h.CUSTACCOUNT : info.INFORMATION } equals
             *                            new { CUSTACCOUNT = cust.ACCOUNTNUM }
             *                            join address in db.CUSTOMERADDRESS on
             *                            new { cust.ACCOUNTNUM, ADDRESSTYPE = defaultAddressType } equals new { address.ACCOUNTNUM, address.ADDRESSTYPE }
             *                            where
             *                              tra_h.TYPE == type &&
             *                              tra_h.ENTRYSTATUS == entryStatus
             *                            select new TransactionCustomer()
             *                            {
             *                                ReceiptID = tra_h.RECEIPTID,
             *                                CustAccount = string.IsNullOrEmpty(info.INFORMATION) ? tra_h.CUSTACCOUNT : info.INFORMATION,
             *                                Name = cust.NAME,
             *                                Address = cust.ADDRESS,
             *                                Phone = cust.PHONE,
             *                                Address1 = address.ADDRESS,
             *                                Street = address.STREET
             *                            };
             *  var transactionLine = from tra_h in db.RBOTRANSACTIONTABLE
             *                        join tra_l in db.RBOTRANSACTIONSALESTRANS
             *                        on tra_h.TRANSACTIONID equals tra_l.TRANSACTIONID
             *                        join tra_i in db.RBOTRANSACTIONINFOCODETRANS
             *                        on
             *                        new { tra_l.TRANSACTIONID, tra_l.LINENUM, INFOCODEID = Program.isDelevary } equals new { tra_i.TRANSACTIONID, LINENUM = (decimal)tra_i.LINEID, tra_i.INFOCODEID } into info_d
             *                        from info in info_d.DefaultIfEmpty()
             *                        join info_sub in db.RBOINFORMATIONSUBCODETABLE on
             *                        info.INFORMATION equals info_sub.SUBCODEID into info_sub_d
             *                        from info_s in info_sub_d.DefaultIfEmpty()
             *                        where
             *                          tra_h.TYPE == type &&
             *                          tra_h.ENTRYSTATUS == entryStatus &&
             *                          tra_l.TRANSACTIONSTATUS == transactionStatus &&
             *                          info_s.DESCRIPTION == Program.isDelevaryValue &&
             *                          tra_h.TRANSDATE < ToDate &&
             *                          tra_h.TRANSDATE > FromDate &&
             *                          tra_l.ITEMID.StartsWith(ItemCode)
             *                        select new TransactionLine()
             *                        {
             *                            ReceiptID = tra_h.RECEIPTID,
             *                            ItemId = tra_l.ITEMID,
             *                            Description = tra_l.DESCRIPTION,
             *                            Qty = (tra_l.QTY ?? 0) * -1,
             *                            TaxInckInPrice = -1 * (tra_l.NETAMOUNTINCLTAX ?? 0),
             *                            Comment = tra_l.COMMENT,
             *                            ExtraInfo = string.IsNullOrEmpty(info_s.DESCRIPTION) ? "NON DELIVERABLE" : info_s.DESCRIPTION
             *                        };
             *
             *  this.TransactionLines = transactionLine.Count() > 0 ? new TransactionLines(transactionLine.ToList()) : null;
             * }
             */
        }
        private void radioButtonReportType_CheckedChanged(object sender, EventArgs e)
        {
            var radioButton = (RadioButton)sender;

            if (radioButton.Checked)
            {
                switch ((ReportType)radioButton.Tag)
                {
                case ReportType.SUMMARY:
                    this.Cursor = Cursors.WaitCursor;
                    this.dateTimePickerFrom.Enabled = true;
                    this.dateTimePickerTo.Enabled   = true;
                    InitReport(typeof(LSDelevaryNote.Provider.Entities.DelivaryTransactionView));
                    using (DelivaryDataProvider db = new DelivaryDataProvider(builder.ConnectionString))
                    {
                        List <DelivaryTransactionView> result = db.getDelivaryTransactionView(
                            null,
                            this.textBoxItem.Text.Trim(),
                            null,
                            this.dateTimePickerFrom.Value,
                            this.dateTimePickerTo.Value,
                            this.comboBoxDeleveryType.SelectedText
                            );
                        this.DelivaryTransactionViewBindingSource.DataSource = result;
                        this.reportViewer1.RefreshReport();
                    }
                    this.Cursor = Cursors.Default;
                    break;

                case ReportType.REPLENISHMENT:
                    //ReportViewer.ProgressMessage = new ProcessForm(new string[] { "Loading Location 150...", "Loading location 650...", "Loading location 295..." });
                    this.Cursor = Cursors.WaitCursor;
                    this.reportViewer1.Enabled    = false;
                    this.dateTimePickerTo.Enabled = false;
                    InitReport(
                        typeof(LSDelevaryNote.Provider.Entities.DelivaryTransactionView),
                        ReportEmbeddedResource: "LSDelevaryNote.ReplenishmentReport.rdlc",
                        DataSourceName: "ReplanishDataSet"
                        );
                    try
                    {
                        using (DelivaryDataProvider db = new DelivaryDataProvider(builder.ConnectionString))
                        {
                            List <DelevaryRelanishment> result = db.getDelivaryReplamishmentView(
                                null,
                                this.textBoxItem.Text.Trim(),
                                null,
                                //null,
                                DateTime.Now.AddDays(-1).Date,
                                //null,
                                DateTime.Now.Date,
                                null
                                );
                            this.DelivaryTransactionViewBindingSource.DataSource = result;
                            this.reportViewer1.RefreshReport();
                            //ReportViewer.ProgressMessage.Close();
                        }
                    }
                    catch (Exception ex) {
                        MessageBox.Show(this, "Error gathering data.\nCheck the network and try again later.", "Bad data", MessageBoxButtons.OK);
                    }
                    //ReportViewer.ProgressMessage.Task = new Task(action);
                    //ReportViewer.ProgressMessage.ShowDialog(this);
                    this.reportViewer1.Enabled      = true;
                    this.dateTimePickerFrom.Enabled = false;
                    this.Cursor = Cursors.Default;
                    break;
                }
            }
        }