My DevExpress.XtraEditors.LookUpEdit control is not working
I Fill the combo with this code:
void FillCombo()
{
cboStep.Properties.DataSource = ProceduresDALC.Fill_StepDetail(" Where StepID = "+_StepID);
cboStep.Properties.DisplayMember = "Description";
cboStep.Properties.ValueMember = "StepID";
cboStep.Properties.Columns.Clear();
cboStep.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Description", "Step Detail"));
}
The values are loaded into LookUpEdit
But when I choose a value from the LookUpEdit it gives me the first value only instead of my preferred value.
Just make sure that StepID is a primary key here. If it isnt a primary key then it will give you the first value on change index event
Your code works correctly to me with my datasource:
void FillLookUp() {
lookUpEdit1.Properties.DataSource = new List<StepDetails>{
new StepDetails(){ StepID = 0, Description = "Step1" },
new StepDetails(){ StepID = 1, Description = "Step2" },
new StepDetails(){ StepID = 2, Description = "Step3" },
};
lookUpEdit1.Properties.DisplayMember = "Description";
lookUpEdit1.Properties.ValueMember = "StepID";
lookUpEdit1.Properties.Columns.Clear();
lookUpEdit1.Properties.Columns.Add(new LookUpColumnInfo("Description", "Step Detail"));
}
It seems that some problems with retrieving data from your database cause this issue.
So, I suggest you contact the DevExpress Support for further research.
Related
My problem is that after creating an invoice, I can never get new line items to reference their corresponding sales order line item.
I have been generating invoices via SuiteTalk. When I initially create an invoice, I empty the lineItemList and add back in the items I need. I make sure the orderLine property matches the sales order line item line number. This works great.
But when I try and update the invoice with additional line items, I can never get the new items to retain their orderLine property. The orderLine property is used for the "Invoiced" column on the Sales Order.
In order to get the referencing to be correct, I need to delete the invoice and create it again with all of the line items I need.
Does anyone know if what I am trying to do is possible?
In this example, I use this CreateInvoice function to create the invoice from scratch and add it to NetSuite. Everything works as expected.
public void CreateInvoice(SalesOrder salesOrder) {
Invoice brandNewInvoice = new Invoice() {
createdFrom = new RecordRef() {
internalId = salesOrder.internalId,
},
entity = salesOrder.entity,
tranDate = endDate,
tranDateSpecified = true,
startDate = startDate,
startDateSpecified = true,
endDate = endDate,
endDateSpecified = true,
itemList = new InvoiceItemList(),
};
invoice.itemList.item = GetInvoiceItemList(salesOrder); //see the function shown further down
netSuiteService.add(brandNewInvoice);
}
In this example, the invoice is already created and so I get it from NetSuite and then replace the existing itemList with a new one. After the update, the invoice will now have NO orderLine property for any of the line items. The invoice also loses its "Created From" field because there are no line items with the orderLine property set.
public void UpdateInvoice(SalesOrder salesOrder, String invoiceInternalId) {
Invoice invoice = GetNetSuiteInvoice(invoiceInternalId);
invoice.itemList.item = GetInvoiceItemList(salesOrder); //see the function shown further down
netSuiteService.update(invoice);
}
this is the function used to create the itemList:
public InvoiceItem[] GetInvoiceItemList(SalesOrder salesOrder) {
InvoiceItem[] invoiceItemList = new InvoiceItem[salesOrder.itemList.item.Length];
for (int i = 0; i < salesOrder.itemList.item.Length; i++) {
SalesOrderItem soItem = salesOrder.itemList.item[i];
double quantity = 1;
invoiceItemList[i] = new InvoiceItem() {
item = new RecordRef() {
internalId = soItem.item.internalId,
name = soItem.item.name,
},
amount = quantity * Double.Parse(soItem.rate),
amountSpecified = true,
quantity = quantity,
quantitySpecified = true,
price = new RecordRef() {
internalId = soItem.price.internalId,
name = soItem.price.name,
},
rate = soItem.rate,
orderLine = soItem.line, //this will establish the link between the invoice and the sales order
orderLineSpecified = true,
taxRate1 = soItem.taxRate1,
taxRate1Specified = true,
};
}
return invoiceItemList;
}
Actually what you are looking for is the intialize operation. You need to use initialize in order for Netsuite to properly fill in the created from and orderline props. From the NS Help there is a C# example of creating a Cash Sale:
private void Initialize()
{
this.login(true);
InitializeRef ref1 = new InitializeRef();
ref1.type = InitializeRefType.salesOrder;
//internal id of the sales order to be converted to cash sale
ref1.internalId = "792";
ref1.typeSpecified = true;
InitializeRecord rec = new InitializeRecord();
rec.type = InitializeType.cashSale;
rec.reference = ref1;
ReadResponse read1 = _service.initialize(rec);
}
This is normal, when transforming a transaction to another transaction (e.g. SO to Inv, PO to IR). When you transform, most of the information from the source transaction will be carried over. Like what you are doing which is creating an Invoice from Sales Order(Base on your code below).
createdFrom = new RecordRef() {
internalId = salesOrder.internalId,
},
You don't need to get the line item information from the Sales Order and put it in the Invoice because it will be pre-populated once you create it form Sales Oder(unless you need to change a value of a line item column).
One behavior of a transformed record(Invoice in your case), if you remove a line item from the Invoice you will lose the link to the Sales order(orderLine) and if you remove all the line item you will totally lose the link between the two transactions (createdfrom). This is what you are experiencing. orderLine/createdFrom is a field populated by the system, it looks like you are populating it but you are not.
I'm trying to create the service/product type in the invoice line item. It returns an error saying bad request, is my ItemRef phrased correctly. My service/product is created in qbo already, its called Subscription Fee, it's the 3rd in the dropdown list.
line.AnyIntuitObject = new Intuit.Ipp.Data.SalesItemLineDetail()
{
ItemRef = new Intuit.Ipp.Data.ReferenceType()
{
Value = "3",
type = "Item",
name = "Subscription Fee"
},
ItemElementName = Intuit.Ipp.Data.ItemChoiceType.UnitPrice,
AnyIntuitObject = (decimal)item.Rate, // Line item rate
Qty = (decimal)item.Quantity,
QtySpecified = true,
ServiceDate = DateTime.Now.Date,
ServiceDateSpecified = true,
TaxCodeRef = new Intuit.Ipp.Data.ReferenceType()
{
Value = taxCode0ZR.Id,
type = Enum.GetName(typeof(Intuit.Ipp.Data.objectNameEnumType), Intuit.Ipp.Data.objectNameEnumType.TaxRate),
name = taxCode0ZR.Name
},
};
What am i creating wrongly please help.
You cannot create an Item within an invoice or rather any entity within an entity.
QBO v3 does not supports creating entities on the fly.
You first need to do a create Item.
Get the Id of that Item and refer it in your Invoice.
Also, enable request/response log to get the details of the errors in log files-
https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0150_ipp_.net_devkit_3.0/0002_configuration/override_configuration
I have set of records in a database table lets call it Components Table which is defined as follows.
The administrator can disable some of the components using disableflag which is the last column of the table. If a particular component is disabled it should not appear in the gridview of the user.
I'm getting the data from the database and presenting through the gridview as shown here, if you observe the SNo values are not in order.
The linq query that i'm using to retrieve the data is:
var gridViewResults = from results in db.Components where results.DisableFlag == false
select new { SNo = results.SNo, ComponentNames = results.Component_Name, Size = results.Size__in_MB_, Price = results.Price__in_SEK_, TotalDownloads = results.Total_Downloads, Description = results.Description };
But I want the data to be shown in order meaning with SNo to be 1, 2, 3, 4 with out dependency on the database table SNO values: for reference look at this.
I'm not able to figure out how to use the linq query to achieve this:
I have tried this query:
(db.Components.AsEnumerable().Select((iterator)=> new{iterator.SNo + 1})
But i think it is absurd. Can some one help me out on this.
Thanks in anticipation.
If you're absoutely certain you want to ignore the database numbers (why output the numbers if they don't actually correspond to anything?) you may be able to try the following:
var gridViewData = from results in db.Components
where results.DisableFlag == false
select new
{
ComponentNames = results.Component_Name,
Size = results.Size__in_MB_,
Price = results.Price__in_SEK_,
TotalDownloads = results.Total_Downloads,
Description = results.Description
};
var gridViewResults = gridViewData.AsEnumerable().Select((item, index) => new
{
SNo = index + 1,
ComponentNames = item.ComponentNames,
Size = item.Size,
Price = item.Price,
TotalDownloads = item.TotalDownloads,
Description = item.Description
});
EDIT: Alternate solution from How To Project a Line Number Into Linq Query Results
EDIT2: Fix for unsupported select by SQL: Linq error - "NotSupportedException: Unsupported overload used for query operator 'Select'"
Hi everyone here is the final answer. Joshua did all of the work. A big thanks to him. Just want to highlight the answer to anyone with the same problem for the future. If any one want to vote up please vote for Joshua
var gridViewData = from results in db.Components
where results.DisableFlag == false
select new
{
ComponentNames = results.Component_Name,
Size = results.Size__in_MB_,
Price = results.Price__in_SEK_,
TotalDownloads = results.Total_Downloads,
Description = results.Description
};
var gridViewResults = gridViewData.AsEnumerable().Select((item, index) => new
{
SNo = index + 1,
ComponentNames = item.ComponentNames,
Size = item.Size,
Price = item.Price,
TotalDownloads = item.TotalDownloads,
Description = item.Description
}).ToList();
This should work.
This code cause double record...
i checked my insert code for all tables and it works fine...
and this is insert code:
StoreDO store = new StoreDO();
List<BrandDO> brandList = new BrandBL().SelectBrands();
StoreBL storeBL = new StoreBL();
store.StoreName = txtStoreName.Text;
store.StorePhone = txtStorePhone.Text;
store.StoreAddress = txtStoreAddress.Text;
store.CityID = int.Parse(ddlCity.SelectedValue);
store.CountyID = int.Parse(ddlCounty.SelectedValue);
store.IsActive = chkIsActive.Checked;
int storeID = storeBL.InsertStore(store);
ContentPlaceHolder contentPlaceHolder = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
for (int i = 0; i < brandList.Count; i++) {
string brandName = brandList[i].BrandName.ToString() + brandList[i].BrandID.ToString();
StoreBrandBL storeBrandBL = new StoreBrandBL();
CheckBox chkBrand = (CheckBox)contentPlaceHolder.FindControl(brandName);
if (chkBrand != null) {
if (chkBrand.Checked) {
StoreBrandDO storeBrandDO = new StoreBrandDO();
storeBrandDO.StoreID = storeID;
storeBrandDO.BrandID = brandList[i].BrandID;
storeBrandDO.IsActive = true;
storeBrandBL.InsertStoreBrand(storeBrandDO);
}
}
}
Duplicating rows in your database should be avoided in the code and protected against in the database.
As hwcverwe said you can use table constraints but you should also try to set the primary key correctly for each table.
If you are using surrogate keys on all tables (such as the StoreID and BrandID I see in your code) then you will have to use unique table constraints to prevent duplicate data. Configuring your database correctly will also show up the problem areas in your code as the database will throw an exception when an insert fails.
EDIT: In response to your comment your question title is incorrect if you are asking about CheckBox controls.
Looking at the code it appears you are trying to find a checkbox control in a ContentPlaceholder but you do not show the code which creates the checkboxes.
LINQ to SQL - When inserting a row (and several other rows with FKs that will point to the PK on this row), is it sufficient to execute [context].[MainTable].InsertOnSubmit(row), or do I need to call it for the other rows as well?
Here's a condensed code sample (C#):
//Forgive the contrived example (off the top of my head) :)
//Main row
Order order = new Order
{
itemId = (int) data["itemNumber"],
address = (string) data["address"]
};
db.Orders.InsertOnSubmit(order); //would be nice to only have to submit here.
//Related rows
OrderPerson orderPerson = new OrderPerson
{
Order = order,
//other things, etc.
orderRoleId = RoleIds.Customer
};
//Q: need to do "db.OrderPerson.InsertOnSubmit(orderPerson);" here?
OrderHistoryEntry historyEntry = new OrderHistoryEntry
{
Order = order,
//other things, etc.
historyTypeId = HistoryIds.Ordered
};
//Q: need to do "db.OrderHistoryEntry.InsertOnSubmit(historyEntry);" here?
db.SubmitChanges();
Is it sufficient to do: db.Orders.InsertOnSubmit(order); or do I need to also execute InsertOnSubmit for the related rows (orderPerson and historyEntry)?
It would be nice to only run it once on the main row. The MSDN examples do just that, but they all have the relationships reversed (referencing the other rows from main row).
I appreciate your thoughts.
How about this instead?
Order order = new Order
{
itemId = (int) data["itemNumber"],
address = (string) data["address"]
};
OrderPerson orderPerson = new OrderPerson
{
orderRoleId = RoleIds.Customer
};
order.OrderPersons.Add(orderPerson);
OrderHistoryEntry historyEntry = new OrderHistoryEntry
{
historyTypeId = HistoryIds.Ordered
};
order.OrderHistoryEntries.Add(historyEntry);
db.Orders.InsertOnSubmit(order);
db.SubmitChanges();