c# - How to bind DataGridView with two tables, and perform CRUD operation in WPF -
here table structures:
first table:
create table [dbo].[tbltoolmodification_pramary] ( [id] [int] identity(1,1) not null, [reportno] [varchar](50) not null, [toolmodificationdate] [varchar](50) null, [productcode] [varchar](50) null, [productiondescription] [varchar](50) null, [drawingno] [varchar](50) null, [dieno] [varchar](50) null, [noofcavity] [varchar](50) null, [diemakercode] [varchar](50) null, [diemakername] [varchar](50) null, constraint [pk_tbltoolmodification_pramary] primary key clustered ([reportno] asc) (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [primary] ) on [primary] create table [dbo].[tbltoolmodification_foreign] ( [id] [int] identity(1,1) not null, [reportno] [varchar](50) not null, [srlno] [varchar](50) null, [drawingdimension] [varchar](50) null, [requireddimension] [varchar](50) null, [actualindie] [varchar](50) null, [actioninneeded] [varchar](50) null, [resultmodification] [varchar](50) null, constraint [pk_tbltoolmodification_foriegn] primary key clustered ([id] asc) (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [primary] ) on [primary]
here design:
<window x:class="demo.foundry.sample.tool_modification_view" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell" xmlns:col="clr-namespace:system.collections;assembly=mscorlib" icon="/img\f_logo.png" windowstyle="none" showintaskbar="false" title="tool modification view" resizemode="noresize" height="692" width="1591.9" background="#d9f9f7" loaded="window_loaded"> <grid margin="0,0,0,-45"> <label content="tool modification view" verticalalignment="top" height="25" horizontalcontentalignment="center" background="{dynamicresource {x:static systemcolors.activecaptionbrushkey}}" /> <grid margin="10,30,4,29"> <rectangle horizontalalignment="left" fill="darkgreen" height="50" margin="61,0,0,0" stroke="black" verticalalignment="top" width="1163" /> <label content="tool modification view" foreground="white" fontweight="bold" horizontalalignment="left" margin="575,11,0,0" verticalalignment="top" width="155" rendertransformorigin="0.03,0.423" height="27" /> <datagrid name="dgdie_outward_dc" horizontalalignment="left" margin="61,50,0,0" verticalalignment="top" itemssource="{binding}" autogeneratecolumns="false" width="1163" height="310" alternatingrowbackground="{dynamicresource {x:static systemcolors.activecaptionbrushkey}}"> <datagrid.columns> <datagridtextcolumn binding="{binding reportno, notifyonsourceupdated=true, mode=twoway,updatesourcetrigger=propertychanged}" width="80" header="report no" isreadonly="true" /> <datagridtextcolumn binding="{binding toolmodificationdate, notifyonsourceupdated=true, mode=twoway,updatesourcetrigger=propertychanged}" width="80" header="date" /> <datagridtextcolumn binding="{binding srlno, notifyonsourceupdated=true, mode=twoway,updatesourcetrigger=propertychanged}" width="50" header="sr.no" /> <datagridtextcolumn binding="{binding productcode, notifyonsourceupdated=true, mode=twoway,updatesourcetrigger=propertychanged}" width="80" header="product" /> <datagridtextcolumn binding="{binding productiondescription, notifyonsourceupdated=true, mode=twoway,updatesourcetrigger=propertychanged}" width="150" header="description" /> <datagridtextcolumn binding="{binding drawingno, notifyonsourceupdated=true, mode=twoway,updatesourcetrigger=propertychanged}" width="100" header="drawing" /> <datagridtextcolumn binding="{binding dieno, notifyonsourceupdated=true, mode=twoway,updatesourcetrigger=propertychanged}" width="55" header="die no." /> <datagridtextcolumn binding="{binding noofcavity, notifyonsourceupdated=true, mode=twoway,updatesourcetrigger=propertychanged}" width="55" header="cavity" /> <datagridtextcolumn binding="{binding diemakername, notifyonsourceupdated=true, mode=twoway,updatesourcetrigger=propertychanged}" width="100" header="vendor name" /> <datagridtextcolumn binding="{binding drawingdimension, notifyonsourceupdated=true, mode=twoway,updatesourcetrigger=propertychanged}" width="150" header="drawing dimension" /> <datagridtextcolumn binding="{binding requireddimension, notifyonsourceupdated=true, mode=twoway,updatesourcetrigger=propertychanged}" width="150" header="required dimension" /> <datagridtextcolumn binding="{binding actualindie, notifyonsourceupdated=true, mode=twoway,updatesourcetrigger=propertychanged}" width="150" header="actual in die" /> <datagridtextcolumn binding="{binding actioninneeded, notifyonsourceupdated=true, mode=twoway,updatesourcetrigger=propertychanged}" width="150" header="action needed" /> <datagridtextcolumn binding="{binding resultmodification, notifyonsourceupdated=true, mode=twoway,updatesourcetrigger=propertychanged}" width="200" header="result after modification" /> </datagrid.columns> </datagrid> <rectangle horizontalalignment="left" fill="beige" height="50" margin="62,356,0,0" stroke="black" verticalalignment="top" width="1163" /> <label content="report no." horizontalalignment="left" margin="62,365,0,0" verticalalignment="top" rendertransformorigin="1.639,0.468" width="65" /> <combobox tabindex="6" horizontalalignment="left" margin="127,365,0,0" verticalalignment="top" width="150" height="28" rendertransformorigin="0.474,1.094" /> <label content="product" horizontalalignment="left" margin="277,365,0,0" verticalalignment="top" rendertransformorigin="1.639,0.468" width="65" /> <combobox tabindex="6" horizontalalignment="left" margin="331,365,0,0" verticalalignment="top" width="150" height="28" rendertransformorigin="0.474,1.094" /> <label content="drawing" horizontalalignment="left" margin="495,365,0,0" verticalalignment="top" rendertransformorigin="1.639,0.468" width="65" /> <combobox tabindex="6" horizontalalignment="left" margin="550,366,0,0" verticalalignment="top" width="150" height="28" rendertransformorigin="0.474,1.094" /> <button name="btnexit" content="exit" horizontalalignment="left" margin="843,360,0,0" verticalalignment="top" width="231" click="btnexit_click" /> </grid> </grid> </window>
i want crud operation in datagridview
- how implement that? please help..
all operation should perform within datagridview delete operation perform when click keyboard delete button . edit , insert operation perform within datagridview column
you wont able bind 2 tables @ once. need either rethink database design or need bring 2 tables in single query, possibly using union.
Comments
Post a Comment