Пример #1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (_province.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("请选择省!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_city.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("请选择市!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_region.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("请选择区!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_source_company.SelectedIndex == 0 || _source_company.Text == "")
            {
                Toolkit.MessageBox.Show("请选择被检单位!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_detect_item.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("请选择检查项目!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_detect_method.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("请选择检测方法!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_sample_no.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("样品编号不能为空!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_detect_object.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("样品名称不能为空!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_detect_value.Text.Trim().Length == 0)
            {
                Toolkit.MessageBox.Show("请输入检测值!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_detect_result.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("请选择检测结果!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_detect_person.Text.Trim().Length == 0)
            {
                Toolkit.MessageBox.Show("请选择检测师!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }


            //判断被检单位是否存在,若不存在则插入数据库

            string company_id = operationContract.GetCompanyId(_source_company.Text.Trim(), PubClass.userInfo.DepartmentID);

            if (string.IsNullOrEmpty(company_id))
            {
                bool flag = operationContract.AddCompany(_source_company.Text, (_region.SelectedItem as Label).Tag.ToString(), "1", PubClass.userInfo.DepartmentID, PubClass.userInfo.ID, DateTime.Now);
                if (!flag)
                {
                    Toolkit.MessageBox.Show("被检单位添加失败!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
            }

            //判断检测模式:若为农药残留检测,模式为0;否则模式为1
            string detect_mode = "";

            if ((_detect_item.SelectedItem as Label).Tag.ToString() == "1")
            {
                detect_mode = "0";
            }
            else
            {
                detect_mode = "1";
            }


            bool flag1 = detectContract.ExecuteProAddDetect(company_id, (_detect_item.SelectedItem as Label).Tag.ToString(), (_detect_method.SelectedItem as Label).Tag.ToString(), (_detect_object.SelectedItem as Label).Tag.ToString(), (_sample_no.SelectedItem as Label).Tag.ToString(), detect_mode, _detect_value.Text, (_detect_result.SelectedItem as Label).Tag.ToString(), PubClass.userInfo.DepartmentID, PubClass.userInfo.ID);

            if (flag1)
            {
                Toolkit.MessageBox.Show("添加成功!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                Common.SysLogEntry.WriteLog("农产品检测单录入", PubClass.userInfo.ShowName, OperationType.Add, "新增检测单");
                clear();
                ComboboxTool.InitComboboxSource(_source_company, operationContract.GetComboUserCompany(userId), "lr");
            }
            else
            {
                Toolkit.MessageBox.Show("添加失败!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (_province.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("请选择省!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_city.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("请选择市!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_region.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("请选择区!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_source_company.SelectedIndex == 0 || _source_company.Text == "")
            {
                Toolkit.MessageBox.Show("请选择被检单位!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_detect_number.Text.Trim().Length == 0)
            {
                Toolkit.MessageBox.Show("请输入检疫证号!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_object_count.Text.Trim().Length == 0)
            {
                Toolkit.MessageBox.Show("请输入批次头数!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_object_label.Text.Trim().Length == 0)
            {
                Toolkit.MessageBox.Show("请输入耳标号!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_object_label.Text.Trim().Length != 15)
            {
                Toolkit.MessageBox.Show("耳标号必须为15位!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_sample_no.SelectedIndex == 0 || _sample_no.Text == "")
            {
                Toolkit.MessageBox.Show("请选择样品编号!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_detect_sample.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("样品名称不能为空!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_detect_object.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("样品分类不能为空!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_detect_item.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("请选择检查项目!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_detect_method.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("请选择检测方法!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_detect_sensitivity.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("请选择检测灵敏度!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_detect_result.SelectedIndex < 1)
            {
                Toolkit.MessageBox.Show("请选择检测结果!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (_detect_person.Text.Trim().Length == 0)
            {
                Toolkit.MessageBox.Show("请选择检测师!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            //判断被检单位是否存在,若不存在则插入数据库

            string company_id = operationContract.GetCompanyId(_source_company.Text.Trim(), PubClass.userInfo.DepartmentID);

            if (string.IsNullOrEmpty(company_id))
            {
                bool flag = operationContract.AddCompany(_source_company.Text, (_region.SelectedItem as Label).Tag.ToString(), "1", PubClass.userInfo.DepartmentID, PubClass.userInfo.ID, DateTime.Now);
                if (!flag)
                {
                    Toolkit.MessageBox.Show("被检单位添加失败!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
            }

            bool flag1 = detectContract.ExecuteProAddDetectAnimal(company_id, (_detect_item.SelectedItem as Label).Tag.ToString(), (_detect_method.SelectedItem as Label).Tag.ToString(), (_sample_no.SelectedItem as Label).Tag.ToString(), (_detect_object.SelectedItem as Label).Tag.ToString(), (_detect_sample.SelectedItem as Label).Tag.ToString(), (_detect_sensitivity.SelectedItem as Label).Tag.ToString(), (_detect_result.SelectedItem as Label).Tag.ToString(), PubClass.userInfo.DepartmentID, PubClass.userInfo.ID, _detect_number.Text, _object_count.Text, _object_label.Text, DateTime.Now);

            if (flag1)
            {
                Toolkit.MessageBox.Show("添加成功!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                Common.SysLogEntry.WriteLog("畜产品检测单录入", PubClass.userInfo.ShowName, OperationType.Add, "新增检测单");
                clear();
                ComboboxTool.InitComboboxSource(_source_company, operationContract.GetComboUserCompany(userId), "lr");
            }
            else
            {
                Toolkit.MessageBox.Show("添加失败!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
        }