How to selected date on caledar and write the line edit - qt

ı create the popup calendar on pushbutton. I selected date this calendar. and then ı write date to lineedit. how to make it. can you help me!
QMenu* pushMenu = new QMenu(pushButton);
QCalendarWidget* pushCalendar = new QCalendarWidget(pushMenu);
QWidgetAction* pushAction = new QWidgetAction(pushMenu);
pushAction->setDefaultWidget(pushCalendar);
pushMenu->addAction(pushAction);
pushButton->setMenu(pushMenu);

Related

X++ assign Enum Value to a table column

I am trying to pull the Enum chosen from a dialog and assign the label to a table's column.
For example: Dialog opens and allows you to choose from:
Surface
OutOfSpec
Other
These are 0,1,2 respectively.
The user chooses OutOfSpec (the label for this is Out Of Spec), I want to put this enum's Name, or the label, into a table. The column I'm inserting into is set to be a str.
Here's the code I've tried, without success:
SysDictEnum dictEnum = new SysDictEnum(enumNum(SDILF_ScrapReasons));
reason = dialog.addField(enumStr(SDILF_ScrapReasons),"Scrap Reason");
dialog.run();
if (!dialog.closedOk())
{
info(reason.value());
return;
}
ttsBegin;
// For now, this will strip off the order ID from the summary fields.
// No longer removing the Order ID
batchAttr = PdsBatchAttributes::find(itemId, invDim.inventBatchId, "OrderId");
orders = SDILF_BreakdownOrders::find(batchAttr.PdsBatchAttribValue, true);
if (orders)
{
orders.BoxProduced -= 1;
orders.update();
}
// Adding a batch attribute that will include the reason for scrapping
select forUpdate batchAttr;
batchAttr.PdsBatchAttribId = "ScrapReason";
//batchAttr.PdsBatchAttribValue = any2str(dictEnum.index2Value(reason.value()));
batchAttr.PdsBatchAttribValue = enum2str(reason.value());
batchAttr.InventBatchId = invDim.inventBatchId;
batchAttr.ItemId = itemId;
batchAttr.insert();
Obviously this is not the whole code, but it should be enough to give the issue that I'm trying to solve.
I'm sure there is a way to get the int value and use that to assign the label, I've just not been able to figure it out yet.
EDIT
To add some more information about what I am trying to accomplish. We make our finished goods, sometimes they are out of spec or damaged when this happens we then have to scrap that finished good. When we do this we want to keep track of why it is being scrapped, but we don't want just a bunch of random reasons. I used an enum to limit the reasons. When the operator clicks the button to scrap something they will get a dialog screen pop-up that allows them to select a reason for scrapping. The code will then, eventually, put that assigned reason on that finished items batch attributes so that we can track it later in a report and have a list of all the finished goods that were scrapped and why they were scrapped.
I'm not entirely sure of your question, but I think you're just missing one of the index2[...] calls or you're not getting the return value from your dialog correctly. Just create the below as a new job, run it, make a selection of Open Order and click ok.
I don't know the difference between index2Label and index2Name.
static void Job67(Args _args)
{
Dialog dialog = new dialog();
SysDictEnum dictEnum = new SysDictEnum(enumNum(SalesStatus));
DialogField reason;
SalesStatus salesStatusUserSelection;
str label, name, symbol;
int value;
reason = dialog.addField(enumStr(SalesStatus), "SalesStatus");
dialog.run();
if (dialog.closedOk())
{
salesStatusUserSelection = reason.value();
// Label
label = dictEnum.index2Label(salesStatusUserSelection);
// Name
name = dictEnum.index2Name(salesStatusUserSelection);
// Symbol
symbol = dictEnum.index2Symbol(salesStatusUserSelection);
// Value
value = dictEnum.index2Value(salesStatusUserSelection);
info(strFmt("Label: %1; Name: %2; Symbol: %3; Value: %4", label, name, symbol, value));
}
}

How to take data (item ID, item names, item price) from a file with FileChooser and list item ID in a combobox? How to match labels to selection?

