예제 #1
0
        public void PopulateData()
        {
            try
            {
                this.grdInvoiceDetails.DataSource = rsInvoiceDetail.ParentTable;
                this.grdInvoiceDetails.DataBind();

                lblCreditNoteno.Text = rsInvoiceHead["InvoiceNo"].ToString();

                if (rsInvoiceHead["Document"] != DBNull.Value)
                {
                    strInvoiceDocument = rsInvoiceHead["Document"].ToString();
                }
                if (rsInvoiceHead["New_ActivityCode"] != DBNull.Value)
                {
                    lblActivityCode.Text = Convert.ToString(rsInvoiceHead["New_ActivityCode"]);
                }
                else
                {
                    lblActivityCode.Text = "";
                }

                if (rsInvoiceHead["New_AccountCategory"] != DBNull.Value)
                {
                    lblAccountCat.Text = Convert.ToString(rsInvoiceHead["New_AccountCategory"]);
                }
                else
                {
                    lblAccountCat.Text = "";
                }

                if (rsInvoiceHead["PaymentDueDate"] != DBNull.Value)
                {
                    lblPaymentDueDAte.Text = Convert.ToDateTime(rsInvoiceHead["PaymentDueDate"]).ToString("dd/MM/yyyy");
                }
                else
                {
                    lblPaymentDueDAte.Text = "";
                }

                if (rsInvoiceHead["DiscountPercent"] != DBNull.Value)
                {
                    lblTermsDiscount.Text = Convert.ToDouble(rsInvoiceHead["DiscountPercent"]).ToString("#0.00");
                }
                else
                {
                    lblTermsDiscount.Text = "0";
                }
                if (rsInvoiceHead["New_SettlementPercent2"] != DBNull.Value)
                {
                    lblSecondSettlementDiscount.Text = Convert.ToDouble(rsInvoiceHead["New_SettlementPercent2"]).ToString("#0.00");
                }
                else
                {
                    lblSecondSettlementDiscount.Text = "0";
                }
                if (rsInvoiceHead["CustomerAccNo"] != DBNull.Value)
                {
                    lblCustomerAccNo.Text = rsInvoiceHead["CustomerAccNo"].ToString();
                }

                if (rsInvoiceHead["New_InvoiceContact"] != DBNull.Value)
                {
                    lblCustomerContactName.Text = rsInvoiceHead["New_InvoiceContact"].ToString();
                }
                if (rsInvoiceHead["New_SettlementDays1"] != DBNull.Value)
                {
                    lblSettlementDays.Text = rsInvoiceHead["New_SettlementDays1"].ToString();
                }
                if (rsInvoiceHead["New_SettlementDays2"] != DBNull.Value)
                {
                    lblSecondSettlementDays.Text = rsInvoiceHead["New_SettlementDays2"].ToString();
                }
                if (rsInvoiceHead["New_InvoiceName"] != DBNull.Value)
                {
                    lblInvoiceName.Text = rsInvoiceHead["New_InvoiceName"].ToString();
                }

                try
                {
                    JKS.Invoice oInvoice = new JKS.Invoice();

                    if (rsInvoiceHead["CurrencyTypeID"] != DBNull.Value)
                    {
                        lblCurrency.Text = oInvoice.GetCurrencyName(Convert.ToInt32(rsInvoiceHead["CurrencyTypeID"]));
                    }
                }
                catch { }

                lblVATRegNo.Text = rsInvoiceHead["SellerVATNo"].ToString();

                if (rsInvoiceHead["InvoiceDate"] != DBNull.Value)
                {
                    lblInvoiceDate.Text = Convert.ToDateTime(rsInvoiceHead["InvoiceDate"]).ToString("dd/MM/yyyy");
                }
                else
                {
                    lblInvoiceDate.Text = "";
                }

                lblPaymentTerms.Text   = rsInvoiceHead["PaymentTerm"].ToString();
                lblDespatchNoteNo.Text = rsInvoiceHead["DespatchNoteNo"].ToString();

                if (rsInvoiceHead["DeliveryDate"] != DBNull.Value)
                {
                    lblDespatchDate.Text = Convert.ToDateTime(rsInvoiceHead["DeliveryDate"]).ToString("dd/MM/yyyy");
                }
                else
                {
                    lblDespatchDate.Text = "";
                }
                if (rsInvoiceHead["TaxPointDate"] != DBNull.Value)
                {
                    lblTaxPointDate.Text = Convert.ToDateTime(rsInvoiceHead["TaxPointDate"]).ToString("dd/MM/yyyy");
                }
                else
                {
                    lblTaxPointDate.Text = "";
                }

                lblNetTotal.Text = System.Convert.ToDouble(rsInvoiceHead["NetTotal"]).ToString("#0.00");
                lblTotal.Text    = System.Convert.ToDouble(rsInvoiceHead["TotalAmt"]).ToString("#0.00");
                txtVATAmt.Text   = System.Convert.ToDouble(rsInvoiceHead["VATAmt"]).ToString("#0.00");
                lblVAT.Text      = System.Convert.ToDouble(rsInvoiceHead["VATAmt"]).ToString("#0.00");
                if (rsInvoiceHead["amountifnotgbpcurrency"] != DBNull.Value)
                {
                    lblGBPEquiAmt.Text    = System.Convert.ToDouble(rsInvoiceHead["amountifnotgbpcurrency"]).ToString("#0.00");
                    lblGBPEquiAmt.Visible = true;
                }

                string s = GetAddressLine(rsInvoiceHead["DeliveryAddress1"].ToString());
                s += GetAddressLine(rsInvoiceHead["DeliveryAddress2"].ToString());
                s += GetAddressLine(rsInvoiceHead["DeliveryAddress3"].ToString());
                s += GetAddressLine(rsInvoiceHead["DeliveryAddress4"].ToString());
                s += GetAddressLine(rsInvoiceHead["DeliveryAddress5"].ToString());
                s += GetAddressLine(rsInvoiceHead["DeliveryCountry"].ToString());
                s += GetAddressLine(rsInvoiceHead["DeliveryZIP"].ToString());
                try
                {
                    s = s.Substring(0, s.Length - 3);
                }
                catch { }
                lblDeliveryAddress.Text = s;

                if (rsInvoiceHead["New_OverallDiscountPercent"] != DBNull.Value)
                {
                    lblOverAllDiscount.Text = rsInvoiceHead["New_OverallDiscountPercent"].ToString().Trim();
                }

                s  = GetAddressLine(rsInvoiceHead["InvoiceAddress1"].ToString());
                s += GetAddressLine(rsInvoiceHead["InvoiceAddress2"].ToString());
                s += GetAddressLine(rsInvoiceHead["InvoiceAddress3"].ToString());
                s += GetAddressLine(rsInvoiceHead["InvoiceAddress4"].ToString());
                s += GetAddressLine(rsInvoiceHead["InvoiceAddress5"].ToString());
                s += GetAddressLine(rsInvoiceHead["InvoiceCountry"].ToString());
                s += GetAddressLine(rsInvoiceHead["InvoiceZIP"].ToString());
                try
                {
                    s = s.Substring(0, s.Length - 3);
                }
                catch { }
                lblInvoiceAddress.Text = s;

                if (rsInvoiceHead["New_PaymentDate"] != DBNull.Value)
                {
                    lblpaymentdate.Text = System.Convert.ToDateTime(rsInvoiceHead["New_PaymentDate"]).ToString();
                }
                else
                {
                    lblpaymentdate.Text = "";
                }
                if (rsInvoiceHead["New_DiscountGiven"] != DBNull.Value)
                {
                    lblDiscount.Text = System.Convert.ToString(rsInvoiceHead["New_DiscountGiven"].ToString());
                }
                else
                {
                    lblDiscount.Text = "";
                }
                if (rsInvoiceHead["New_PaymentMethod"] != DBNull.Value)
                {
                    lblPaymentMethod.Text = System.Convert.ToString(rsInvoiceHead["New_PaymentMethod"].ToString());
                }
                else
                {
                    lblPaymentMethod.Text = "";
                }

                s  = GetAddressLine(rsInvoiceHead["SupplierAddress1"].ToString());
                s += GetAddressLine(rsInvoiceHead["SupplierAddress2"].ToString());
                s += GetAddressLine(rsInvoiceHead["SupplierAddress3"].ToString());
                s += GetAddressLine(rsInvoiceHead["SupplierAddress4"].ToString());
                s += GetAddressLine(rsInvoiceHead["SupplierAddress5"].ToString());
                s += GetAddressLine(rsInvoiceHead["SupplierCountry"].ToString());
                s += GetAddressLine(rsInvoiceHead["SupplierZIP"].ToString());
                try
                {
                    s = s.Substring(0, s.Length - 3);
                }
                catch { }
                lblSupplierAddress.Text = s;
                RecordSet rs = Company.GetCompanyData(System.Convert.ToInt32(rsInvoiceHead["SupplierCompanyID"]));
                lblSupplier.Text = rs["CompanyName"].ToString();
                rs            = Company.GetCompanyData(System.Convert.ToInt32(rsInvoiceHead["BuyerCompanyID"]));
                lblBuyer.Text = rs["CompanyName"].ToString();
                if (rsInvoiceHead["StatusId"] != DBNull.Value)
                {
                    lblStatus.Text = Invoice_CN.GetStatus((int)rsInvoiceHead["StatusId"]);
                }
                else
                {
                    lblStatus.Text = "Pending";
                }

                if (rsInvoiceHead["StatusId"].ToString() == "6" || rsInvoiceHead["StatusId"].ToString() == "26" || rsInvoiceHead["StatusId"].ToString() == "25")
                {
                    btnEdit.Visible = true;
                }
                else
                {
                    btnEdit.Visible = false;
                }
                if (Request.QueryString["AllowEdit"] != null)
                {
                    btnEdit.Visible = true;
                }
                else
                {
                    btnEdit.Visible = false;
                }
                if (Convert.ToInt32(Session["UserTypeID"]) >= 2)
                {
                    btnEdit.Visible = true;
                }
                else
                {
                    btnEdit.Visible = false;
                }

                if (ViewState["INID"] != null)
                {
                    Double dGBPEquivalentAmount = 0;
                    dGBPEquivalentAmount = objInvoice.GetGBPEquivalentAmount(Convert.ToInt32(ViewState["INID"]));
                    if (dGBPEquivalentAmount != 0)
                    {
                        lblGBPEquiAmt.Visible = true;
                        hdGBPEquiFlag.Value   = "1";
                        lblGBPEquiAmt.Text    = dGBPEquivalentAmount.ToString();
                    }
                    txtVATAmt.Visible = false;
                    lblVAT.Visible    = true;
                }
                if (Session["StrVATAmt_CN"] != null)
                {
                    lblGBPEquiAmt.Visible = true;
                    hdGBPEquiFlag.Value   = "1";
                    lblGBPEquiAmt.Text    = Session["StrVATAmt_CN"].ToString();
                }
                if (Convert.ToInt32(rsInvoiceHead["CurrencyTypeID"]) != 22 && Session["StrVATAmt_CN"] == null && ViewState["INID"] == null)
                {
                    txtSterlingEquivalent.Visible  = true;
                    trInputSterlingEquiAmt.Visible = true;
                }
                else
                {
                    trInputSterlingEquiAmt.Visible = false;
                }
                txtSterlingEquivalent.Visible = false;
            }
            catch { }
        }
