private static CreditLine PopulateFromDBDetailsObject(CreditLineDetails obj) { CreditLine objNew = new CreditLine(); objNew.CreditLineId = obj.CreditLineId; objNew.FullPart = obj.FullPart; objNew.Part = obj.Part; objNew.ManufacturerNo = obj.ManufacturerNo; objNew.DateCode = obj.DateCode; objNew.PackageNo = obj.PackageNo; objNew.ProductNo = obj.ProductNo; objNew.CreditNo = obj.CreditNo; objNew.Quantity = obj.Quantity; objNew.Price = obj.Price; objNew.Taxable = obj.Taxable; objNew.CustomerPart = obj.CustomerPart; objNew.LandedCost = obj.LandedCost; objNew.InvoiceLineNo = obj.InvoiceLineNo; objNew.CustomerRMALineNo = obj.CustomerRMALineNo; objNew.ROHS = obj.ROHS; objNew.UpdatedBy = obj.UpdatedBy; objNew.DLUP = obj.DLUP; objNew.StockNo = obj.StockNo; objNew.ServiceNo = obj.ServiceNo; objNew.Notes = obj.Notes; objNew.FullCustomerPart = obj.FullCustomerPart; objNew.CreditId = obj.CreditId; objNew.CreditNumber = obj.CreditNumber; objNew.CreditDate = obj.CreditDate; objNew.CompanyName = obj.CompanyName; objNew.CompanyNo = obj.CompanyNo; objNew.CustomerRMANumber = obj.CustomerRMANumber; objNew.CustomerRMANo = obj.CustomerRMANo; objNew.CustomerPO = obj.CustomerPO; objNew.InvoiceNumber = obj.InvoiceNumber; objNew.InvoiceNo = obj.InvoiceNo; objNew.ContactName = obj.ContactName; objNew.ContactNo = obj.ContactNo; objNew.ManufacturerCode = obj.ManufacturerCode; objNew.RowNum = obj.RowNum; objNew.RowCnt = obj.RowCnt; objNew.LineNotes = obj.LineNotes; objNew.ManufacturerName = obj.ManufacturerName; objNew.PackageName = obj.PackageName; objNew.PackageDescription = obj.PackageDescription; objNew.ProductName = obj.ProductName; objNew.ProductDescription = obj.ProductDescription; objNew.CurrencyNo = obj.CurrencyNo; objNew.CurrencyCode = obj.CurrencyCode; objNew.RaiserName = obj.RaiserName; objNew.SalesmanName = obj.SalesmanName; objNew.TeamNo = obj.TeamNo; objNew.DivisionName = obj.DivisionName; objNew.ReferenceDate = obj.ReferenceDate; return(objNew); }
/// <summary> /// DataListNugget /// Calls [usp_datalistnugget_CreditLine] /// </summary> public override List <CreditLineDetails> DataListNugget(System.Int32?clientId, System.Int32?teamId, System.Int32?divisionId, System.Int32?loginId, System.Int32?orderBy, System.Int32?sortDir, System.Int32?pageIndex, System.Int32?pageSize, System.String partSearch, System.String contactSearch, System.String cmSearch, System.Int32?salesmanSearch, System.String creditNotesSearch, System.String customerPoSearch, System.Int32?creditNoLo, System.Int32?creditNoHi, System.Int32?invoiceNoLo, System.Int32?invoiceNoHi, System.Int32?customerRmaNoLo, System.Int32?customerRmaNoHi, System.DateTime?creditDateFrom, System.DateTime?creditDateTo, System.Boolean?PohubOnly, System.Int32?ClientInvoiceNoLo, System.Int32?ClientInvoiceNoHi, System.Boolean?blnHubCredit) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand((blnHubCredit.Value) ? "usp_datalistnugget_HubCreditLine" : "usp_datalistnugget_CreditLine", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 60; cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value = clientId; cmd.Parameters.Add("@TeamId", SqlDbType.Int).Value = teamId; cmd.Parameters.Add("@DivisionId", SqlDbType.Int).Value = divisionId; cmd.Parameters.Add("@LoginId", SqlDbType.Int).Value = loginId; cmd.Parameters.Add("@OrderBy", SqlDbType.Int).Value = orderBy; cmd.Parameters.Add("@SortDir", SqlDbType.Int).Value = sortDir; cmd.Parameters.Add("@PageIndex", SqlDbType.Int).Value = pageIndex; cmd.Parameters.Add("@PageSize", SqlDbType.Int).Value = pageSize; cmd.Parameters.Add("@PartSearch", SqlDbType.NVarChar).Value = partSearch; cmd.Parameters.Add("@ContactSearch", SqlDbType.NVarChar).Value = contactSearch; cmd.Parameters.Add("@CMSearch", SqlDbType.NVarChar).Value = cmSearch; cmd.Parameters.Add("@SalesmanSearch", SqlDbType.Int).Value = salesmanSearch; cmd.Parameters.Add("@CreditNotesSearch", SqlDbType.NVarChar).Value = creditNotesSearch; cmd.Parameters.Add("@CustomerPOSearch", SqlDbType.NVarChar).Value = customerPoSearch; cmd.Parameters.Add("@CreditNoLo", SqlDbType.Int).Value = creditNoLo; cmd.Parameters.Add("@CreditNoHi", SqlDbType.Int).Value = creditNoHi; cmd.Parameters.Add("@InvoiceNoLo", SqlDbType.Int).Value = invoiceNoLo; cmd.Parameters.Add("@InvoiceNoHi", SqlDbType.Int).Value = invoiceNoHi; cmd.Parameters.Add("@CustomerRMANoLo", SqlDbType.Int).Value = customerRmaNoLo; cmd.Parameters.Add("@CustomerRMANoHi", SqlDbType.Int).Value = customerRmaNoHi; cmd.Parameters.Add("@CreditDateFrom", SqlDbType.DateTime).Value = creditDateFrom; cmd.Parameters.Add("@CreditDateTo", SqlDbType.DateTime).Value = creditDateTo; cmd.Parameters.Add("@PoHubOnly", SqlDbType.Bit).Value = PohubOnly; //[001] Start Here cmd.Parameters.Add("@ClientInvoiceNoLo", SqlDbType.Int).Value = ClientInvoiceNoLo; cmd.Parameters.Add("@ClientInvoiceNoHi", SqlDbType.Int).Value = ClientInvoiceNoHi; //[001] End Here cn.Open(); DbDataReader reader = ExecuteReader(cmd); List <CreditLineDetails> lst = new List <CreditLineDetails>(); while (reader.Read()) { CreditLineDetails obj = new CreditLineDetails(); obj.Part = GetReaderValue_String(reader, "Part", ""); obj.ManufacturerNo = GetReaderValue_NullableInt32(reader, "ManufacturerNo", null); obj.ROHS = GetReaderValue_Byte(reader, "ROHS", (byte)0); obj.CreditId = GetReaderValue_Int32(reader, "CreditId", 0); obj.CreditNumber = GetReaderValue_Int32(reader, "CreditNumber", 0); obj.CreditDate = GetReaderValue_DateTime(reader, "CreditDate", DateTime.MinValue); obj.CompanyName = GetReaderValue_String(reader, "CompanyName", ""); obj.CompanyNo = GetReaderValue_Int32(reader, "CompanyNo", 0); obj.CustomerRMANumber = GetReaderValue_Int32(reader, "CustomerRMANumber", 0); obj.CustomerRMANo = GetReaderValue_NullableInt32(reader, "CustomerRMANo", null); obj.CustomerPO = GetReaderValue_String(reader, "CustomerPO", ""); obj.InvoiceNumber = GetReaderValue_Int32(reader, "InvoiceNumber", 0); obj.InvoiceNo = GetReaderValue_NullableInt32(reader, "InvoiceNo", null); obj.ContactName = GetReaderValue_String(reader, "ContactName", ""); obj.ContactNo = GetReaderValue_Int32(reader, "ContactNo", 0); obj.ManufacturerCode = GetReaderValue_String(reader, "ManufacturerCode", ""); obj.RowCnt = GetReaderValue_NullableInt32(reader, "RowCnt", null); obj.ClientInvoiceNumber = GetReaderValue_NullableInt32(reader, "ClientInvoiceNumber", null); obj.ClientInvoiceNo = GetReaderValue_NullableInt32(reader, "ClientInvoiceId", null); lst.Add(obj); obj = null; } return(lst); } catch (SqlException sqlex) { //LogException(sqlex); throw new Exception("Failed to get CreditLines", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }
/// <summary> /// GetListForCredit /// Calls [usp_selectAll_CreditLine_for_Credit] /// </summary> public override List <CreditLineDetails> GetListForCredit(System.Int32?creditId) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_selectAll_CreditLine_for_Credit", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cmd.Parameters.Add("@CreditId", SqlDbType.Int).Value = creditId; cn.Open(); DbDataReader reader = ExecuteReader(cmd); List <CreditLineDetails> lst = new List <CreditLineDetails>(); while (reader.Read()) { CreditLineDetails obj = new CreditLineDetails(); obj.CreditLineId = GetReaderValue_Int32(reader, "CreditLineId", 0); obj.FullPart = GetReaderValue_String(reader, "FullPart", ""); obj.Part = GetReaderValue_String(reader, "Part", ""); obj.ManufacturerNo = GetReaderValue_NullableInt32(reader, "ManufacturerNo", null); obj.DateCode = GetReaderValue_String(reader, "DateCode", ""); obj.PackageNo = GetReaderValue_NullableInt32(reader, "PackageNo", null); obj.ProductNo = GetReaderValue_NullableInt32(reader, "ProductNo", null); obj.CreditNo = GetReaderValue_Int32(reader, "CreditNo", 0); obj.Quantity = GetReaderValue_Int32(reader, "Quantity", 0); obj.Price = GetReaderValue_Double(reader, "Price", 0); obj.Taxable = GetReaderValue_Boolean(reader, "Taxable", false); obj.CustomerPart = GetReaderValue_String(reader, "CustomerPart", ""); obj.LandedCost = GetReaderValue_NullableDouble(reader, "LandedCost", null); obj.InvoiceLineNo = GetReaderValue_NullableInt32(reader, "InvoiceLineNo", null); obj.CustomerRMALineNo = GetReaderValue_NullableInt32(reader, "CustomerRMALineNo", null); //[002] start obj.ROHS = GetReaderValue_NullableByte(reader, "ROHS", null); //[002] end obj.UpdatedBy = GetReaderValue_NullableInt32(reader, "UpdatedBy", null); obj.DLUP = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue); obj.StockNo = GetReaderValue_NullableInt32(reader, "StockNo", null); obj.ServiceNo = GetReaderValue_NullableInt32(reader, "ServiceNo", null); obj.CreditDate = GetReaderValue_DateTime(reader, "CreditDate", DateTime.MinValue); obj.CompanyName = GetReaderValue_String(reader, "CompanyName", ""); obj.CustomerRMANumber = GetReaderValue_Int32(reader, "CustomerRMANumber", 0); obj.InvoiceNumber = GetReaderValue_Int32(reader, "InvoiceNumber", 0); obj.ContactName = GetReaderValue_String(reader, "ContactName", ""); obj.ManufacturerCode = GetReaderValue_String(reader, "ManufacturerCode", ""); obj.LineNotes = GetReaderValue_String(reader, "LineNotes", ""); obj.ManufacturerName = GetReaderValue_String(reader, "ManufacturerName", ""); obj.PackageName = GetReaderValue_String(reader, "PackageName", ""); obj.PackageDescription = GetReaderValue_String(reader, "PackageDescription", ""); obj.ProductName = GetReaderValue_String(reader, "ProductName", ""); obj.ProductDescription = GetReaderValue_String(reader, "ProductDescription", ""); obj.CurrencyNo = GetReaderValue_Int32(reader, "CurrencyNo", 0); obj.CurrencyCode = GetReaderValue_String(reader, "CurrencyCode", ""); 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.ReferenceDate = GetReaderValue_DateTime(reader, "ReferenceDate", DateTime.MinValue); obj.Ipo = GetReaderValue_Int32(reader, "ipo", 0); obj.ParentCreditLineNo = GetReaderValue_Int32(reader, "ParentCreditLineNo", 0); obj.ClientInvoiceLineId = GetReaderValue_Int32(reader, "ClientInvoiceLineId", 0); obj.ParentCreditLineId = GetReaderValue_Int32(reader, "ParentCreditLineId", 0); obj.DutyCode = GetReaderValue_String(reader, "ProductDutyCode", ""); lst.Add(obj); obj = null; } return(lst); } catch (SqlException sqlex) { //LogException(sqlex); throw new Exception("Failed to get CreditLines", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }