一。删除
1.
(usrListVIEw.Selectedindex != - currentSelectIndex = item = (StockManageDataContext smDataContext =2.
MenuItemDelete_Click( </span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #0000ff;">if</span> (Address<a href="https://m.jb51.cc/tag/List/" target="_blank" >List</a>.Selecte<a href="https://www.jb51.cc/tag/dind/" target="_blank" >dind</a>ex == -<span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800080;">1</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;">) { Message<a href="https://www.jb51.cc/tag/Box/" target="_blank" >Box</a>.Show(</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">"</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">请<a href="https://m.jb51.cc/tag/xuanze/" target="_blank" >选择</a>一项!</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">"</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;">); </span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #0000ff;">return</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;">; } </span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #0000ff;">if</span> (Message<a href="https://www.jb51.cc/tag/Box/" target="_blank" >Box</a>.Show(<span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">"</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">确认<a href="https://www.jb51.cc/tag/shanchu/" target="_blank" >删除</a>所选定的供应商信息?</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">"</span>,<span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">"</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;"><a href="https://www.jb51.cc/tag/tishi/" target="_blank" >提示</a></span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">"</span>,Message<a href="https://www.jb51.cc/tag/Box/" target="_blank" >Box</a><a href="https://m.jb51.cc/tag/button/" target="_blank" >button</a>.OKCancel) ==<span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;"> Message<a href="https://www.jb51.cc/tag/Box/" target="_blank" >Box</a>Res<a href="https://m.jb51.cc/tag/ul/" target="_blank" >ul</a>t.OK) { </span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #0000ff;">while</span> (Address<a href="https://m.jb51.cc/tag/List/" target="_blank" >List</a>.Selecte<a href="https://www.jb51.cc/tag/dind/" target="_blank" >dind</a>ex != -<span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800080;">1</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;">){ </span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #0000ff;">var</span> currentSelectIndex =<span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;"> Address<a href="https://m.jb51.cc/tag/List/" target="_blank" >List</a>.Selecte<a href="https://www.jb51.cc/tag/dind/" target="_blank" >dind</a>ex; SHDZ selectedAddress </span>=<span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;"> (SHDZ)Address<a href="https://m.jb51.cc/tag/List/" target="_blank" >List</a>.SelectedValue; </span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #0000ff;">using</span> (WJK<a href="https://m.jb51.cc/tag/cda/" target="_blank" >cda</a>taContext wjkc = <span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #0000ff;">new</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;"> WJK<a href="https://m.jb51.cc/tag/cda/" target="_blank" >cda</a>taContext()) { </span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #0000ff;">try</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;"> { wjkc.ExecuteCommand(</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">"</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">DELETE FROM SHDZ WHERE CODE={0}</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">"</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;">,selectedAddress.CODE); addressV<a href="https://m.jb51.cc/tag/IE/" target="_blank" >IE</a>w.RemoveAt(currentSelectIndex); } </span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #0000ff;">catch</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;"> (Exception ex) { Message<a href="https://www.jb51.cc/tag/Box/" target="_blank" >Box</a>.Show(ex.Message); } } </span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #0000ff;">return</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;">; } } } }</span></pre>
3.
item = smDataContext.suppliers.SingleOrDefault(c => c.ID == ( (item != +
二。插入
1.
(StockManageDataContext smDataContext = User { Username = usrname.Text,Password = pwd,Permission == = = = = = = = =2.
= = SolIDcolorBrush(color.Fromrgb(,,三 编辑
1.
确保 编辑的对象是所选对象,所以传入参数要注意,并且编辑时要先填充控件。
wjkc.ExecuteCommand(</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">"</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">update SHDZ set DETAIL={0},DZ={1},ISTY={2} where CODE={3};</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">"</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;">,address.ISTY,address.CODE); lblMsg.Content </span>= <span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">"</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">信息<a href="https://www.jb51.cc/tag/xiugai/" target="_blank" >修改</a>成功!</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800000;">"</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;">; lblMsg.Foreground </span>= <span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #0000ff;">new</span> S<a href="https://m.jb51.cc/tag/ol/" target="_blank" >ol</a><a href="https://m.jb51.cc/tag/ID/" target="_blank" >ID</a><a href="https://m.jb51.cc/tag/color/" target="_blank" >color</a>B<a href="https://www.jb51.cc/tag/rush/" target="_blank" >rush</a>(<a href="https://m.jb51.cc/tag/color/" target="_blank" >color</a>.Fr<a href="https://www.jb51.cc/tag/omr/" target="_blank" >omr</a>gb(<span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800080;">0</span>,<span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #800080;">255</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;">)); </span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #008000;">//</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #008000;"> this.Window_Closed();</span> <span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #0000ff;">this</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;">.Close(); } </span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #0000ff;">catch</span><span https://m.jb51.cc/tag/color/" target="_blank" >color</a>: #000000;"> (Exception ex) { Message<a href="https://www.jb51.cc/tag/Box/" target="_blank" >Box</a>.Show(ex.Message); }</span></pre>
2,。
(StockManageDataContext smDataContext = usrname = (.Parent s = smDataContext.Users.Single(c => c.Username ===.NavigationService.Navigate( Uri(=四,根据Index的值 来判断要编辑item还是要新增item。
此步是获得index,前提是父窗口或者子窗口已经传入一个带参。
Index { ; supplierAM(= (Index > = = item = smDataContext.suppliers.SingleOrDefault(c => c.ID =======此步是提交按钮的事件。
button_submit_Click(= (Index > item = smDataContext.suppliers.SingleOrDefault(c => c.ID ======= ===== +总结
以上是内存溢出为你收集整理的C# 从数据库中删除,插入,修改 索引选中条目全部内容,希望文章能够帮你解决C# 从数据库中删除,插入,修改 索引选中条目所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)