I am trying to make point of sale terminal. I need to read read (item ID, item names, and item price) from a text file with FileChooser. Then the itemID should be listed in a comboBox. The comboBox selection should change labels and prices to the corresponding item name and item price. I believe this has to do with properties and binding but I don't understand how to use those.
I've tried creating an Items class, I tried reading the file into three arrays and then comparing the ID array item to the combobox selection and then switching the label text to the name array item with the same position.
stage.setTitle("Open Resource File");
FileChooser fileChooser = new FileChooser();
try {
FileReader reader = new
FileReader(fileChooser.showOpenDialog(stage));
Scanner scanner = new Scanner(reader);
for (int i = 0; i < 10; i++) {
itemID[i] = scanner.next();
itemName[i] = scanner.next();
itemPrice[i] = scanner.nextDouble();
}
scanner.close();
reader.close();
}
catch (Exception FileNotFoundException) {
}
Items item = new Items();
ComboBox idBox = new ComboBox();
idBox.setPromptText("Select an item");
idBox.getItems().addAll("A", "B", "C", "D", "E", "F", "G", "H", "I",
"J");
idBox.setOnAction(e -> {
item.setName(idBox.getValue().toString(), itemID, itemName);
item.setPrice(idBox.getValue().toString(), itemID, itemPrice);
nameLbl.setText(item.name.toString());
});
double quantity;
Label idLabel = new Label("Item ID: ");
Label nameLabel = new Label("Item Name: ");
Label nameLbl = new Label(item.name.toString());
Label priceLabel = new Label("Item Price: ");
Label priceLbl = new
Label(NumberFormat.getCurrencyInstance(newLocale("en",
"US")).format(item.price));
Label priceLbl = new Label("");
Program compiles and main window opens but shows error and crashes when
it tries to create the point of sales terminal window.
So there are a number of things you're going to want to look into, this isn't going to contain all the code, but it should be enough to get you going.
1) You're going to want to scan your Items into an ObservableList<Item> so that you have them in a single List to work with. At a bare minimum you can do something like this in your for:
String id = scanner.next();
String name = scanner.next();
String price = scanner.nextDouble();
items.add(new Item(id, name, price));
although you probably want to make the looping within the scanner a little more dynamic (instead of to 10) - possibly use a while loop or a different reader.
2) Now that you have your list of Items you want to use a ComboBox<Item> cbItems = new ComboBox<Item>() in order to display. You're going to have to set the cbItems.setCellFactory(...) and cbItems.setButtonFactory(...) in order to display the Id or the name in the drop down. The ObservableList you've added to can then be set to the cbItems.setItems(items) described in (1). There are a ton of SO articles on doing so, so I'll leave out the full code.
3) It's dealers choice on whether you want to use ObjectProperty<Item> or cbItems.selectedProperty() in order to bind to the text boxes that you're using. 'd suggest starting with the on change handler you're using now and setting the labels directly with item.getName() and once you've got that working move on to lblName.textProperty().bind(Bindings....).
With regards to the error, you haven't posted enough information (what the exception is, or the full code to replicate) so I can't help in that way. But if you research the items above, you should be closer.

How to add a row in gridview of Devexpress

I have a form where i have some text boxes and a Gridview(with Columns in it).the values entered in textboxes should be added as a row in gridview when pressing a ADD button..below is the code in the click event of ADD button..It add as a single column not as a row..Please help me with this.
BindingList<string> Grid_data = new BindingList<string>();
Grid_data.Add(txtMaterial.Text.ToString());
Grid_data.Add(txtPlastic.Text.ToString());
Grid_data.Add(txtCoatingtype.Text.ToString());
Grid_data.Add(txtManufacturer.Text.ToString());
Grid_data.Add(txtManuDate.Text.ToString());
Grid_data.Add(txtLineSize.Text.ToString());
Grid_data.Add(txtFootage.Text.ToString());
DGMaterial.DataSource = Grid_data;
GV_Material.PopulateColumns();
To begin with, when you write : Grid_data.Add(someString) it adds a new element to the binding list not to the row. You have to understand that each element of the BindingList represents a row, not a value for a cell.
What you should do is the following :
BindingList<List<string>> gridData = new BindingList<List<string>>();
gridData.add(new List<string>() {"someString", "anotherString"}); // Your inputs here
DGMaterial.DataSource = gridData ;
GV_Material.PopulateColumns();
Hope that helps !

