public ActionResult Create(FormCollection collection)
        {
            var        SelectedIds = collection.GetValues("selectedAddressesIds");
            List <int> PolicyIds   = new List <int>();

            if (SelectedIds != null)
            {
                foreach (var item in SelectedIds)
                {
                    if (item.ToString() != "false")
                    {
                        PolicyIds.Add(Convert.ToInt32(item.ToString()));
                    }
                }
            }
            CustomerInvoice Model = new CustomerInvoiceRepository().GetPolicyDetailsForInvoice(PolicyIds);

            Model.Items = new CustomerInvoiceRepository().GetPolicyDetailsForInvoiceDetails(PolicyIds);
            var internalid = CustomerInvoiceRepository.GetNextDocNo();

            Model.CusInvoiceRefNo = "CIB/INV/" + internalid;
            Model.CusInvoiceDate  = DateTime.Now;

            return(View(Model));
        }
        public ActionResult PreviousInvoicePartial(DateTime?FromDate, DateTime?ToDate, string ClientName = "")
        {
            FromDate = FromDate ?? FYStartdate;
            ToDate   = ToDate ?? DateTime.Now;
            List <Invoice> obj = new List <Invoice>();

            obj = new CustomerInvoiceRepository().InvoiceList(FromDate, ToDate, ClientName);

            return(PartialView("_PreviousInvoiceList", obj));
        }
        public ActionResult Invoice(int Paymentid)
        {
            Invoice objInvoice = new CustomerInvoiceRepository().GetInvoice(Paymentid);
            var     internalid = CustomerInvoiceRepository.GetNextRefNo();

            objInvoice.CustInvoiceRefNo    = internalid;
            objInvoice.CustInvoiceDate     = DateTime.Now;
            objInvoice.BillDueDate         = DateTime.Now;
            objInvoice.CustomerInvoiceItem = new CustomerInvoiceRepository().GetInvoiceItem(Paymentid);
            return(View("Invoice", objInvoice));
            //return View();
        }
 public ActionResult DeleteInvoice(int id = 0)
 {
     try
     {
         if (id == 0)
         {
             return(RedirectToAction("Index", "Home"));
         }
         string result = new CustomerInvoiceRepository().DeleteInvoice(id);
         TempData["Success"] = "Deleted Successfully!";
         return(RedirectToAction("PreviousInvoice"));
     }
     catch (Exception)
     {
         TempData["error"] = "Some error occured while deleting. Please try again.";
         return(RedirectToAction("Invoice", new { id = id }));
     }
 }
        public ActionResult Invoice(Invoice model)
        {
            model.CreatedBy   = UserID.ToString();
            model.CreatedDate = System.DateTime.Now;
            if (!ModelState.IsValid)
            {
                var allErrors = ModelState.Values.SelectMany(v => v.Errors);
                return(View(model));
            }
            Result res = new CustomerInvoiceRepository().Insert(model);

            if (res.Value)
            {
                TempData["Success"] = "Saved Successfully!";
            }
            else
            {
            }
            return(RedirectToAction("paymentFollowup", "Payment"));
        }
 public ActionResult Update(Invoice model)
 {
     try
     {
         model.CreatedBy   = UserID.ToString();
         model.CreatedDate = System.DateTime.Now;
         var success = new CustomerInvoiceRepository().UpdateInvoice(model);
         if (success <= 0)
         {
             throw new Exception();
         }
         TempData["success"] = "Updated successfully (" + model.CustInvoiceRefNo + ")";
         return(RedirectToAction("PreviousInvoice"));
     }
     catch (Exception)
     {
         TempData["error"] = "Some error occured while saving. Please try again.";
         return(View("Invoice", model));
     }
 }
        public ActionResult Update(int id)
        {
            try
            {
                if (id == 0)
                {
                    TempData["error"] = "That was an invalid/unknown request. Please try again.";
                    return(RedirectToAction("Index", "Home"));
                }
                var model = new CustomerInvoiceRepository().GetInvoiceView(id);
                if (model == null)
                {
                    TempData["error"] = "Could not find the requested Purchase Indent. Please try again.";
                    return(RedirectToAction("Index", "Home"));
                }

                return(View("Invoice", model));
            }
            catch (Exception)
            {
                TempData["error"] = "Some error occured. Please try again.";
                return(RedirectToAction("PreviousInvoice"));
            }
        }
        public ActionResult InvoiceReport(int Id)
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports"), "CustomerInvoice.rpt"));

            DataSet ds = new DataSet();

            ds.Tables.Add("Head");
            ds.Tables.Add("Items");

            #region creating Head table
            ds.Tables["Head"].Columns.Add("CustInvoiceRefNo");
            ds.Tables["Head"].Columns.Add("CustInvoiceDate");
            ds.Tables["Head"].Columns.Add("ClientName");
            ds.Tables["Head"].Columns.Add("ProjectOrderRefNo");
            ds.Tables["Head"].Columns.Add("Address1");
            ds.Tables["Head"].Columns.Add("Address2");
            ds.Tables["Head"].Columns.Add("Address3");
            ds.Tables["Head"].Columns.Add("SpecialRemarks");
            ds.Tables["Head"].Columns.Add("PaymentTerms");
            ds.Tables["Head"].Columns.Add("AdditionalRemarks");
            ds.Tables["Head"].Columns.Add("AddAmount");
            ds.Tables["Head"].Columns.Add("DeductionRemarks");
            ds.Tables["Head"].Columns.Add("DedAmount");
            ds.Tables["Head"].Columns.Add("BillDueDate");
            #endregion

            #region creating Item Table
            ds.Tables["Items"].Columns.Add("ProjectRefNo");
            ds.Tables["Items"].Columns.Add("ProjectDate");
            ds.Tables["Items"].Columns.Add("ProjectEnquiry");
            ds.Tables["Items"].Columns.Add("Description");
            ds.Tables["Items"].Columns.Add("Amount");
            ds.Tables["Items"].Columns.Add("InvoiceAmount");
            #endregion


            #region store data to Head table
            CustomerInvoiceRepository repo = new CustomerInvoiceRepository();
            var     Head = repo.CustomerInvoiceHdforPrint(Id);
            DataRow dr   = ds.Tables["Head"].NewRow();
            dr["CustInvoiceRefNo"]  = Head.CustInvoiceRefNo;
            dr["CustInvoiceDate"]   = Head.CustInvoiceDate.ToString("dd-MMM-yyyy");
            dr["ClientName"]        = Head.ClientName;
            dr["ProjectOrderRefNo"] = Head.ProjectOrderRefNo;
            dr["Address1"]          = Head.Address1;
            dr["Address2"]          = Head.Address2;
            dr["Address3"]          = Head.Address3;
            dr["SpecialRemarks"]    = Head.SpecialRemarks;
            dr["PaymentTerms"]      = Head.PaymentTerms;
            dr["AdditionalRemarks"] = Head.AdditionalRemarks;
            dr["AddAmount"]         = Head.AddAmount;
            dr["DeductionRemarks"]  = Head.DeductionRemarks;
            dr["DedAmount"]         = Head.DedAmount;
            dr["BillDueDate"]       = Head.BillDueDate.ToString("dd-MMM-yyyy");
            ds.Tables["Head"].Rows.Add(dr);
            #endregion

            #region store data to Items Table
            CustomerInvoiceRepository repo1 = new CustomerInvoiceRepository();
            var Items = repo1.customerInvoiceItemforPrint(Id);
            foreach (var item in Items)
            {
                DataRow dri = ds.Tables["Items"].NewRow();
                dri["ProjectRefNo"]   = item.ProjectRefNo;
                dri["ProjectDate"]    = item.ProjectDate.ToString("dd-MMM-yyyy");
                dri["ProjectEnquiry"] = item.ProjectEnquiry;
                dri["Description"]    = item.Description;
                dri["Amount"]         = item.Amount;
                dri["InvoiceAmount"]  = item.InvoiceAmount;
                ds.Tables["Items"].Rows.Add(dri);
            }
            #endregion



            ds.WriteXml(Path.Combine(Server.MapPath("~/XML"), "CustomerInvoice.xml"), XmlWriteMode.WriteSchema);

            rd.SetDataSource(ds);

            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();


            try
            {
                Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stream.Seek(0, SeekOrigin.Begin);
                return(File(stream, "application/pdf"));//, String.Format("SalesInvoice{0}.pdf", Id.ToString()));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public IEnumerable <CustomerInvoices> GetCustomerInvoicesByCustomerNo(string customerNo)
        {
            var ci = CustomerInvoiceRepository.ListByCustom("CustomerNo", customerNo);

            return(ci);
        }
Beispiel #10
0
        public RepositoryFactory()
        {
            Repository                           bankRepository         = new Repository(new Bank());
            CurrencyRepository                   ccyRepository          = new CurrencyRepository();
            Repository                           divRepository          = new Repository(new Division());
            Repository                           empRepository          = new EmployeeRepository(new Employee());
            Repository                           topRepository          = new Repository(new TermOfPayment());
            Repository                           unitRepository         = new Repository(new Unit());
            Repository                           cuscatRepository       = new Repository(new CustomerCategory());
            Repository                           supcatRepository       = new Repository(new SupplierCategory());
            Repository                           pricecatRepository     = new Repository(new PriceCategory());
            Repository                           taxRepository          = new Repository(new Tax());
            Repository                           prtGroupRepository     = new Repository(new PartGroup());
            Repository                           warehouseRepository    = new Repository(new Warehouse());
            Repository                           prtCategoryRepository  = new Repository(new PartCategory());
            Repository                           docTypeRepository      = new Repository(new DocumentType());
            Repository                           excRateRepository      = new Repository(new ExchangeRate());
            CustomerRepository                   customerRepository     = new CustomerRepository();
            SupplierRepository                   supplierRepository     = new SupplierRepository();
            Repository                           yearRepository         = new YearRepository();
            Repository                           partRepository         = new PartRepository(new Part());
            StockTakingRepository                stocktakingRepository  = new StockTakingRepository();
            UserRepository                       userRepository         = new UserRepository(new User());
            GeneralSetupRepository               generalsetupRepository = new GeneralSetupRepository();
            PurchaseOrderRepository              poRepository           = new PurchaseOrderRepository();
            PeriodRepository                     periodRepository       = new PeriodRepository();
            UserSettingsRepository               usRepository           = new UserSettingsRepository();
            GoodReceiveNoteRepository            grnRepository          = new GoodReceiveNoteRepository();
            PurchaseReturnRepository             prRepository           = new PurchaseReturnRepository();
            SupplierInvoiceRepository            siRepository           = new SupplierInvoiceRepository();
            SupplierOutStandingInvoiceRepository soiRepository          = new SupplierOutStandingInvoiceRepository();
            SupplierInvoiceJournalRepository     sijRepository          = new SupplierInvoiceJournalRepository();
            PaymentRepository                    payRepository          = new PaymentRepository();
            APDebitNoteRepository                apdnRepository         = new APDebitNoteRepository();
            ProcessTransactionRepository         prtrRepository         = new ProcessTransactionRepository();
            SalesOrderRepository                 slsorderRepository     = new SalesOrderRepository();
            DeliveryOrderRepository              doRepository           = new DeliveryOrderRepository();
            SalesReturnRepository                srRepository           = new SalesReturnRepository();
            CustomerOutStandingInvoiceRepository coirRepository         = new CustomerOutStandingInvoiceRepository();
            CustomerInvoiceRepository            cirRepository          = new CustomerInvoiceRepository();
            ReceiptRepository                    rcptRepository         = new ReceiptRepository();
            ARCreditNoteRepository               arcrRepository         = new ARCreditNoteRepository();
            CustomerInvoiceJournalRepository     cijRepository          = new CustomerInvoiceJournalRepository();
            OpeningStockRepository               opstRepository         = new OpeningStockRepository();
            POSRepository                        posRepository          = new POSRepository();

            m_listService.Add(BANK_REPOSITORY, bankRepository);
            m_listService.Add(CURRENCY_REPOSITORY, ccyRepository);
            m_listService.Add(DIVISION_REPOSITORY, divRepository);
            m_listService.Add(EMPLOYEE_REPOSITORY, empRepository);
            m_listService.Add(TOP_REPOSITORY, topRepository);
            m_listService.Add(UNIT_REPOSITORY, unitRepository);
            m_listService.Add(CUSTOMER_CATEGORY_REPOSITORY, cuscatRepository);
            m_listService.Add(SUPPLIER_CATEGORY_REPOSITORY, supcatRepository);
            m_listService.Add(PRICE_CATEGORY_REPOSITORY, pricecatRepository);
            m_listService.Add(TAX_REPOSITORY, taxRepository);
            m_listService.Add(PART_GROUP_REPOSITORY, prtGroupRepository);
            m_listService.Add(WAREHOUSE_REPOSITORY, warehouseRepository);
            m_listService.Add(PART_CATEGORY_REPOSITORY, prtCategoryRepository);
            m_listService.Add(DOC_TYPE_REPOSITORY, docTypeRepository);
            m_listService.Add(EXCHANGE_RATE_REPOSITORY, excRateRepository);
            m_listService.Add(CUSTOMER_REPOSITORY, customerRepository);
            m_listService.Add(SUPPLIER_REPOSITORY, supplierRepository);
            m_listService.Add(YEAR_REPOSITORY, yearRepository);
            m_listService.Add(PART_REPOSITORY, partRepository);
            m_listService.Add(STOCKTAKING_REPOSITORY, stocktakingRepository);
            m_listService.Add(USER_REPOSITORY, userRepository);
            m_listService.Add(GENERAL_SETUP_REPOSITORY, generalsetupRepository);
            m_listService.Add(PURCHASEORDER_REPOSITORY, poRepository);
            m_listService.Add(PERIOD_REPOSITORY, periodRepository);
            m_listService.Add(USER_SETTING_REPOSITORY, usRepository);
            m_listService.Add(GOODRECEIVENOTE_REPOSITORY, grnRepository);
            m_listService.Add(PURCHASE_RETURN_REPOSITORY, prRepository);
            m_listService.Add(SUPPLIERINVOICE_REPOSITORY, siRepository);
            m_listService.Add(SUPPLIERINVOICE_JOURNAL_REPOSITORY, sijRepository);
            m_listService.Add(SUPPLIER_OUTSTANDING_INVOICE_REPOSITORY, soiRepository);
            m_listService.Add(PAYMENT_REPOSITORY, payRepository);
            m_listService.Add(APDEBITNOTE_REPOSITORY, apdnRepository);
            m_listService.Add(PROCESS_TRANSACTION_REPOSITORY, prtrRepository);
            m_listService.Add(SALES_ORDER_REPOSITORY, slsorderRepository);
            m_listService.Add(DELIVERY_ORDER_REPOSITORY, doRepository);
            m_listService.Add(SALES_RETURN_REPOSITORY, srRepository);
            m_listService.Add(CUSTOMER_OUTSTANDING_INVOICE_REPOSITORY, coirRepository);
            m_listService.Add(CUSTOMERINVOICE_REPOSITORY, cirRepository);
            m_listService.Add(RECEIPT_REPOSITORY, rcptRepository);
            m_listService.Add(ARCREDITNOTE_REPOSITORY, arcrRepository);
            m_listService.Add(CUSTOMERINVOICE_JOURNAL_REPOSITORY, cijRepository);
            m_listService.Add(OPENING_STOCK_REPOSITORY, opstRepository);
            m_listService.Add(POS_REPOSITORY, posRepository);
        }
        public ActionResult Print(int Id)
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports"), "CustomerInvoice.rpt"));

            DataSet ds = new DataSet();

            ds.Tables.Add("Head");
            ds.Tables.Add("Items");

            //    //-------HEAD


            ds.Tables["Head"].Columns.Add("DocumentNo");
            ds.Tables["Head"].Columns.Add("DocumentDate");
            ds.Tables["Head"].Columns.Add("Location");
            ds.Tables["Head"].Columns.Add("InsuredName");
            ds.Tables["Head"].Columns.Add("SpecialRemarks");
            //-------DT
            ds.Tables["Items"].Columns.Add("EffectiveDate");
            ds.Tables["Items"].Columns.Add("InsuranceType");
            ds.Tables["Items"].Columns.Add("PolicyOrEndorseNo");
            ds.Tables["Items"].Columns.Add("Company");
            ds.Tables["Items"].Columns.Add("Premium");
            ds.Tables["Items"].Columns.Add("Remarks");
            CustomerInvoiceRepository repo = new CustomerInvoiceRepository();
            var     Head = repo.GetCustomerInvoiceHdDetails(Id);
            DataRow dr   = ds.Tables["Head"].NewRow();

            dr["DocumentNo"]     = Head.CusInvoiceRefNo;
            dr["DocumentDate"]   = Head.CusInvoiceDate.Value.ToString("dd-MMM-yyyy");
            dr["InsuredName"]    = Head.CusName;
            dr["SpecialRemarks"] = Head.SpecialRemarks;

            ds.Tables["Head"].Rows.Add(dr);

            var Items = repo.GetCustomerInvoicePrint(Id);

            foreach (var item in Items)
            {
                var CustomerInvoiceItem = new CustomerInvoiceItem
                {
                    EffectiveDate = item.EffectiveDate,
                    TranType      = item.TranType,
                    PolicyNo      = item.PolicyNo,
                    InsCmpName    = item.InsCmpName,
                    TotalPremium  = item.TotalPremium,
                    Remarks       = item.Remarks
                };

                DataRow dri = ds.Tables["Items"].NewRow();
                dri["EffectiveDate"]     = CustomerInvoiceItem.EffectiveDate.Value.ToString("dd-MMM-yyyy");
                dri["InsuranceType"]     = CustomerInvoiceItem.TranType;
                dri["PolicyOrEndorseNo"] = CustomerInvoiceItem.PolicyNo;
                dri["Company"]           = CustomerInvoiceItem.InsCmpName;
                dri["Premium"]           = CustomerInvoiceItem.TotalPremium;
                dri["Remarks"]           = CustomerInvoiceItem.Remarks;
                ds.Tables["Items"].Rows.Add(dri);
            }

            ds.WriteXml(Path.Combine(Server.MapPath("~/XML"), "CustomerInvoice.xml"), XmlWriteMode.WriteSchema);

            rd.SetDataSource(ds);

            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();

            try
            {
                Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stream.Seek(0, SeekOrigin.Begin);
                return(File(stream, "application/pdf"));
            }
            catch (Exception ex)
            {
                throw;
            }
        }