一。删除
1.
(usrListView.SelectedIndex != - currentSelectIndex = item = (StockManageDataContext smDataContext = Box.Show(ex.Message);
}
}
}
2.
MenuItemDelete_Click(
</span><span style="color: #0000ff;">if</span> (AddressList.SelectedIndex == -<span style="color: #800080;">1</span><span style="color: #000000;">)
{
Message<a href="/tag/Box/" target="_blank" class="keywords">Box</a>.Show(</span><span style="color: #800000;">"</span><span style="color: #800000;">请选择一项!</span><span style="color: #800000;">"</span><span style="color: #000000;">);
</span><span style="color: #0000ff;">return</span><span style="color: #000000;">;
}
</span><span style="color: #0000ff;">if</span> (Message<a href="/tag/Box/" target="_blank" class="keywords">Box</a>.Show(<span style="color: #800000;">"</span><span style="color: #800000;">确认<a href="/tag/shanchu/" target="_blank" class="keywords">删除</a>所选定的供应商信息?</span><span style="color: #800000;">"</span>,<span style="color: #800000;">"</span><span style="color: #800000;"><a href="/tag/tishi/" target="_blank" class="keywords">提示</a></span><span style="color: #800000;">"</span>,Message<a href="/tag/Box/" target="_blank" class="keywords">Box</a>Button.OKCancel) ==<span style="color: #000000;"> Message<a href="/tag/Box/" target="_blank" class="keywords">Box</a>Result.OK)
{
</span><span style="color: #0000ff;">while</span> (AddressList.SelectedIndex != -<span style="color: #800080;">1</span><span style="color: #000000;">){
</span><span style="color: #0000ff;">var</span> currentSelectIndex =<span style="color: #000000;"> AddressList.SelectedIndex;
SHDZ selectedAddress </span>=<span style="color: #000000;"> (SHDZ)AddressList.SelectedValue;
</span><span style="color: #0000ff;">using</span> (WJKCDataContext wjkc = <span style="color: #0000ff;">new</span><span style="color: #000000;"> WJKCDataContext())
{
</span><span style="color: #0000ff;">try</span><span style="color: #000000;">
{
wjkc.ExecuteCommand(</span><span style="color: #800000;">"</span><span style="color: #800000;">DELETE FROM SHDZ WHERE CODE={0}</span><span style="color: #800000;">"</span><span style="color: #000000;">,selectedAddress.CODE);
addressView.RemoveAt(currentSelectIndex);
}
</span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception ex)
{
Message<a href="/tag/Box/" target="_blank" class="keywords">Box</a>.Show(ex.Message);
}
}
</span><span style="color: #0000ff;">return</span><span style="color: #000000;">;
}
}
}
}</span></pre>
3.
item = smDataContext.Suppliers.SingleOrDefault(c => c.ID == ( (item != Box.Show(删除成功!Box.Show(删除时发生错误!错误信息:+
二。插入
1.
(StockManageDataContext smDataContext = User { UserName = usrName.Text,Password = pwd,Permission =Box.Show(添加用户改成功!= Box1.IsEnabled = Box2.IsEnabled = = = = Box1.Password = Box2.Password = =
2.
= 添加成功!= SolidColorBrush(Color.FromRgb(,,
三 编辑
1.
确保 编辑的对象是所选对象,所以传入参数要注意,并且编辑时要先填充控件。
wjkc.ExecuteCommand(</span><span style="color: #800000;">"</span><span style="color: #800000;">update SHDZ set DETAIL={0},DZ={1},ISTY={2} where CODE={3};</span><span style="color: #800000;">"</span><span style="color: #000000;">,address.ISTY,address.CODE);
lblMsg.Content </span>= <span style="color: #800000;">"</span><span style="color: #800000;">信息<a href="/tag/xiugai/" target="_blank" class="keywords">修改</a>成功!</span><span style="color: #800000;">"</span><span style="color: #000000;">;
lblMsg.Foreground </span>= <span style="color: #0000ff;">new</span> SolidColorBrush(Color.FromRgb(<span style="color: #800080;">0</span>,<span style="color: #800080;">255</span><span style="color: #000000;">));
</span><span style="color: #008000;">//</span><span style="color: #008000;"> this.Window_Closed();</span>
<span style="color: #0000ff;">this</span><span style="color: #000000;">.Close();
}
</span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception ex)
{
Message<a href="/tag/Box/" target="_blank" class="keywords">Box</a>.Show(ex.Message);
}</span></pre>
2,。
(StockManageDataContext smDataContext = usrname = (.Parent s = smDataContext.Users.Single(c => c.UserName ===Box.Show(添加成功!.NavigationService.Navigate( Uri(Box.Show(ex.Message);
label_warning.Content = 提示:密码修改失败!
四,根据Index的值 来判断要编辑item还是要新增item。
此步是获得index,前提是父窗口或者子窗口已经传入一个带参。
Index { ; SupplierAM(= (Index > = 修改供应商信息= item = smDataContext.Suppliers.SingleOrDefault(c => c.ID ==Box_name.Text =Box_contacter.Text =Box_tel.Text =Box_fax.Text == 添加供应商信息
此步是提交按钮的事件。
button_submit_Click(= (Index > item = smDataContext.Suppliers.SingleOrDefault(c => c.ID ===Box_name.Text;
item.PsContacter =Box_contacter.Text;
item.PsTel =Box_tel.Text;
item.PsFax =Box_fax.Text;
}
= =Box_name.Text;
item.PsContacter =Box_contacter.Text;
item.PsTel =Box_tel.Text;
item.PsFax =Box_fax.Text;
smDataContext.Suppliers.InsertOnSubmit(item);
}
Box.Show(= Box.Show(错误!错误信息: +