How to compare current date with date from the picker

I have a datetimepicker which i used to get the date and set it as label in my screen. Now i want to check if the entered date is valid or not. i.e., the entered date should be bigger than or equal to the current date. Please tell with a code. Thank you
StringBuffer dateStrDate = new StringBuffer();
Calendar Cal = datePickerDate.getDateTime();
SimpleDateFormat dateFormat = new SimpleDateFormat("yy:mm:dd");
dateFormat.format(Cal, dateStrDate, null);
time.setText(dateStrDate.toString());
DateTimePicker datePicker = DateTimePicker.createInstance(Calendar.getInstance(), "yyyy-MM-dd", null);
if(datePicker.doModal()) {
Calendar cal = datePicker.getDateTime();
int month=cal.get(cal.MONTH);
int year=cal.get(cal.YEAR);
int date1=cal.get(cal.DATE);
}

ASP.NET add multiple series to chart via treeview selection

My page has a chart that is set up to display data that is coming from a SqlDataSource.
There is a TreeView which contains a list of datapoints that I want to be able to add to the chart as different series. The user selects which item they wish to add by clicking a checkbox in the treeview for that node and then clicks an update button to refresh the chart.
Each node's value is set to a column name in the table.
If there is only one point selected on the treeview the data comes across as a series on the chart with no problem when the update button is clicked.
If multiple items in the treeview are selected an ASP.NET error page appears when clicking the button stating that a column name 'XXXX' was not found where 'XXXX' is the node.Value of the highest item in the tree that was checked.
For example an error saying that "Column with name 'X1' was not found" would show up when using the following selection:
If just 'X1' is checked the data shows up on the chart.
public void UpdateChart(Object sender, EventArgs e)
{
if (TagTreeView.CheckedNodes.Count > 0)
{
foreach (TreeNode node in TagTreeView.CheckedNodes)
{
// Add a series to the chart
Series series = new Series();
series=Chart1.Series.Add("Series"+node.Value);
series.ChartArea = "ChartArea1";
series.ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), charts[1], true);
// create a datasource, add it to the page,
SqlDataSource sqlDataSource = new SqlDataSource();
sqlDataSource.ID = "SQLDataSource"+node.Value;
sqlDataSource.ConnectionString = ConfigurationManager.ConnectionStrings["HistoricalDataConnectionString"].ConnectionString;
if (node.Depth > 1)
{
if (node.Parent.Text.Contains("AAA"))
{
MessageBox.Show(node.Value);
sqlDataSource.SelectCommand = "SELECT (Date + CONVERT(datetime,Time)) As TimeStamp, " + node.Value + " FROM AAA ORDER BY TimeStamp";
}
this.Page.Controls.Add(sqlDataSource);
Chart1.DataSourceID = "SQLDataSource"+node.Value;
Chart1.Series["Series" + node.Value].XValueMember = "TimeStamp";
Chart1.Series["Series" + node.Value].YValueMembers = node.Value;
Chart1.DataBind();
}
}
}
}
Is there a way to take each selected item in the TreeView and use the node.value to build a query to add an additional series to the chart? I have done a little bit of work to see if putting the SqlDatasource and Series objects into an array and looping through that but it doesn't seem to be taking me anywhere.
To get this to work correctly all of the datapoints that will be added to the chart need to be included in the select statement for the sqlDataSource:
sqlDataSource.SelectCommand = "SELECT (Date + CONVERT(datetime,Time)) As TimeStamp, X1, X2, X3 FROM AAA ORDER BY TimeStamp";

Resources