using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using System.Data; namespace SiaSun.LMS.WPFClient.Dialog { /// /// WorkMode.xaml 的交互逻辑 /// public partial class SYSMode : Window { string inventory_code = string.Empty; /// /// 构造函数 /// public SYSMode() { InitializeComponent(); } /// /// 加载窗体 /// private void Window_Loaded(object sender, RoutedEventArgs e) { DataTable dtMode = MainApp._I_BaseService.GetList(string.Format("SELECT * FROM SYS_ITEM_LIST WHERE ITEM_ID=96")); #region 模式设置 string WorkMode = dtMode.Rows[0]["ITEM_LIST_CODE"].ToString(); foreach (UIElement element in wpWorkMode.Children) { if (!(element is RadioButton)) continue; if ((element as RadioButton).Tag.ToString() == WorkMode) { (element as RadioButton).IsChecked = true; } } #endregion } /// /// 按钮事件 /// private void WrapPanel_Click(object sender, RoutedEventArgs e) { Button btn = e.OriginalSource as Button; if (btn != null) { switch (btn.Name) { case "btnOK": this.Save(btn); break; case "btnCancel": this.Close(); break; } } } /// /// private void Save(object sender) { string sResult = string.Empty; bool bResult = true; try { string WorkMode = string.Empty; if (this.rbtAuto.IsChecked == true) { WorkMode = this.rbtAuto.Tag.ToString(); } else if (this.rbtManual.IsChecked == true) { WorkMode = this.rbtManual.Tag.ToString(); } else { bResult = false; sResult = string.Format("请选择一种模式"); return; } string SQL = string.Format("update sys_item_list set ITEM_LIST_CODE='{0}' where ITEM_ID=96", WorkMode); MainApp._I_BaseService.ExecuteNonQuery_ReturnVoid(SQL); } catch (Exception ex) { bResult = false; sResult = ex.Message; } finally { if (!bResult) { MainApp._MessageDialog.ShowResult(bResult, sResult); } else { MainApp._MessageDialog.ShowResult(bResult, sResult); this.DialogResult = bResult; } } } } }