how to enable drag and drop tables from EDM datasource? - winforms

I created a c# winform project. I added Entity Data Model. I set the data model property "code generation" to default. The list of tables showed up in the datasource window, but when I try to drag and drop a table on the designer window of the form, it does not work.
I'm frustrated. I do not know what I'm missing. Please help!!!

I was able to figure it out. here...
The only thing that was missing from was I was doing is that I needed to go the Datasource window, then right click to select to add new datasource, then from this window select
object. Then you select the newly added EDM. After that you should be able to drag and drop table objects to your form. Make sure that the data model property "code generation strategy" is set to default.

Related

Databound textbox updates do not persist to db

I have a winforms app with a group of text boxes for an entity, let's call the entity Product
One of my textboxes is hidden because it holds a foreign key to another database object Business Unit. I populate the hidden textbox using a combobox that looks up values on the parent table. When the selection changes, so does the value in the hidden textbox.
private void businessUnitComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{
this.businessUnitIdTextBox.Text = this.businessUnitComboBox.SelectedValue.ToString();
this.businessUnitComboBox.Focus();
}
Problem is after calling SaveChanges on my context, this change on the hidden textbox is not persisted. Oddly, if I update any of the other Product textboxes, they save just fine.
The textboxes were added to the project with standard drag and drag drop from Visual Studio's GUI, and a bindingsource was created when adding automatically.
My entities implement INotifyPropertyChanged using fody-propertychanged.
I am struggling to find the issue here. Creating new records works fine, but updating that one Foreign Key value never has.
Is this because it is a navigation property and needs to be handled differently, or are there other possibilities as to why the changes are not persisted? Any help is much appreciated.
May be it is because of lacking of this.Validate() in your Save method.
Put this code in save method of your form.
this.Validate();
this.yourBindingSource.EndEdit();
yourDbContext.SaveChanges();
The default behavior of data binding is OnValidation.
To change this behavior you can go to your textbox properties, open databinding part, open advanced, Change Data Source Update Mode to OnPropertyChanged.
So the code of your databinding in designer generated codes will be like this:
this.nameTextBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.productBindingSource, "Category.Name", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
In this case you don't need to use this.Validate before saving changes and you can simply use
this.yourBindingSource.EndEdit();
yourDbContext.SaveChanges();

telerik radscheduler view in wpf

I am using a telerik RadScheduleView control to display employee records
I have also added custom column names Employee name,start date,end date.
Please help me on how to fetch data from the database and display it on the RadScheduleView control.
I am new to Telerik control.
In order to display Employees in the RadScheduleView you need to bind the AppointmentSource to a model representation (Employee) of the data from your database. Your model representation must implement IAppointment:
I suppose you only require the End (Employee.EndDate), Start (Employee.StartDate) and Subject (Employee.Name) members for now.
That is as far as I can help you start off. More information on Telerik RadScheduleView database binding can be found in the following articles:
Overview
RadScheduleView Types and Sources
Table Definitions and Relationships
List item
Models
View and ViewModel
They even have a sample project for you: http://www.telerik.com/support/code-library/binding-to-database-example

Can I drop files on a DataGrid?

I have a datgrid that has the information of files. The name, type of file, size... etc.
I would like to do the following:
1.- select some files, one or more in the file explorer in windows.
2.- drop the files into the datagrid.
3.- With the path of the files, I can convert this information in the type of items of the dataGrid, so I can create an object myFile, set the properties with the info and add the object to the collection that the dataGrid use as ItemsSource.
4.- One with of all the information in the dataGrid, I use my repositury to save the new items in the dataGrid in the database.
My question is if I can drop files in a datagrid, and if it is possible, hoe can I know the path of the files.
I have look at the e argument of the drop event but I don't see what information I receive in the event.
Thanks.
Daimroc.
You can try this soulution.........................

DevExpress column a multi select field

I'm trying to create a drop down / combo box in dev express with check boxes, to allow the user to select multiple options.
Something like this:
I've found some documentation but nothing that tells me what to do. Can anyone help?
Use checkedComboBoxEdit control and use it's drop down list as you want..
Refer - CheckedComboBoxEdit - add AllowMultiSelect property devexpress thread and attached example..
you can easily implement the required logic manually using a piece of code. Simply handle the SelectedIndexChanged event and check the selected items.
Hope this help...

Windows Forms checkboxes with LINQ

I am using checkedListBox with windows forms . I am using LINQ for database operations.
Now when user edits the form I need to see if checkboxes are new selected and if entry does not exist insert to the table.If they had checked it before and now they checked it off I need to delete that entry from database. Can some one help me how can I do this in LINQ some easy way ? In sort I need to Insert any newly selected checkboxes and delete if they existed before but are not checked off.
Thanks a lot.
You can easily get the checked and unchecked items, but to determine if they are originally checked/unchecked, you have to store that somewhere, whether the tag property or in a variable somewhere.
HTH.

Resources