예제 #2
0
        private void rptInvoice_DataInitialize(object sender, System.EventArgs eArgs)
        {
            RecordSet rsSupplier = Company.GetCompanyData(System.Convert.ToInt32(rsInvoiceHeader["SupplierCompanyID"]));
            RecordSet rsBuyer    = Company.GetCompanyData(System.Convert.ToInt32(rsInvoiceHeader["BuyerCompanyID"]));

            Fields.Add("SupplierComapany");
            Fields.Add("BuyerComapany");
            Fields.Add("New_InvoiceName");
            Fields.Add("CreditNoteID");
            Fields.Add("InvoiceNo");
            //Fields.Add("BranchID") ;
            Fields.Add("PaymentDueDate");
            Fields.Add("DiscountPercent");
            Fields.Add("CustomerAccNo");
            Fields.Add("InvoiceDate");
            Fields.Add("PaymentTerm");

            Fields.Add("NetTotal");
            Fields.Add("H_VATAmt");
            Fields.Add("H_TotalAmt");
            Fields.Add("InvoiceAddress");
            Fields.Add("DeliveryAddress");
            Fields.Add("SupplierAddress");
            Fields.Add("SellerVATNo");
            Fields.Add("New_InvoiceContact");
            Fields.Add("New_OverallDiscountPercent");
            Fields.Add("New_SettlementDays1");
            Fields.Add("New_SettlementDays2");
            Fields.Add("New_SettlementPercent2");
            //
            Fields.Add("New_PaymentDate");
            Fields.Add("New_PaymentMethod");
            Fields.Add("New_DiscountGiven");
            //invoice detail fields
            Fields.Add("PurOrderNo");
            Fields.Add("PurOrderLineNo");
            Fields.Add("PurOrderDate");
            Fields.Add("PurInfo");
            Fields.Add("Quantity");
            Fields.Add("Description");
            Fields.Add("UOM");
            Fields.Add("VATRate");
            Fields.Add("Discount");
            Fields.Add("Rate");
            Fields.Add("BuyersProdCode");
            Fields.Add("SuppliersProdCode");
            Fields.Add("New_DespatchNoteNumber");
            Fields.Add("New_DespatchDate");
            Fields.Add("New_DiscountPercent2");
            Fields.Add("New_NettValue");
            Fields.Add("VATAmt");
            Fields.Add("TotalAmt");
            Fields.Add("New_Type");
            Fields.Add("New_Definable1");

            Fields["CreditNoteID"].Value = rsInvoiceHeader["CreditNoteID"];
            Fields["InvoiceNo"].Value    = rsInvoiceHeader["InvoiceNo"];
            //Fields["BranchID"].Value   = rsInvoiceHeader["BranchID"]   ;
            Fields["PaymentDueDate"].Value             = rsInvoiceHeader["PaymentDueDate"];
            Fields["DiscountPercent"].Value            = rsInvoiceHeader["DiscountPercent"];
            Fields["New_SettlementPercent2"].Value     = rsInvoiceHeader["New_SettlementPercent2"];
            Fields["CustomerAccNo"].Value              = rsInvoiceHeader["CustomerAccNo"];
            Fields["New_InvoiceContact"].Value         = rsInvoiceHeader["New_InvoiceContact"];
            Fields["New_OverallDiscountPercent"].Value = rsInvoiceHeader["New_OverallDiscountPercent"];
            Fields["New_SettlementDays1"].Value        = rsInvoiceHeader["New_SettlementDays1"];
            Fields["New_SettlementDays2"].Value        = rsInvoiceHeader["New_SettlementDays2"];
            Fields["InvoiceDate"].Value = rsInvoiceHeader["InvoiceDate"];
            Fields["PaymentTerm"].Value = rsInvoiceHeader["PaymentTerm"];
            Fields["NetTotal"].Value    = rsInvoiceHeader["NetTotal"];
            Fields["H_VATAmt"].Value    = rsInvoiceHeader["VATAmt"];
            Fields["H_TotalAmt"].Value  = rsInvoiceHeader["TotalAmt"];


            Fields["SupplierComapany"].Value = rsSupplier["CompanyName"];
            Fields["BuyerComapany"].Value    = rsBuyer["CompanyName"];
            rsSupplier = null;
            rsBuyer    = null;


            Fields["New_InvoiceName"].Value = rsInvoiceHeader["New_InvoiceName"];

            JKS.Invoice objInvoice    = new JKS.Invoice();
            Invoice_CN  objInvoice_CN = new Invoice_CN();

            if (rsInvoiceHeader["CurrencyTypeID"] != DBNull.Value)
            {
                TextBox9.Text = objInvoice.GetCurrencyCode(Convert.ToInt32(rsInvoiceHeader["CurrencyTypeID"]));
            }
            Double dGBPEquivalentAmount = 0;

            dGBPEquivalentAmount = objInvoice_CN.GetGBPEquivalentAmount(Convert.ToInt32(rsInvoiceHeader["CreditNoteID"]));

            if (dGBPEquivalentAmount > 0)
            {
                lblGBPEquivalentAmount.Visible = true;
                tblGBPEquivalentAmount.Text    = dGBPEquivalentAmount.ToString();
            }

            if (rsInvoiceHeader["CreditNoteID"] != DBNull.Value)
            {
                txtAssociatedInvoiceNo.Text = objInvoice_CN.GetAssociatedInvoiceNo(Convert.ToInt32(rsInvoiceHeader["CreditNoteID"]));
            }

            string s = GetAddressLine(rsInvoiceHeader["DeliveryAddress1"].ToString());

            s += GetAddressLine(rsInvoiceHeader["DeliveryAddress2"].ToString());
            s += GetAddressLine(rsInvoiceHeader["DeliveryAddress3"].ToString());
            s += GetAddressLine(rsInvoiceHeader["DeliveryAddress4"].ToString());
            s += GetAddressLine(rsInvoiceHeader["DeliveryAddress5"].ToString());
            s += GetAddressLine(rsInvoiceHeader["DeliveryCountry"].ToString());
            s += GetAddressLine(rsInvoiceHeader["DeliveryZIP"].ToString());
            Fields["DeliveryAddress"].Value = s;

            s  = GetAddressLine(rsInvoiceHeader["InvoiceAddress1"].ToString());
            s += GetAddressLine(rsInvoiceHeader["InvoiceAddress2"].ToString());
            s += GetAddressLine(rsInvoiceHeader["InvoiceAddress3"].ToString());
            s += GetAddressLine(rsInvoiceHeader["InvoiceAddress4"].ToString());
            s += GetAddressLine(rsInvoiceHeader["InvoiceAddress5"].ToString());
            s += GetAddressLine(rsInvoiceHeader["InvoiceCountry"].ToString());
            s += GetAddressLine(rsInvoiceHeader["InvoiceZIP"].ToString());
            Fields["InvoiceAddress"].Value = s;

            s  = GetAddressLine(rsInvoiceHeader["SupplierAddress1"].ToString());
            s += GetAddressLine(rsInvoiceHeader["SupplierAddress2"].ToString());
            s += GetAddressLine(rsInvoiceHeader["SupplierAddress3"].ToString());
            s += GetAddressLine(rsInvoiceHeader["SupplierAddress4"].ToString());
            s += GetAddressLine(rsInvoiceHeader["SupplierAddress5"].ToString());
            s += GetAddressLine(rsInvoiceHeader["SupplierCountry"].ToString());
            s += GetAddressLine(rsInvoiceHeader["SupplierZIP"].ToString());
            Fields["SupplierAddress"].Value = s;
            Fields["SellerVATNo"].Value     = rsInvoiceHeader["SellerVATNo"];
        }