private void ButtonEditItem_Click(object sender, RoutedEventArgs e) { if (_SelIndex < 0) { MessageBox.Show("未选择任何项目!", "操作提示"); return; } Global.WaitingWindowIsClose = true; DYHMItemPara item = Global.hmItems[_SelIndex]; bool canEdit = false; if (string.Empty.Equals(item.Password)) { canEdit = true; } else { for (int i = 0; i < 1; i++) { InputDialog dialog = new InputDialog("请输入密码"); dialog.ShowDialog(); if (dialog.GetResult()) { if (dialog.GetInput().Equals(item.Password)) { canEdit = true; break; } else { canEdit = false; MessageBox.Show("密码错误"); } i--; } } } if (canEdit) { HmEditItemWindow window = new HmEditItemWindow() { _item = Global.hmItems[_SelIndex], ShowInTaskbar = false, Owner = this }; window.ShowDialog(); ShowAllItems(Global.hmItems, _SelIndex); } }
private void ButtonDelItem_Click(object sender, RoutedEventArgs e) { if (_SelIndex < 0) { MessageBox.Show("未选择任何项目!", "操作提示"); return; } DYHMItemPara item = Global.hmItems[_SelIndex]; bool canEdit = false; if (string.Empty.Equals(item.Password)) { canEdit = true; } else { for (int i = 0; i < 1; i++) { InputDialog dialog = new InputDialog("请输入密码"); dialog.ShowDialog(); if (dialog.GetResult()) { if (dialog.GetInput().Equals(item.Password)) { canEdit = true; break; } else { canEdit = false; MessageBox.Show("密码错误"); } i--; } } } if (canEdit) { Global.hmItems.RemoveAt(_SelIndex); Global.SerializeToFile(Global.hmItems, Global.hmItemsFile); ShowAllItems(Global.hmItems); _SelIndex = -1; } }
private UIElement GenerateItemBriefLayout(DYHMItemPara item, string name, bool FalseOrTrue) { //是否显示调整项目顺序 Boolean IsSetIndex = Global.IsSetIndex ? true : false; Border border = new Border() { Width = 185, Margin = new Thickness(2), BorderThickness = new Thickness(5), CornerRadius = new CornerRadius(10), BorderBrush = name.Equals(string.Empty) ? _borderBrushNormal : _borderBrushSelected, Background = Brushes.AliceBlue, Name = "border" }; if (FalseOrTrue) { border.BorderBrush = _borderBrushSelected; } border.MouseDown += Border_MouseDown; StackPanel stackPanel = new StackPanel() { Width = 185, Name = "stackPanel" }; Grid gridLabelName = new Grid() { Width = 185, Height = 40 }; Label labelName = new Label() { FontSize = 20, HorizontalAlignment = System.Windows.HorizontalAlignment.Center, VerticalAlignment = System.Windows.VerticalAlignment.Center, Content = item.Name, Name = "labelName" }; #region //检测孔 隐藏 //WrapPanel wrapPannelHole = new WrapPanel(); //wrapPannelHole.Width = 185; //wrapPannelHole.Height = 30; //wrapPannelHole.Visibility = System.Windows.Visibility.Collapsed; //Label labelSampleHole = new Label(); //labelSampleHole.Width = 75; //labelSampleHole.Height = 26; //labelSampleHole.Margin = new Thickness(0, 2, 0, 0); //labelSampleHole.FontSize = 15; //labelSampleHole.Content = "检测孔:"; //labelSampleHole.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; //TextBox textBoxSampleHole = new TextBox(); //textBoxSampleHole.Width = 95; //textBoxSampleHole.Height = 26; //textBoxSampleHole.Margin = new Thickness(0, 2, 0, 2); //textBoxSampleHole.FontSize = 15; //string strhole = string.Empty; //for (int i = 0; i < Global.deviceHole.HmCount; ++i) //{ // if (item.Hole[i].Use) // { // if (string.Empty.Equals(strhole)) // strhole += (i + 1); // else // strhole += "," + (i + 1); // } //} //textBoxSampleHole.Text = strhole; //textBoxSampleHole.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; //textBoxSampleHole.IsReadOnly = true; #endregion //样品名称 WrapPanel wrapPannelSampleName = new WrapPanel() { Width = 185, Height = 30 }; //Label labelX = new Label(); //labelX.Width = 16; //labelX.Height = 26; //labelX.Margin = new Thickness(0, 0, 0, 0); //labelX.FontSize = 15; //labelX.Content = "*"; //labelX.Foreground = new SolidColorBrush(Colors.Red); //labelX.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; //wrapPannelSampleName.Children.Add(labelX); Label labelSampleName = new Label() { Width = 75, Height = 26, Margin = new Thickness(0, 2, 0, 0), FontSize = 15, Content = "样品名称", FlowDirection = System.Windows.FlowDirection.RightToLeft, VerticalContentAlignment = System.Windows.VerticalAlignment.Center }; TextBox textBoxSampleName = new TextBox() { Width = 95, Height = 26, Margin = new Thickness(0, 2, 0, 2), FontSize = 15, Text = name.Trim().Equals(string.Empty) ? string.Empty : name.Trim().ToString(), VerticalContentAlignment = System.Windows.VerticalAlignment.Center, Name = "sampleName", ToolTip = "双击可查询样品名称", IsReadOnly = true//Global.EachDistrict.Equals("CC") ? true : false }; textBoxSampleName.MouseDoubleClick += textBoxSampleName_MouseDoubleClick; if (Global.IsSelectSampleName) { textBoxSampleName.TextChanged += textBoxSampleName_TextChanged; textBoxSampleName.KeyDown += textBoxSampleName_KeyDown; } //任务主题 WrapPanel wrapPannelTask = null; Label labelTaskName = null; TextBox textBoxTaskName = null; if (Global.InterfaceType.Equals("DY")) { wrapPannelTask = new WrapPanel() { Width = 185, Height = 30 }; labelTaskName = new Label() { Width = 75, Height = 26, Margin = new Thickness(0, 2, 0, 0), FontSize = 15, Content = "任务主题", FlowDirection = System.Windows.FlowDirection.RightToLeft, VerticalContentAlignment = System.Windows.VerticalAlignment.Center }; textBoxTaskName = new TextBox() { Width = 95, Height = 26, Margin = new Thickness(0, 2, 0, 0), FontSize = 15, Text = string.Empty, DataContext = string.Empty, VerticalContentAlignment = System.Windows.VerticalAlignment.Center, Name = "TaskName", ToolTip = "双击可查询所有任务" }; textBoxTaskName.MouseDoubleClick += textBoxTaskName_MouseDoubleClick; } //被检单位 WrapPanel wrapCompany = new WrapPanel() { Width = 185, Height = 30 }; //Label labelY = new Label(); //labelY.Width = 16; //labelY.Height = 26; //labelY.Margin = new Thickness(0, 0, 0, 0); //labelY.FontSize = 15; //labelY.Content = "*"; //labelY.Foreground = new SolidColorBrush(Colors.Red); //labelY.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; Label labelCompany = new Label() { Width = 75, Height = 26, Margin = new Thickness(0, 2, 0, 0), FontSize = 15, Content = "被检单位", FlowDirection = System.Windows.FlowDirection.RightToLeft, VerticalContentAlignment = System.Windows.VerticalAlignment.Center }; //if (EachDistrict) //{ // wrapCompany.Children.Add(labelY); // labelCompany.Width = 75; //} TextBox textBoxCompany = new TextBox() { Width = 95, Height = 26, Margin = new Thickness(0, 2, 0, 0), FontSize = 15, Text = string.Empty, VerticalContentAlignment = System.Windows.VerticalAlignment.Center, Name = "Company", ToolTip = "双击可查询所有被检单位", IsReadOnly = true//Global.EachDistrict.Equals("CC") ? true : false }; textBoxCompany.MouseDoubleClick += textBoxCompany_MouseDoubleClick; //生产单位 WrapPanel wrapProduceCompany = new WrapPanel() { Width = 185, Height = 30 }; //Label labelProduceCompanyX = new Label(); //labelProduceCompanyX.Width = 16; //labelProduceCompanyX.Height = 26; //labelProduceCompanyX.Margin = new Thickness(0, 0, 0, 0); //labelProduceCompanyX.FontSize = 15; //labelProduceCompanyX.Content = "*"; //labelProduceCompanyX.Foreground = new SolidColorBrush(Colors.Red); //labelProduceCompanyX.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; Label labelProduceCompany = new Label() { Width = 75, Height = 26, Margin = new Thickness(0, 2, 0, 0), FontSize = 15, Content = "生产单位", FlowDirection = System.Windows.FlowDirection.RightToLeft, VerticalContentAlignment = System.Windows.VerticalAlignment.Center }; //wrapProduceCompany.Children.Add(labelProduceCompanyX); TextBox textBoxProduceCompany = new TextBox() { Width = 95, Height = 26, Margin = new Thickness(0, 2, 0, 0), FontSize = 15, Text = string.Empty, VerticalContentAlignment = System.Windows.VerticalAlignment.Center, Name = "ProduceCompany" }; //快检单号 WrapPanel wrapSampleid = null; if (InterfaceType) { wrapSampleid = new WrapPanel() { Width = 185, Height = 30 }; //Label labelKJ = new Label(); //labelKJ.Width = 16; //labelKJ.Height = 26; //labelKJ.Margin = new Thickness(0, 0, 0, 0); //labelKJ.FontSize = 15; //labelKJ.Content = "*"; //labelKJ.Foreground = new SolidColorBrush(Colors.Red); //labelKJ.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; //wrapSampleid.Children.Add(labelKJ); Label labelSampleid = new Label() { Width = 75, Height = 26, Margin = new Thickness(0, 2, 0, 0), FontSize = 15, Content = "快检单号", FlowDirection = System.Windows.FlowDirection.RightToLeft, VerticalContentAlignment = System.Windows.VerticalAlignment.Center }; wrapSampleid.Children.Add(labelSampleid); TextBox tbSampleid = new TextBox() { Width = 95, Height = 26, Margin = new Thickness(0, 2, 0, 0), FontSize = 15, Text = string.Empty, VerticalContentAlignment = System.Windows.VerticalAlignment.Center, Name = "Sampleid", ToolTip = "双击可查询所有快检单号" }; tbSampleid.MouseDoubleClick += tbSampleid_MouseDoubleClick; wrapSampleid.Children.Add(tbSampleid); } //项目顺序 WrapPanel wrapIndex = null; Label labelIndex = null; TextBox textIndex = null; if (IsSetIndex) { wrapIndex = new WrapPanel() { Width = 185, Height = 30 }; labelIndex = new Label() { Width = 75, Height = 26, Margin = new Thickness(0, 2, 0, 0), FontSize = 15, Content = "项目顺序", VerticalContentAlignment = System.Windows.VerticalAlignment.Center }; textIndex = new TextBox() { Width = 95, Height = 26, Margin = new Thickness(0, 2, 0, 0), FontSize = 15, Text = (_SelIndex + 1).ToString(), VerticalContentAlignment = System.Windows.VerticalAlignment.Center, Name = "ProIndex" }; textIndex.TextChanged += textIndex_TextChanged; wrapIndex.Children.Add(labelIndex); wrapIndex.Children.Add(textIndex); } gridLabelName.Children.Add(labelName); wrapPannelSampleName.Children.Add(labelSampleName); wrapPannelSampleName.Children.Add(textBoxSampleName); if (Global.InterfaceType.Equals("DY")) { wrapPannelTask.Children.Add(labelTaskName); wrapPannelTask.Children.Add(textBoxTaskName); } wrapCompany.Children.Add(labelCompany); wrapCompany.Children.Add(textBoxCompany); wrapProduceCompany.Children.Add(labelProduceCompany); wrapProduceCompany.Children.Add(textBoxProduceCompany); stackPanel.Children.Add(gridLabelName); stackPanel.Children.Add(wrapPannelSampleName); if (Global.InterfaceType.Equals("DY")) { stackPanel.Children.Add(wrapPannelTask); } stackPanel.Children.Add(wrapCompany); if (EachDistrict) { stackPanel.Children.Add(wrapProduceCompany); } if (InterfaceType) { stackPanel.Children.Add(wrapSampleid); } if (IsSetIndex) { stackPanel.Children.Add(wrapIndex); } border.Child = stackPanel; return(border); }
private void ShowHmSelChannelWindow() { if (_SelIndex < 0) { MessageBox.Show("请选择点选一个检测项目,再按检测按钮"); return; } List <Border> borderList = UIUtils.GetChildObjects <Border>(WrapPanelItem, "border"); TextBox tbSampleName = UIUtils.GetChildObject <TextBox>(borderList[_SelIndex], "sampleName"); TextBox tbTaskName = UIUtils.GetChildObject <TextBox>(borderList[_SelIndex], "TaskName"); TextBox tbCompany = UIUtils.GetChildObject <TextBox>(borderList[_SelIndex], "Company"); TextBox tbProduceCompany = UIUtils.GetChildObject <TextBox>(borderList[_SelIndex], "ProduceCompany"); TextBox tbSampleid = UIUtils.GetChildObject <TextBox>(borderList[_SelIndex], "Sampleid"); DYHMItemPara item = Global.hmItems[_SelIndex]; #region 2016年12月30日 检测项目选择界面不验证必填项,通道选择界面再验证 //if (!InterfaceType) //{ // if (tbSampleName.Text.Trim().Length == 0) // { // MessageBox.Show("样品名称不能为空!\r\n请双击选择样品", "操作提示"); // tbSampleName.Focus(); // return; // } //} //if (EachDistrict) //{ // if (tbCompany.Text.Trim().Length == 0) // { // MessageBox.Show("被检单位不能为空!\r\n请双击选择被检单位", "操作提示"); // tbCompany.Focus(); // return; // } // if (tbProduceCompany.Text.Trim().Length == 0) // { // MessageBox.Show("生产单位不能为空!", "操作提示"); // tbProduceCompany.Focus(); // return; // } //} //if (InterfaceType) //{ // if (tbSampleid.Text.Trim().Length == 0) // { // MessageBox.Show("快检单号不能为空!\r\n可双击文本框选择快检单号", "操作提示"); // tbSampleid.Focus(); // return; // } //} #endregion for (int i = 0; i < Global.deviceHole.HmCount; ++i) { item.Hole[i].SampleName = tbSampleName.Text.Trim(); if (tbTaskName != null) { item.Hole[i].TaskName = tbTaskName.Text.Trim(); item.Hole[i].TaskCode = tbTaskName.DataContext.ToString(); } else { item.Hole[i].TaskName = string.Empty; item.Hole[i].TaskCode = string.Empty; } item.Hole[i].CompanyName = tbCompany.Text.Trim(); item.Hole[i].ProduceCompany = tbProduceCompany != null?tbProduceCompany.Text.Trim() : string.Empty; item.Hole[i].SampleId = tbSampleid != null?tbSampleid.Text.Trim() : string.Empty; } HmSelChannelWindow window = new HmSelChannelWindow() { _item = item, ShowInTaskbar = false, Owner = this }; window.ShowDialog(); }
public void ButtonNext_Click(object sender, RoutedEventArgs e) { // 将数据保存到文件 try { if (Check()) { if (null == _item) {// 这属于新添加 _item = new DYHMItemPara(); Global.hmItems.Add(_item); } if (sender == null && e == null) { _item.Name = _HmMetailArry[0].ToString(); //项目名称 _item.Unit = _HmMetailArry[3].ToString(); //项目检测单位 _item.HintStr = _HmMetailArry[4].ToString(); //简要操作:新添加实验--注释 _item.Password = _HmMetailArry[5].ToString(); //密码 Int32.TryParse(_HmMetailArry[6].ToString(), out _item.SampleNum); //样品编号 //检测方法选择 _item.Method = Convert.ToInt32(_HmMetailArry[12].ToString()); _item.Hole[0].Use = Convert.ToBoolean(_HmMetailArry[8].ToString()); _item.Hole[1].Use = Convert.ToBoolean(_HmMetailArry[9].ToString()); } else { _item.Name = ComboBoxItemName.Text; _item.Password = TextBoxPassword.Text; _item.HintStr = TextBoxHintStr.Text; Int32.TryParse(TextBoxSampleNum.Text, out _item.SampleNum); _item.Unit = TextBoxUnit.Text; List <CheckBox> listCheckBoxes = UIUtils.GetChildObjects <CheckBox>(StackPanelHole, typeof(CheckBox)); for (int i = 0; i < Global.deviceHole.HmCount; ++i) { _item.Hole[i].Use = (bool)listCheckBoxes[i].IsChecked; } } try { Int32.TryParse(TextBoxDilutionRatio.Text, out _item.DilutionRatio); Int32.TryParse(TextBoxConcentration.Text, out _item.Concentration); Int32.TryParse(TextBoxLiquidVolume.Text, out _item.LiquidVolume); Int32.TryParse(TextBoxRequirements.Text, out _item.Requirements); Int32.TryParse(TextBoxA0.Text, out _item.a0); Int32.TryParse(TextBoxA1.Text, out _item.a1); Int32.TryParse(TextBoxA2.Text, out _item.a2); Int32.TryParse(TextBoxItemID.Text, out _item.ItemID); } catch (Exception ex) { FileUtils.Log(ex.ToString()); return; } Global.SerializeToFile(Global.hmItems, Global.hmItemsFile); //_isClose = true; //_isUpdate = false; try { this.Close(); } catch (Exception) { } } else { //_isClose = false; } } catch (Exception exception) { MessageBox.Show(exception.Message); } }