Ejemplo n.º 1
0
        /// <summary>
        /// GetForPage
        /// Calls [usp_select_Credit_for_Page]
        /// </summary>
        public override CreditDetails GetForPage(System.Int32?creditId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try
            {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_select_Credit_for_Page", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@CreditId", SqlDbType.Int).Value = creditId;
                cn.Open();
                DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    //return GetCreditFromReader(reader);
                    CreditDetails obj = new CreditDetails();
                    obj.CreditId        = GetReaderValue_Int32(reader, "CreditId", 0);
                    obj.CreditNumber    = GetReaderValue_Int32(reader, "CreditNumber", 0);
                    obj.ClientNo        = GetReaderValue_Int32(reader, "ClientNo", 0);
                    obj.CompanyNo       = GetReaderValue_Int32(reader, "CompanyNo", 0);
                    obj.CompanyName     = GetReaderValue_String(reader, "CompanyName", "");
                    obj.TeamNo          = GetReaderValue_NullableInt32(reader, "TeamNo", 0);
                    obj.DivisionNo      = GetReaderValue_Int32(reader, "DivisionNo", 0);
                    obj.Salesman        = GetReaderValue_Int32(reader, "Salesman", 0);
                    obj.isClientInvoice = GetReaderValue_Boolean(reader, "IsClientInvoice", false);
                    obj.RefClientName   = GetReaderValue_String(reader, "ClientName", "");
                    obj.RefClientNo     = GetReaderValue_NullableInt32(reader, "RefClientNo", 0);
                    obj.ClientCreditNo  = GetReaderValue_NullableInt32(reader, "ClientCreditNo", 0);
                    return(obj);
                }
                else
                {
                    return(null);
                }
            }
            catch (SqlException sqlex)
            {
                //LogException(sqlex);
                throw new Exception("Failed to get Credit", sqlex);
            }
            finally
            {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// GetNextNumber
        /// Calls [usp_select_Credit_NextNumber]
        /// </summary>
        public override CreditDetails GetNextNumber(System.Int32?clientNo, System.Int32?updatedBy)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try
            {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_select_Credit_NextNumber", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@ClientNo", SqlDbType.Int).Value      = clientNo;
                cmd.Parameters.Add("@UpdatedBy", SqlDbType.Int).Value     = updatedBy;
                cmd.Parameters.Add("@NewNumber", SqlDbType.Int).Direction = ParameterDirection.Output;
                cn.Open();
                DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    //return GetCreditFromReader(reader);
                    CreditDetails obj = new CreditDetails();
                    obj.CreditNumber = GetReaderValue_Int32(reader, "CreditNumber", 0);
                    return(obj);
                }
                else
                {
                    return(null);
                }
            }
            catch (SqlException sqlex)
            {
                //LogException(sqlex);
                throw new Exception("Failed to get Credit", sqlex);
            }
            finally
            {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
Ejemplo n.º 3
0
        private static Credit PopulateFromDBDetailsObject(CreditDetails obj)
        {
            Credit objNew = new Credit();

            objNew.CreditId            = obj.CreditId;
            objNew.CreditNumber        = obj.CreditNumber;
            objNew.ClientNo            = obj.ClientNo;
            objNew.CompanyNo           = obj.CompanyNo;
            objNew.ContactNo           = obj.ContactNo;
            objNew.CreditDate          = obj.CreditDate;
            objNew.CurrencyNo          = obj.CurrencyNo;
            objNew.RaisedBy            = obj.RaisedBy;
            objNew.Salesman            = obj.Salesman;
            objNew.Notes               = obj.Notes;
            objNew.Instructions        = obj.Instructions;
            objNew.ShipViaNo           = obj.ShipViaNo;
            objNew.Account             = obj.Account;
            objNew.ShippingCost        = obj.ShippingCost;
            objNew.Freight             = obj.Freight;
            objNew.DivisionNo          = obj.DivisionNo;
            objNew.TaxNo               = obj.TaxNo;
            objNew.InvoiceNo           = obj.InvoiceNo;
            objNew.CustomerRMANo       = obj.CustomerRMANo;
            objNew.ReferenceDate       = obj.ReferenceDate;
            objNew.CustomerPO          = obj.CustomerPO;
            objNew.CustomerRMA         = obj.CustomerRMA;
            objNew.CustomerDebit       = obj.CustomerDebit;
            objNew.UpdatedBy           = obj.UpdatedBy;
            objNew.DLUP                = obj.DLUP;
            objNew.Salesman2           = obj.Salesman2;
            objNew.Salesman2Percent    = obj.Salesman2Percent;
            objNew.IncotermNo          = obj.IncotermNo;
            objNew.DivisionNo2         = obj.DivisionNo2;
            objNew.CompanyName         = obj.CompanyName;
            objNew.CustomerCode        = obj.CustomerCode;
            objNew.ContactName         = obj.ContactName;
            objNew.CurrencyCode        = obj.CurrencyCode;
            objNew.CurrencyDescription = obj.CurrencyDescription;
            objNew.RaiserName          = obj.RaiserName;
            objNew.SalesmanName        = obj.SalesmanName;
            objNew.TeamNo              = obj.TeamNo;
            objNew.DivisionName        = obj.DivisionName;
            objNew.Salesman2Name       = obj.Salesman2Name;
            objNew.TaxName             = obj.TaxName;
            objNew.InvoiceNumber       = obj.InvoiceNumber;
            objNew.InvoiceDate         = obj.InvoiceDate;
            objNew.SalesOrderNo        = obj.SalesOrderNo;
            objNew.SalesOrderNumber    = obj.SalesOrderNumber;
            objNew.CustomerRMANumber   = obj.CustomerRMANumber;
            objNew.CustomerRMADate     = obj.CustomerRMADate;
            objNew.ShipViaName         = obj.ShipViaName;
            objNew.CreditValue         = obj.CreditValue;
            objNew.CreditCost          = obj.CreditCost;
            objNew.TaxRate             = obj.TaxRate;
            objNew.IncotermName        = obj.IncotermName;
            //[001] start code
            objNew.CreditNoteBankFee = obj.CreditNoteBankFee;
            //[001] end code
            objNew.CompanyTelephone = obj.CompanyTelephone;
            objNew.CompanyFax       = obj.CompanyFax;
            objNew.ContactEmail     = obj.ContactEmail;
            return(objNew);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// GetListForCompany
        /// Calls [usp_selectAll_Credit_for_Company]
        /// </summary>
        public override List <CreditDetails> GetListForCompany(System.Int32?companyId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try
            {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_selectAll_Credit_for_Company", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@CompanyId", SqlDbType.Int).Value = companyId;
                cn.Open();
                DbDataReader         reader = ExecuteReader(cmd);
                List <CreditDetails> lst    = new List <CreditDetails>();
                while (reader.Read())
                {
                    CreditDetails obj = new CreditDetails();
                    obj.CreditId            = GetReaderValue_Int32(reader, "CreditId", 0);
                    obj.CreditNumber        = GetReaderValue_Int32(reader, "CreditNumber", 0);
                    obj.ClientNo            = GetReaderValue_Int32(reader, "ClientNo", 0);
                    obj.CompanyNo           = GetReaderValue_Int32(reader, "CompanyNo", 0);
                    obj.ContactNo           = GetReaderValue_Int32(reader, "ContactNo", 0);
                    obj.CreditDate          = GetReaderValue_DateTime(reader, "CreditDate", DateTime.MinValue);
                    obj.CurrencyNo          = GetReaderValue_Int32(reader, "CurrencyNo", 0);
                    obj.RaisedBy            = GetReaderValue_NullableInt32(reader, "RaisedBy", null);
                    obj.Salesman            = GetReaderValue_Int32(reader, "Salesman", 0);
                    obj.Notes               = GetReaderValue_String(reader, "Notes", "");
                    obj.Instructions        = GetReaderValue_String(reader, "Instructions", "");
                    obj.ShipViaNo           = GetReaderValue_NullableInt32(reader, "ShipViaNo", null);
                    obj.Account             = GetReaderValue_String(reader, "Account", "");
                    obj.ShippingCost        = GetReaderValue_NullableDouble(reader, "ShippingCost", null);
                    obj.Freight             = GetReaderValue_NullableDouble(reader, "Freight", null);
                    obj.DivisionNo          = GetReaderValue_Int32(reader, "DivisionNo", 0);
                    obj.TaxNo               = GetReaderValue_NullableInt32(reader, "TaxNo", null);
                    obj.InvoiceNo           = GetReaderValue_NullableInt32(reader, "InvoiceNo", null);
                    obj.CustomerRMANo       = GetReaderValue_NullableInt32(reader, "CustomerRMANo", null);
                    obj.ReferenceDate       = GetReaderValue_DateTime(reader, "ReferenceDate", DateTime.MinValue);
                    obj.CustomerPO          = GetReaderValue_String(reader, "CustomerPO", "");
                    obj.CustomerRMA         = GetReaderValue_String(reader, "CustomerRMA", "");
                    obj.CustomerDebit       = GetReaderValue_String(reader, "CustomerDebit", "");
                    obj.UpdatedBy           = GetReaderValue_NullableInt32(reader, "UpdatedBy", null);
                    obj.DLUP                = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue);
                    obj.Salesman2           = GetReaderValue_NullableInt32(reader, "Salesman2", null);
                    obj.Salesman2Percent    = GetReaderValue_Double(reader, "Salesman2Percent", 0);
                    obj.IncotermNo          = GetReaderValue_NullableInt32(reader, "IncotermNo", null);
                    obj.CompanyName         = GetReaderValue_String(reader, "CompanyName", "");
                    obj.CustomerCode        = GetReaderValue_String(reader, "CustomerCode", "");
                    obj.ContactName         = GetReaderValue_String(reader, "ContactName", "");
                    obj.CurrencyCode        = GetReaderValue_String(reader, "CurrencyCode", "");
                    obj.CurrencyDescription = GetReaderValue_String(reader, "CurrencyDescription", "");
                    obj.RaiserName          = GetReaderValue_String(reader, "RaiserName", "");
                    obj.SalesmanName        = GetReaderValue_String(reader, "SalesmanName", "");
                    obj.TeamNo              = GetReaderValue_NullableInt32(reader, "TeamNo", null);
                    obj.DivisionName        = GetReaderValue_String(reader, "DivisionName", "");
                    obj.Salesman2Name       = GetReaderValue_String(reader, "Salesman2Name", "");
                    obj.TaxName             = GetReaderValue_String(reader, "TaxName", "");
                    obj.InvoiceNumber       = GetReaderValue_NullableInt32(reader, "InvoiceNumber", null);
                    obj.InvoiceDate         = GetReaderValue_NullableDateTime(reader, "InvoiceDate", null);
                    obj.SalesOrderNo        = GetReaderValue_NullableInt32(reader, "SalesOrderNo", null);
                    obj.SalesOrderNumber    = GetReaderValue_NullableInt32(reader, "SalesOrderNumber", null);
                    obj.CustomerRMANumber   = GetReaderValue_NullableInt32(reader, "CustomerRMANumber", null);
                    obj.CustomerRMADate     = GetReaderValue_NullableDateTime(reader, "CustomerRMADate", null);
                    obj.ShipViaName         = GetReaderValue_String(reader, "ShipViaName", "");
                    obj.CreditValue         = GetReaderValue_NullableDouble(reader, "CreditValue", null);
                    obj.CreditCost          = GetReaderValue_NullableDouble(reader, "CreditCost", null);
                    obj.TaxRate             = GetReaderValue_NullableDouble(reader, "TaxRate", null);
                    obj.IncotermName        = GetReaderValue_String(reader, "IncotermName", "");
                    lst.Add(obj);
                    obj = null;
                }
                return(lst);
            }
            catch (SqlException sqlex)
            {
                //LogException(sqlex);
                throw new Exception("Failed to get Credits", sqlex);
            }
            finally
            {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// GetForPrint
        /// Calls [usp_select_Credit_for_Print]
        /// </summary>
        public override CreditDetails GetForPrint(System.Int32?creditId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try
            {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_select_Credit_for_Print", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@CreditId", SqlDbType.Int).Value = creditId;
                cn.Open();
                DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    //return GetCreditFromReader(reader);
                    CreditDetails obj = new CreditDetails();
                    obj.CreditId            = GetReaderValue_Int32(reader, "CreditId", 0);
                    obj.CreditNumber        = GetReaderValue_Int32(reader, "CreditNumber", 0);
                    obj.ClientNo            = GetReaderValue_Int32(reader, "ClientNo", 0);
                    obj.CompanyNo           = GetReaderValue_Int32(reader, "CompanyNo", 0);
                    obj.ContactNo           = GetReaderValue_Int32(reader, "ContactNo", 0);
                    obj.CreditDate          = GetReaderValue_DateTime(reader, "CreditDate", DateTime.MinValue);
                    obj.CurrencyNo          = GetReaderValue_Int32(reader, "CurrencyNo", 0);
                    obj.RaisedBy            = GetReaderValue_NullableInt32(reader, "RaisedBy", null);
                    obj.Salesman            = GetReaderValue_Int32(reader, "Salesman", 0);
                    obj.Notes               = GetReaderValue_String(reader, "Notes", "");
                    obj.Instructions        = GetReaderValue_String(reader, "Instructions", "");
                    obj.ShipViaNo           = GetReaderValue_NullableInt32(reader, "ShipViaNo", null);
                    obj.Account             = GetReaderValue_String(reader, "Account", "");
                    obj.ShippingCost        = GetReaderValue_NullableDouble(reader, "ShippingCost", null);
                    obj.Freight             = GetReaderValue_NullableDouble(reader, "Freight", null);
                    obj.DivisionNo          = GetReaderValue_Int32(reader, "DivisionNo", 0);
                    obj.TaxNo               = GetReaderValue_NullableInt32(reader, "TaxNo", null);
                    obj.InvoiceNo           = GetReaderValue_NullableInt32(reader, "InvoiceNo", null);
                    obj.CustomerRMANo       = GetReaderValue_NullableInt32(reader, "CustomerRMANo", null);
                    obj.ReferenceDate       = GetReaderValue_DateTime(reader, "ReferenceDate", DateTime.MinValue);
                    obj.CustomerPO          = GetReaderValue_String(reader, "CustomerPO", "");
                    obj.CustomerRMA         = GetReaderValue_String(reader, "CustomerRMA", "");
                    obj.CustomerDebit       = GetReaderValue_String(reader, "CustomerDebit", "");
                    obj.UpdatedBy           = GetReaderValue_NullableInt32(reader, "UpdatedBy", null);
                    obj.DLUP                = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue);
                    obj.Salesman2           = GetReaderValue_NullableInt32(reader, "Salesman2", null);
                    obj.Salesman2Percent    = GetReaderValue_Double(reader, "Salesman2Percent", 0);
                    obj.IncotermNo          = GetReaderValue_NullableInt32(reader, "IncotermNo", null);
                    obj.CompanyName         = GetReaderValue_String(reader, "CompanyName", "");
                    obj.CustomerCode        = GetReaderValue_String(reader, "CustomerCode", "");
                    obj.ContactName         = GetReaderValue_String(reader, "ContactName", "");
                    obj.CurrencyCode        = GetReaderValue_String(reader, "CurrencyCode", "");
                    obj.CurrencyDescription = GetReaderValue_String(reader, "CurrencyDescription", "");
                    obj.RaiserName          = GetReaderValue_String(reader, "RaiserName", "");
                    obj.SalesmanName        = GetReaderValue_String(reader, "SalesmanName", "");
                    obj.TeamNo              = GetReaderValue_NullableInt32(reader, "TeamNo", null);
                    obj.DivisionName        = GetReaderValue_String(reader, "DivisionName", "");
                    obj.Salesman2Name       = GetReaderValue_String(reader, "Salesman2Name", "");
                    obj.TaxName             = GetReaderValue_String(reader, "TaxName", "");
                    obj.InvoiceNumber       = GetReaderValue_NullableInt32(reader, "InvoiceNumber", null);
                    obj.InvoiceDate         = GetReaderValue_NullableDateTime(reader, "InvoiceDate", null);
                    obj.SalesOrderNo        = GetReaderValue_NullableInt32(reader, "SalesOrderNo", null);
                    obj.SalesOrderNumber    = GetReaderValue_NullableInt32(reader, "SalesOrderNumber", null);
                    obj.CustomerRMANumber   = GetReaderValue_NullableInt32(reader, "CustomerRMANumber", null);
                    obj.CustomerRMADate     = GetReaderValue_NullableDateTime(reader, "CustomerRMADate", null);
                    obj.ShipViaName         = GetReaderValue_String(reader, "ShipViaName", "");
                    obj.CreditValue         = GetReaderValue_NullableDouble(reader, "CreditValue", null);
                    obj.CreditCost          = GetReaderValue_NullableDouble(reader, "CreditCost", null);
                    obj.TaxRate             = GetReaderValue_NullableDouble(reader, "TaxRate", null);
                    obj.IncotermName        = GetReaderValue_String(reader, "IncotermName", "");
                    obj.CompanyTelephone    = GetReaderValue_String(reader, "CompanyTelephone", "");
                    obj.CompanyFax          = GetReaderValue_String(reader, "CompanyFax", "");
                    obj.ContactEmail        = GetReaderValue_String(reader, "ContactEmail", "");
                    obj.CreditNoteBankFee   = GetReaderValue_NullableDouble(reader, "CreditNoteBankFee", null);
                    obj.VATNO               = GetReaderValue_String(reader, "VATNo", "");

                    obj.ClientCreditNo      = GetReaderValue_Int32(reader, "ClientCreditNo", 0);
                    obj.RefNumber           = GetReaderValue_NullableInt32(reader, "RefNumber", null);
                    obj.isClientInvoice     = GetReaderValue_Boolean(reader, "IsClientInvoice", false);
                    obj.RefClientName       = GetReaderValue_String(reader, "ClientName", "");
                    obj.RefClientNo         = GetReaderValue_NullableInt32(reader, "RefClientNo", null);
                    obj.ClientInvoiceNo     = GetReaderValue_NullableInt32(reader, "ClientInvoiceNo", null);
                    obj.ClientInvoiceNumber = GetReaderValue_NullableInt32(reader, "ClientInvoiceNumber", null);


                    obj.ClientShipTo       = GetReaderValue_String(reader, "ClientShipTo", "");
                    obj.Telephone          = GetReaderValue_String(reader, "Telephone", "");
                    obj.Fax                = GetReaderValue_String(reader, "Fax", "");
                    obj.ClientCustomerCode = GetReaderValue_String(reader, "ClientCustomerCode", "");
                    obj.Email              = GetReaderValue_String(reader, "Email", "");
                    obj.VAT                = GetReaderValue_String(reader, "VAT", "");
                    obj.Tax                = GetReaderValue_String(reader, "Tax", "");
                    obj.ClientBillToAdr    = GetReaderValue_String(reader, "ClientBillToAdr", "");

                    obj.ExchangeRate       = GetReaderValue_NullableDouble(reader, "ExchangeRate", null);
                    obj.LocalCurrencyNo    = GetReaderValue_NullableInt32(reader, "LocalCurrencyNo", 0);
                    obj.ApplyLocalCurrency = GetReaderValue_NullableBoolean(reader, "ApplyLocalCurrency", false);
                    obj.LocalCurrencyCode  = GetReaderValue_String(reader, "LocalCurrencyCode", "");

                    return(obj);
                }
                else
                {
                    return(null);
                }
            }
            catch (SqlException sqlex)
            {
                //LogException(sqlex);
                throw new Exception("Failed to get Credit", sqlex);
            }
            finally
            {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }