public void UpdateDebitNote(DebitNoteForm debitNote)
        {
            try
            {
                using (SDNPurchasingDBEntities entities = new SDNPurchasingDBEntities())
                {
                    DebitNote obj = entities.DebitNotes.Where(e => e.DN_No == debitNote.DebitNote.DebitNo
                                                              ).SingleOrDefault();
                    if (obj != null)
                    {
                        if (!string.IsNullOrEmpty(debitNote.DebitNote.SupplierCreditNoteAmount))
                        {
                            debitNote.DebitNote.SCNAmount = Convert.ToDecimal(debitNote.DebitNote.SupplierCreditNoteAmount);
                        }

                        obj.Sup_CN_No     = debitNote.DebitNote.SupplierCreditNoteNo;
                        obj.Sup_CN_Date   = debitNote.DebitNote.SupplierCreditNoteDate;
                        obj.Sup_CN_Amount = debitNote.DebitNote.SCNAmount;
                        obj.ModifiedDate  = DateTime.Now;
                        entities.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
 public void UpdateDebitNote(DebitNoteForm debitNote)
 {
     try
     {
         IDebitNoteDAL debitNoteDAL = new DebitNoteDAL();
         debitNoteDAL.UpdateDebitNote(debitNote);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void CollectMoneyFromSupplier(object param)
        {
            MessageBoxResult result = System.Windows.MessageBox.Show("Do you want to save changes?", "Save Confirmation", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                Mouse.OverrideCursor = Cursors.Wait;

                PQErrors = string.Empty;
                DebitNoteForm PQForm = GetDataIntoModel();

                if (PQForm != null)
                {
                    dnRepository.UpdateDebitNote(PQForm);
                }
                if (param != null)
                {
                    SharedValues.NewClick = param.ToString();
                }
                SharedValues.ScreenCheckName = "Refund to Supplier";
                SharedValues.ViewName        = "Refund From Supplier";
                var accessitem = listitem.AddToList();
                if (accessitem == true)
                {
                    SharedValues.getValue       = "RefundFromSupplierTab";
                    SharedValues.CollectCommand = Convert.ToString(this.SelectedSupplierID);
                    var tabview = ServiceLocator.Current.GetInstance <CashBankTabView>();

                    var tabregion = this.regionManager.Regions[RegionNames.MenuBarRegion];
                    tabregion.Add(tabview);
                    if (tabregion != null)
                    {
                        tabregion.Activate(tabview);
                    }

                    var mainview = ServiceLocator.Current.GetInstance <RefundFromSupplierView>();

                    var mainregion = this.regionManager.Regions[RegionNames.MainRegion];
                    mainregion.Add(mainview);
                    if (mainregion != null)
                    {
                        mainregion.Activate(mainview);
                    }
                    eventAggregator.GetEvent <TabVisibilityEvent>().Publish(true);
                    eventAggregator.GetEvent <TitleChangedEvent>().Publish("Refund From Supplier Form");
                }
                else
                {
                    MessageBox.Show("You do not have access to this screen. Please contact your Administrator.\n" + "@ Simple Accounting Software Pte Ltd");
                }
                Mouse.OverrideCursor = null;
            }
        }
Exemple #4
0
        public void GetDebitNote(object param)
        {
            if (param != null)
            {
                DebitNoteForm pqf = dnRepository.GetDebitNoteDetails(Convert.ToString(param));

                this.ID                       = pqf.DebitNote.ID;
                this.DebitNo                  = pqf.DebitNote.DebitNo;
                this.DebitDate                = pqf.DebitNote.DebitDate;
                this.SupplierCreditNoteNo     = pqf.DebitNote.SupplierCreditNoteNo;
                this.SupplierCreditNoteDate   = pqf.DebitNote.SupplierCreditNoteDate;
                this.SupplierCreditNoteAmount = pqf.DebitNote.SupplierCreditNoteAmount;
                this.SelectedSupplierID       = pqf.DebitNote.SupplierID;
                this.PurchaseInvoiceID        = pqf.DebitNote.PurchaseInvoiceID;
                this.PurchaseInvoiceNo        = pqf.DebitNote.PurchaseInvoiceNo;
                this.TermsAndConditions       = pqf.DebitNote.TermsAndConditions;

                this.TotalBeforeTax    = pqf.DebitNote.TotalBeforeTax;
                this.TotalTax          = pqf.DebitNote.TotalTax;
                this.TotalAfterTax     = pqf.DebitNote.TotalAfterTax;
                this.TotalBeforeTaxStr = Convert.ToString(this.TotalBeforeTax);
                this.TotalTaxStr       = Convert.ToString(TotalTax);
                this.TotalAfterTaxStr  = Convert.ToString(TotalAfterTax);

                this.Status = pqf.DebitNote.Status;


                this.PQDetailsEntity = new ObservableCollection <DataGridViewModel>();
                foreach (var item in pqf.InvoiceDetails)
                {
                    DataGridViewModel pqEntity = new DataGridViewModel(ProductList);
                    pqEntity.SelectedPSID = Convert.ToString(item.PINo);
                    pqEntity.PandSCode    = item.PandSCode;
                    pqEntity.PandSName    = item.PandSName;
                    pqEntity.GSTRate      = Math.Round(Convert.ToDecimal(item.GSTRate), DecimalPlaces);
                    pqEntity.GSTRateStr   = Convert.ToString(pqEntity.GSTRate) + "%";
                    pqEntity.PQQty        = item.PIQty;
                    pqEntity.PQPrice      = Convert.ToString(item.Price);
                    pqEntity.PQDiscount   = Math.Round((decimal)item.PIDiscount, 2);

                    //  PQDEntity.GSTRate = item.GSTRate;
                    pqEntity.PQAmount = item.PIAmount;

                    PQDetailsEntity.Add(pqEntity);
                }
            }
        }
        public DebitNoteForm GetDataIntoModel()
        {
            OptionsEntity             oData = new OptionsEntity();
            ISalesOrderListRepository purchaseRepository = new SalesOrderListRepository();

            oData = purchaseRepository.GetOptionSettings();
            DebitNoteForm PQForm = new DebitNoteForm();

            PQForm.InvoiceDetails = new List <PurchaseInvoiceDetailEntity>();
            DebitNoteEntity model = new DebitNoteEntity();

            model.DebitNo                  = this.DebitNo;
            model.DebitDate                = this.DebitDate;
            model.TotalBeforeTax           = this.TotalBeforeTax;
            model.TotalTax                 = this.TotalTax;
            model.TotalAfterTax            = this.TotalAfterTax;
            model.SupplierCreditNoteNo     = this.SupplierCreditNoteNo;
            model.SupplierCreditNoteDate   = DateTime.ParseExact(this.SupplierCreditNoteDateStr, oData.DateFormat, null);
            model.SupplierCreditNoteAmount = this.SupplierCreditNoteAmount;
            model.SupplierID               = this.SelectedSupplierID;

            model.TermsAndConditions = this.TermsAndConditions;

            PQForm.DebitNote = model;

            foreach (var item in PQDetailsEntity)
            {
                PurchaseInvoiceDetailEntity pqEntity = new PurchaseInvoiceDetailEntity();
                pqEntity.PINo       = Convert.ToString(item.SelectedPSID);
                pqEntity.PandSCode  = item.PandSCode;
                pqEntity.PandSName  = item.PandSName;
                pqEntity.PIQty      = item.PQQty;
                pqEntity.PIPrice    = item.PQPrice;
                pqEntity.PIDiscount = item.PQDiscount;
                pqEntity.GSTRate    = item.GSTRate;
                pqEntity.GSTRateStr = Convert.ToString(item.GSTRate) + "%";
                pqEntity.PIAmount   = item.PQAmount;
                if (item.SelectedPSID != null && Convert.ToInt32(item.SelectedPSID) > 0)
                {
                    PQForm.InvoiceDetails.Add(pqEntity);
                }
            }
            return(PQForm);
        }
        /// <summary>
        /// This method is used to save and edit pq
        /// </summary>
        /// <param name="param"></param>
        public void UpdateDebitNote(object param)
        {
            MessageBoxResult result = System.Windows.MessageBox.Show("Do you want to save changes?", "Save Confirmation", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                Mouse.OverrideCursor = Cursors.Wait;

                PQErrors = string.Empty;
                DebitNoteForm PQForm = GetDataIntoModel();

                if (PQForm != null)
                {
                    dnRepository.UpdateDebitNote(PQForm);
                }

                Mouse.OverrideCursor = null;
            }
        }
Exemple #7
0
        public void CollectMoneyFromSupplier(object param)
        {
            MessageBoxResult result = System.Windows.MessageBox.Show("Do you want to save changes?", "Save Confirmation", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                Mouse.OverrideCursor = Cursors.Wait;

                PQErrors = string.Empty;
                DebitNoteForm PQForm = GetDataIntoModel();

                if (PQForm != null)
                {
                    dnRepository.UpdateDebitNote(PQForm);
                }
                if (param != null)
                {
                    SharedValues.NewClick = param.ToString();
                }
                SharedValues.getValue       = "RefundFromSupplierTab";
                SharedValues.CollectCommand = Convert.ToString(this.SelectedSupplierID);
                var tabview = ServiceLocator.Current.GetInstance <SDN.Common.View.CashAndBankTabView>();

                var tabregion = this.regionManager.Regions[RegionNames.MenuBarRegion];
                tabregion.Add(tabview);
                if (tabregion != null)
                {
                    tabregion.Activate(tabview);
                }

                var mainview = ServiceLocator.Current.GetInstance <RefundFromSupplierView>();

                var mainregion = this.regionManager.Regions[RegionNames.MainRegion];
                mainregion.Add(mainview);
                if (mainregion != null)
                {
                    mainregion.Activate(mainview);
                }
                eventAggregator.GetEvent <TabVisibilityEvent>().Publish(true);
                eventAggregator.GetEvent <TitleChangedEvent>().Publish("Refund From Supplier Form");
                Mouse.OverrideCursor = null;
            }
        }
Exemple #8
0
        public DebitNoteForm GetDataIntoModel()
        {
            DebitNoteForm PQForm = new DebitNoteForm();

            PQForm.InvoiceDetails = new List <PurchaseInvoiceDetailEntity>();
            DebitNoteEntity model = new DebitNoteEntity();

            model.DebitNo                  = this.DebitNo;
            model.DebitDate                = this.DebitDate;
            model.TotalBeforeTax           = this.TotalBeforeTax;
            model.TotalTax                 = this.TotalTax;
            model.TotalAfterTax            = this.TotalAfterTax;
            model.SupplierCreditNoteNo     = this.SupplierCreditNoteNo;
            model.SupplierCreditNoteDate   = this.SupplierCreditNoteDate;
            model.SupplierCreditNoteAmount = this.SupplierCreditNoteAmount;
            model.SupplierID               = this.SelectedSupplierID;

            model.TermsAndConditions = this.TermsAndConditions;

            PQForm.DebitNote = model;

            foreach (var item in PQDetailsEntity)
            {
                PurchaseInvoiceDetailEntity pqEntity = new PurchaseInvoiceDetailEntity();
                pqEntity.PINo       = Convert.ToString(item.SelectedPSID);
                pqEntity.PandSCode  = item.PandSCode;
                pqEntity.PandSName  = item.PandSName;
                pqEntity.PIQty      = item.PQQty;
                pqEntity.PIPrice    = item.PQPrice;
                pqEntity.PIDiscount = Math.Round((decimal)item.PQDiscount, 2);
                pqEntity.GSTRate    = item.GSTRate;
                pqEntity.GSTRateStr = Convert.ToString(item.GSTRate) + "%";
                pqEntity.PIAmount   = item.PQAmount;
                if (item.SelectedPSID != null && Convert.ToInt32(item.SelectedPSID) > 0)
                {
                    PQForm.InvoiceDetails.Add(pqEntity);
                }
            }
            return(PQForm);
        }
        public void GetDebitNote(object param)
        {
            OptionsEntity             oData = new OptionsEntity();
            ISalesOrderListRepository purchaseRepository = new SalesOrderListRepository();

            oData = purchaseRepository.GetOptionSettings();
            if (param != null)
            {
                DebitNoteForm pqf = dnRepository.GetDebitNoteDetails(Convert.ToString(param));

                this.ID                   = pqf.DebitNote.ID;
                this.DebitNo              = pqf.DebitNote.DebitNo;
                this.DebitDate            = pqf.DebitNote.DebitDate;
                this.SupplierCreditNoteNo = pqf.DebitNote.SupplierCreditNoteNo;
                if (SupplierCreditNoteDate == null)
                {
                    this.SupplierCreditNoteDate = pqf.DebitNote.SupplierCreditNoteDate;
                }
                else
                {
                    DateTime DateinStr = (DateTime)pqf.DebitNote.SupplierCreditNoteDate;
                    this.SupplierCreditNoteDateStr = DateinStr.ToString(oData.DateFormat);
                }

                this.SupplierCreditNoteAmount = pqf.DebitNote.SupplierCreditNoteAmount;
                this.SelectedSupplierID       = pqf.DebitNote.SupplierID;
                this.PurchaseInvoiceID        = pqf.DebitNote.PurchaseInvoiceID;
                this.PurchaseInvoiceNo        = pqf.DebitNote.PurchaseInvoiceNo;
                this.TermsAndConditions       = pqf.DebitNote.TermsAndConditions;

                this.TotalBeforeTax    = Convert.ToDecimal(pqf.DebitNote.TotalBeforeTax);
                this.TotalTax          = Convert.ToDecimal(pqf.DebitNote.TotalTax);
                this.TotalAfterTax     = Convert.ToDecimal(pqf.DebitNote.TotalAfterTax);
                this.TotalBeforeTaxStr = Convert.ToString(this.TotalBeforeTax);
                this.TotalTaxStr       = Convert.ToString(TotalTax);
                this.TotalAfterTaxStr  = Convert.ToString(TotalAfterTax);

                this.Status = pqf.DebitNote.Status;
                if (this.Status == 1)
                {
                    RubberStampDN = true;
                }
                else
                {
                    RubberStampDN = false;
                }


                this.PQDetailsEntity = new ObservableCollection <DataGridViewModel>();
                foreach (var item in pqf.InvoiceDetails)
                {
                    DataGridViewModel pqEntity = new DataGridViewModel(ProductList);
                    pqEntity.SelectedPSID = Convert.ToString(item.PINo);
                    pqEntity.PandSCode    = item.PandSCode;
                    pqEntity.PandSName    = item.PandSName;
                    pqEntity.GSTRate      = Math.Round(Convert.ToDecimal(item.GSTRate), DecimalPlaces);
                    pqEntity.GSTRateStr   = Convert.ToString(pqEntity.GSTRate) + "%";
                    pqEntity.PQQty        = item.PIQty;
                    pqEntity.PQPrice      = Convert.ToString(item.Price);
                    pqEntity.PQDiscount   = item.PIDiscount;

                    //  PQDEntity.GSTRate = item.GSTRate;
                    pqEntity.PQAmount = item.PIAmount;

                    PQDetailsEntity.Add(pqEntity);
                }
            }
        }
        private void UserControl_LoadedDebitNote(object sender, RoutedEventArgs e)
        {
            //var a = _viewModel.PrintSalesQuotation();
            DebitNoteForm sqf = _ViewModel.PrintDebitNote();

            // System.Drawing.Image newImage = byteArrayToImage(sqf.Quotation.CompanyLogo);
            // System.Drawing.Image x = (Bitmap)((new ImageConverter()).ConvertFrom(sqf.Quotation.CompanyLogo));


            //this is for table grid

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("PandSCode", typeof(string)));
            dt.Columns.Add(new DataColumn("PandSName", typeof(string)));
            dt.Columns.Add(new DataColumn("PIQty", typeof(string)));
            dt.Columns.Add(new DataColumn("Price", typeof(string)));
            dt.Columns.Add(new DataColumn("PIDiscount", typeof(string)));
            dt.Columns.Add(new DataColumn("PIAmount", typeof(string)));
            dt.Columns.Add(new DataColumn("GSTRate", typeof(string)));

            //ReportingDataset ds = new ReportingDataset();


            foreach (var item in sqf.InvoiceDetails)
            {
                DataRow dr = dt.NewRow();
                dr["PandSCode"]  = item.PandSCode;
                dr["PandSName"]  = item.PandSName;
                dr["PIQty"]      = item.PIQty;
                dr["Price"]      = item.Price.ToString();
                dr["PIDiscount"] = item.PIDiscount;
                dr["PIAmount"]   = item.PIAmount.ToString();
                dr["GSTRate"]    = item.GSTRate.ToString();
                dt.Rows.Add(dr);
            }



            ReportDataSource reportDataSource = new ReportDataSource();

            reportDataSource.Name  = "DebitNoteDataSet"; // Name of the DataSet we set in .rdlc
            reportDataSource.Value = dt;

            // company details
            /*****Define column*****/
            DataTable dt1 = new DataTable();

            dt1.Columns.Add(new DataColumn("CompanyName", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyLogo", typeof(byte[])));
            dt1.Columns.Add(new DataColumn("CompanyRegNumber", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyGstNumber", typeof(string)));
            dt1.Columns.Add(new DataColumn("Telephone", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyFax", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyEmail", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyBillToAddressLine1", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyBillToAddressLine2", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyBillToCity", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyBillToState", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyBillToCountary", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyBillToPostCode", typeof(string)));
            /*****End  column*****/
            /*****data part*******/

            DataRow dr1 = dt1.NewRow();

            dr1["CompanyName"]               = sqf.DebitNote.CompanyName;
            dr1["CompanyLogo"]               = sqf.DebitNote.CompanyLogo;
            dr1["CompanyRegNumber"]          = sqf.DebitNote.CompanyRegNumber;
            dr1["CompanyGstNumber"]          = sqf.DebitNote.CompanyGstNumber;
            dr1["Telephone"]                 = sqf.DebitNote.Telephone;
            dr1["CompanyFax"]                = sqf.DebitNote.CompanyFax;
            dr1["CompanyEmail"]              = sqf.DebitNote.CompanyEmail;
            dr1["CompanyBillToAddressLine1"] = sqf.DebitNote.CompanyBillToAddressLine1;
            dr1["CompanyBillToAddressLine2"] = sqf.DebitNote.CompanyBillToAddressLine2;
            dr1["CompanyBillToCity"]         = sqf.DebitNote.CompanyBillToCity;
            dr1["CompanyBillToState"]        = sqf.DebitNote.CompanyBillToState;
            dr1["CompanyBillToCountary"]     = sqf.DebitNote.CompanyBillToCountary;
            dr1["CompanyBillToPostCode"]     = sqf.DebitNote.CompanyBillToPostCode;

            dt1.Rows.Add(dr1);
            /*****data part*******/
            ReportDataSource reportDataSource1 = new ReportDataSource();

            reportDataSource1.Name  = "CompanyDetailDataSet"; // Name of the DataSet we set in .rdlc
            reportDataSource1.Value = dt1;
            // end of company details

            //Customer Details
            /****column defn**/
            DataTable dt2 = new DataTable();

            dt2.Columns.Add(new DataColumn("SupplierName", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierBillToLine1", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierBillToLine2", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierBillToCity", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierBillToState", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierBillToCountary", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierBillToPostCode", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierTelephone", typeof(string)));
            dt2.Columns.Add(new DataColumn("TermsAndConditions", typeof(string)));
            dt2.Columns.Add(new DataColumn("TotalBeforeTax", typeof(string)));
            dt2.Columns.Add(new DataColumn("TotalTax", typeof(string)));
            dt2.Columns.Add(new DataColumn("TotalAfterTax", typeof(string)));
            dt2.Columns.Add(new DataColumn("DebitNo", typeof(string)));
            dt2.Columns.Add(new DataColumn("DebitDate", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierCreditNoteNo", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierCreditNoteDate", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierCreditNoteAmount", typeof(string)));
            /****end column defn**/
            /**data****/
            DataRow dr2 = dt2.NewRow();

            dr2["SupplierName"]           = sqf.DebitNote.SupplierName;
            dr2["SupplierBillToLine1"]    = sqf.DebitNote.SupplierBillToLine1;
            dr2["SupplierBillToLine2"]    = sqf.DebitNote.SupplierBillToLine2;
            dr2["SupplierBillToCity"]     = sqf.DebitNote.SupplierBillToCity;
            dr2["SupplierBillToState"]    = sqf.DebitNote.SupplierBillToState;
            dr2["SupplierBillToCountary"] = sqf.DebitNote.SupplierBillToCountary;
            dr2["SupplierBillToPostCode"] = sqf.DebitNote.SupplierBillToPostCode;
            dr2["SupplierTelephone"]      = sqf.DebitNote.SupplierTelephone;
            dr2["TermsAndConditions"]     = sqf.DebitNote.TermsAndConditions;
            dr2["TotalBeforeTax"]         = sqf.DebitNote.TotalAfterTax;
            dr2["TotalTax"]                 = sqf.DebitNote.TotalTax.ToString();
            dr2["TotalAfterTax"]            = sqf.DebitNote.TotalAfterTax.ToString();
            dr2["DebitNo"]                  = sqf.DebitNote.DebitNo;
            dr2["DebitDate"]                = sqf.DebitNote.DebitDate;
            dr2["SupplierCreditNoteNo"]     = sqf.DebitNote.SupplierCreditNoteNo;
            dr2["SupplierCreditNoteDate"]   = sqf.DebitNote.SupplierCreditNoteDate;
            dr2["SupplierCreditNoteAmount"] = sqf.DebitNote.SupplierCreditNoteAmount;
            /**end data****/
            dt2.Rows.Add(dr2);
            ReportDataSource reportDataSource2 = new ReportDataSource();

            reportDataSource2.Name  = "DebitNoteUniqueRecordDataSet"; // Name of the DataSet we set in .rdlc
            reportDataSource2.Value = dt2;
            //End Customer Details

            //option
            DataTable dt3 = new DataTable();

            dt3.Columns.Add(new DataColumn("CurrencyCode", typeof(string)));
            DataRow dr3 = dt3.NewRow();

            dr3["CurrencyCode"] = sqf.DebitNote.CurrencyCode;
            dt3.Rows.Add(dr3);

            ReportDataSource reportDataSource3 = new ReportDataSource();

            reportDataSource3.Name  = "OptionDataSet"; // Name of the DataSet we set in .rdlc
            reportDataSource3.Value = dt3;
            //end options

            string exefolder  = System.Windows.Forms.Application.StartupPath;
            string reportPath = System.IO.Path.Combine(exefolder, @"DebitNote.rdlc");

            reportViewer4.LocalReport.ReportPath = reportPath;

            //D:\DayUser\src\SAS - NEW\Client\SASClient\Reports\ReportsRdlc
            reportViewer4.LocalReport.DataSources.Clear();
            reportViewer4.LocalReport.DataSources.Add(reportDataSource);
            reportViewer4.LocalReport.DataSources.Add(reportDataSource1);
            reportViewer4.LocalReport.DataSources.Add(reportDataSource2);
            reportViewer4.LocalReport.DataSources.Add(reportDataSource3);
            reportViewer4.RefreshReport();
            // this.reportViewer1.Width = 75;
        }
        /// <summary>
        /// This method is used to get Purchase Invoice details
        /// </summary>
        /// <param name="pqId"></param>
        /// <returns></returns>
        public DebitNoteForm GetDebitNoteDetails(string dnNo)
        {
            DebitNoteForm pqf = new DebitNoteForm();

            try
            {
                using (SDNPurchasingDBEntities entities = new SDNPurchasingDBEntities())
                {
                    var pq = (from pqs in entities.PurchaseInvoices
                              join dn in entities.DebitNotes on
                              pqs.ID equals dn.PI_Id
                              where dn.DN_No == dnNo && (pqs.IsDeleted == false || pqs.IsDeleted == null)
                              select new DebitNoteEntity
                    {
                        ID = dn.ID,
                        SupplierCreditNoteNo = dn.Sup_CN_No,
                        SupplierCreditNoteDate = dn.Sup_CN_Date,
                        SCNAmount = dn.Sup_CN_Amount,
                        SupplierID = pqs.Sup_Id,
                        DebitNo = dn.DN_No,
                        DebitDate = dn.DN_Date,
                        TermsAndConditions = dn.DN_Reason,
                        TotalBeforeTax = pqs.PI_Tot_bef_Tax,
                        TotalTax = pqs.PI_GST_Amt,
                        TotalAfterTax = pqs.PI_Tot_aft_Tax,
                        ExcIncGST = pqs.Exc_Inc_GST,
                        PurchaseInvoiceNo = pqs.PI_No,
                        PurchaseInvoiceID = pqs.ID,
                        Status = dn.DN_Status
                    }).SingleOrDefault();

                    if (pq != null)
                    {
                        pq.SupplierCreditNoteAmount = Convert.ToString(pq.SCNAmount);
                        pqf.DebitNote = pq;
                    }


                    var pqd = (from pqds in entities.PurchaseInvoiceDetails
                               where pqds.PI_ID == pq.PurchaseInvoiceID
                               select new PurchaseInvoiceDetailEntity
                    {
                        ID = pqds.ID,
                        PIID = pqds.PI_ID,
                        PINo = pqds.PI_No,
                        PandSCode = pqds.PandS_Code,
                        PandSName = pqds.PandS_Name,
                        PIQty = pqds.PI_Qty,
                        Price = pqds.PI_Price,
                        PIDiscount = pqds.PI_Discount,
                        PIAmount = pqds.PI_Amount,
                        GSTRate = pqds.GST_Rate
                    }).ToList <PurchaseInvoiceDetailEntity>();

                    if (pqd != null)
                    {
                        pqf.InvoiceDetails = pqd;
                    }

                    return(pqf);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public DebitNoteForm GetPrintDebitNote(string pqNo)
        {
            DebitNoteForm pqf = new DebitNoteForm();

            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    var pq = (from pqs in entities.PurchaseInvoices
                              join dn in entities.DebitNotes on
                              pqs.ID equals dn.PI_Id
                              join S in entities.Suppliers on dn.Sup_Id equals S.ID
                              where dn.DN_No == pqNo && (pqs.IsDeleted == false || pqs.IsDeleted == null)
                              select new DebitNoteEntity
                    {
                        ID = dn.ID,
                        SupplierCreditNoteNo = dn.Sup_CN_No,
                        SupplierCreditNoteDate = dn.Sup_CN_Date,
                        SCNAmount = dn.Sup_CN_Amount,
                        SupplierID = pqs.Sup_Id,
                        SupplierName = S.Sup_Name,
                        SupplierBillToLine1 = S.Sup_Bill_to_line1,
                        SupplierBillToLine2 = S.Sup_Bill_to_line2,
                        SupplierBillToCity = S.Sup_Bill_to_city,
                        SupplierBillToState = S.Sup_Bill_to_state,
                        SupplierBillToCountary = S.Sup_Bill_to_country,
                        SupplierBillToPostCode = S.Sup_Bill_to_post_code,
                        SupplierTelephone = S.Sup_Telephone,
                        DebitNo = dn.DN_No,
                        DebitDate = dn.DN_Date,
                        TermsAndConditions = dn.DN_Reason,
                        TotalBeforeTax = pqs.PI_Tot_bef_Tax,
                        TotalTax = pqs.PI_GST_Amt,
                        TotalAfterTax = pqs.PI_Tot_aft_Tax,
                        ExcIncGST = pqs.Exc_Inc_GST,
                        PurchaseInvoiceNo = pqs.PI_No,
                        PurchaseInvoiceID = pqs.ID,
                        Status = dn.DN_Status
                    }).SingleOrDefault();

                    if (pq != null)
                    {
                        pq.SupplierCreditNoteAmount = Convert.ToString(pq.SCNAmount);
                        pqf.DebitNote = pq;
                    }
                    //company details binding data
                    var company = (from com in entities.CompanyDetails
                                   where (com.IsDeleted == false || com.IsDeleted == null)
                                   select new DebitNoteEntity
                    {
                        CompanyName = com.Comp_Name,
                        CompanyLogo = com.Comp_Logo,
                        CompanyRegNumber = com.Comp_Reg_No,
                        CompanyGstNumber = com.Comp_GST_Reg_No,
                        CompanyBillToAddressLine1 = com.Comp_Bill_to_line1,
                        CompanyBillToAddressLine2 = com.Comp_Bill_to_line2,
                        CompanyBillToCity = com.Comp_Bill_to_city,
                        CompanyBillToState = com.Comp_Bill_to_state,
                        CompanyBillToCountary = com.Comp_Bill_to_country,
                        CompanyBillToPostCode = com.Comp_Bill_to_post_code,
                        CompanyEmail = com.Comp_Email,
                        CompanyFax = com.Comp_Fax
                    }).SingleOrDefault();
                    pqf.DebitNote.CompanyName               = company.CompanyName;
                    pqf.DebitNote.CompanyLogo               = company.CompanyLogo;
                    pqf.DebitNote.CompanyRegNumber          = company.CompanyRegNumber;
                    pqf.DebitNote.CompanyGstNumber          = company.CompanyGstNumber;
                    pqf.DebitNote.CompanyBillToAddressLine1 = company.CompanyBillToAddressLine1;
                    pqf.DebitNote.CompanyBillToAddressLine2 = company.CompanyBillToAddressLine2;
                    pqf.DebitNote.CompanyBillToCity         = company.CompanyBillToCity;
                    pqf.DebitNote.CompanyBillToState        = company.CompanyBillToState;
                    pqf.DebitNote.CompanyBillToCountary     = company.CompanyBillToCountary;
                    pqf.DebitNote.CompanyBillToPostCode     = company.CompanyBillToPostCode;
                    pqf.DebitNote.CompanyEmail              = company.CompanyEmail;
                    pqf.DebitNote.CompanyFax = company.CompanyFax;
                    //end of company details binding
                    //option details
                    var optiondata = (from option in entities.Options
                                      select new DebitNoteEntity
                    {
                        CurrencyCode = option.Currency_Code
                    }).SingleOrDefault();
                    pqf.DebitNote.CurrencyCode = optiondata.CurrencyCode;
                    //end options details
                    var pqd = (from pqds in entities.PurchaseInvoiceDetails
                               where pqds.PI_ID == pq.PurchaseInvoiceID
                               select new PurchaseInvoiceDetailEntity
                    {
                        ID = pqds.ID,
                        PIID = pqds.PI_ID,
                        PINo = pqds.PI_No,
                        PandSCode = pqds.PandS_Code,
                        PandSName = pqds.PandS_Name,
                        PIQty = pqds.PI_Qty,
                        Price = pqds.PI_Price,
                        PIDiscount = pqds.PI_Discount,
                        PIAmount = pqds.PI_Amount,
                        GSTRate = pqds.GST_Rate
                    }).ToList <PurchaseInvoiceDetailEntity>();

                    if (pqd != null)
                    {
                        pqf.InvoiceDetails = pqd;
                    }

                    return(pqf);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }