Exemple #1
0
        /// <summary>
        /// To Find Billing Record
        /// </summary>
        /// <param name="BillingProp"></param>
        /// <returns>IList<BillingProp></returns>
        /// <createdBy></createdBy>
        /// <createdOn>Jul-14,2016</createdOn>
        public async Task <List <BillingProp> > BillingSearch(BillingProp objBilling)
        {
            BillingDAL objBillingDAL = new BillingDAL();

            try
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                return(await objBillingDAL.BillingSearch(objBilling));
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }
Exemple #2
0
        /// <summary>
        /// function CreateCSVFile to return the exported csv file
        /// </summary>
        /// <param name="Na"></param>
        /// <param name="Na"></param>
        /// <returns>csv file</returns>
        public void CreateCSVFile()
        {
            CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            try
            {
                if (BillingList != null)
                {
                    BillingProp objBillingProp = new BillingProp();
                    if (vin != null)
                    {
                        objBillingProp.Vin = Vin;
                    }
                    else
                    {
                        objBillingProp.Vin = string.Empty;
                    }

                    objBillingProp.CustomerName     = CustomerName;
                    objBillingProp.InvoiceStatus    = SelectedInvoiceStatus;
                    objBillingProp.InvoiceType      = SelectedInvoiceType;
                    objBillingProp.InvoiceNumber    = InvoiceNumber;
                    objBillingProp.Vin              = Vin;
                    objBillingProp.CustomerNumber   = CustomerNumber;
                    objBillingProp.CustIndent       = CustIndent;
                    objBillingProp.CreatedBetwDtFrm = CreatedBetwDtFrm;
                    objBillingProp.CreatedBetwDtTo  = CreatedBetwDtTo;
                    objBillingProp.DtInvBetwDtFrm   = DtInvBetwDtFrm;
                    objBillingProp.DtInvBetwDtTo    = DtInvBetwDtTo;
                    objBillingProp.DtPaidBetwDtFrm  = DtPaidBetwDtFrm;
                    objBillingProp.DtPaidBetwDtTo   = DtPaidBetwDtTo;
                    objBillingProp.CurrentPageIndex = CurrentPageIndex;
                    objBillingProp.PageSize         = 0;
                    objBillingProp.DefaultPageSize  = _GridPageSize;

                    //objBillingProp.PONumber = PONumber;
                    //objBillingProp.OrderNumber = OrderNumber;
                    //objBillingProp.LoadNumber = LoadNumber;
                    //objBillingProp.OutsideCarrier = SelectedoutsideCarrier;
                    //objBillingProp.Driver = SelectedDriverList;

                    var data = _serviceInstance.BillingSearch(objBillingProp).Select(d => new BillingModel()
                    {
                        BillingID    = d.BillingID,
                        CustomerName = d.CustomerName,

                        InvoiceDate    = d.InvoiceDate,
                        InvoiceNumber  = d.InvoiceNumber,
                        InvoiceStatus  = d.InvoiceStatus,
                        InvoiceType    = d.InvoiceType,
                        TotalPageCount = d.TotalPageCount
                                         //LoadNumber = d.LoadNumber,
                                         //OutsideCarrierID = d.OutsideCarrierID,
                                         //Driver = d.Driver,
                                         //CarrierName = d.CarrierName,
                    });

                    if (data != null)
                    {
                        BillingListExp = null;
                        BillingListExp = new ObservableCollection <BillingModel>(data);
                    }

                    if (BillingListExp.Count > 0)
                    {
                        string[] ExportValue = new string[] { "InvoiceNumber ", "CustomerName ", "Invoice Type", "Invoice Date", "Invoice Status" };
                        if (!Directory.Exists(ConfigurationManager.AppSettings["CSVFilePath"].ToString()))
                        {
                            Directory.CreateDirectory(ConfigurationManager.AppSettings["CSVFilePath"].ToString());
                        }
                        StreamWriter sw = new StreamWriter(ConfigurationManager.AppSettings["CSVFilePath"].ToString() + "BillingInvoice.csv", false);

                        foreach (string objVal in ExportValue)
                        {
                            sw.Write(objVal);
                            sw.Write(",");
                        }
                        sw.Write(sw.NewLine);

                        // Row creation
                        foreach (BillingModel prop in BillingListExp)
                        {
                            if (prop.InvoiceNumber != null)
                            {
                                sw.Write(prop.InvoiceNumber);
                                sw.Write(",");
                            }
                            else
                            {
                                sw.Write("");
                                sw.Write(",");
                            }
                            if (prop.CustomerName != null)
                            {
                                sw.Write(prop.CustomerName);
                                sw.Write(",");
                            }
                            else
                            {
                                sw.Write("");
                                sw.Write(",");
                            }
                            //if (prop.CarrierName != null)
                            //{
                            //    sw.Write(prop.CarrierName);
                            //    sw.Write(",");
                            //}
                            //else
                            //{
                            //    sw.Write("");
                            //    sw.Write(",");
                            //}
                            if (prop.InvoiceType != null)
                            {
                                sw.Write(prop.InvoiceType);
                                sw.Write(",");
                            }
                            else
                            {
                                sw.Write("");
                                sw.Write(",");
                            }
                            if (prop.InvoiceDate != null)
                            {
                                sw.Write(prop.InvoiceDate.Value.Date.ToString("MM/dd/yyy"));
                                sw.Write(",");
                            }
                            else
                            {
                                sw.Write("");
                                sw.Write(",");
                            }
                            //if (prop.LoadNumber != null)
                            //{
                            //    sw.Write(prop.LoadNumber);
                            //    sw.Write(",");
                            //}
                            //else
                            //{
                            //    sw.Write("");
                            //    sw.Write(",");
                            //}
                            //if (prop.OutsideCarrierID != null)
                            //{
                            //    sw.Write(prop.OutsideCarrierID);
                            //    sw.Write(",");
                            //}
                            //else
                            //{
                            //    sw.Write("");
                            //    sw.Write(",");
                            //}
                            //if (prop.Driver != null)
                            //{
                            //    sw.Write(prop.Driver);
                            //    sw.Write(",");
                            //}
                            //else
                            //{
                            //    sw.Write("");
                            //    sw.Write(",");
                            //}
                            if (prop.InvoiceStatus != null)
                            {
                                sw.Write(prop.InvoiceStatus);
                                sw.Write(",");
                            }
                            else
                            {
                                sw.Write("");
                                sw.Write(",");
                            }

                            // Do something with propValue
                            sw.Write(sw.NewLine);
                        }
                        sw.Close();
                        System.Diagnostics.Process.Start(System.Configuration.ConfigurationManager.AppSettings["CSVFilePath"].ToString() + "BillingInvoice.csv");
                    }
                    else
                    {
                        MessageBox.Show(Resources.msgExportResultError);
                    }
                }
                else
                {
                    MessageBox.Show(Resources.msgExportResultError);
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogErrorToDb(ex);
                bool displayErrorOnUI = false;
                CommonSettings.logger.LogError(this.GetType(), ex);
                if (displayErrorOnUI)
                {
                    throw;
                }
            }
            finally
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }