/// <summary>
        /// 按钮点击事件-查询出入信息
        /// </summary>
        /// <param name="sender">事件源</param>
        /// <param name="e">事件参数</param>
        private void QueryBtn_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(moldNR))
            {
                ConditionServiceClient conditionclient = new ConditionServiceClient();
                BasicMessage msg = new BasicMessage();

                if (!conditionclient.MoldExist(moldNR))
                {
                    msg.Result = false;
                    msg.MsgContent.Add("模具");
                }
                if (applicantNRTB.Text.Length != 0&&!conditionclient.EmpExist(applicantNRTB.Text))
                {
                    msg.Result = false;
                    msg.MsgContent.Add("员工");
                }
                if (msg.Result == false)
                {
                    MessageBox.Show(msg.MsgText+" 不存在,请重新输入");
                    return;
                }
                MoldPartInfoServiceClient client = new MoldPartInfoServiceClient();
                DateTime? startDT = null;
                DateTime? endDT = null;
                startDT = startDateDP.Text.Length == 0 ? startDT : DateTime.Parse(startDateDP.Text);
                endDT = endDateDP.Text.Length == 0 ? endDT : DateTime.Parse(endDateDP.Text);
                List<StorageRecord> storageRecord = client.GetMoldApplyRecords(moldNR, applicantNRTB.Text, startDT, endDT);
                MoldInOutInfoDG.ItemsSource = storageRecord;
            }
        }
        /// <summary>
        /// 按钮点击事件-申领模具
        /// </summary>
        /// <param name="sender">事件源</param>
        /// <param name="e">事件参数</param>
        private void MoldApplyBtn_Click(object sender, RoutedEventArgs e)
        {
            if ((ToolingManWPF.ConditionServiceReference.MoldStateType)moldBaseInfo.State != ToolingManWPF.ConditionServiceReference.MoldStateType.Normal
                && (MoldUseType)int.Parse(MoldUseWayCB.SelectedValue.ToString()) == MoldUseType.Produce)
            {
                MessageBox.Show("模具目前状态不可用作正产!");
                return;
            }
            if (!string.IsNullOrWhiteSpace(EnsureMoldNRTB.Text) && !string.IsNullOrWhiteSpace(ApplicantNRTB.Text) && !string.IsNullOrWhiteSpace(WorkstationNRTB.Text))
            {
                if (MoldNRTB.Text.Equals(EnsureMoldNRTB.Text))
                {
                    ConditionServiceClient conditionclient = new ConditionServiceClient();
                    BasicMessage bmsg = new BasicMessage();
                    if (!conditionclient.EmpExist(ApplicantNRTB.Text))
                    {
                        bmsg.Result = false;
                        bmsg.MsgContent.Add("申领员工");
                    }
                    if (!conditionclient.WorkstationExist(WorkstationNRTB.Text))
                    {
                        bmsg.Result = false;
                        bmsg.MsgContent.Add("工作台");
                    }
                    if (bmsg.Result == false)
                    {
                        MessageBox.Show(bmsg.MsgText + " 不存在,请重新输入");
                        return;
                    }

                    StorageManageServiceClient client = new StorageManageServiceClient();
                    Message msg = client.ApplyMold((MoldUseType)int.Parse(MoldUseWayCB.SelectedValue.ToString()), MoldNRTB.Text, ApplicantNRTB.Text, "", WorkstationNRTB.Text);
                    MessageBoxResult result = MessageBox.Show(msg.Content);
                    if (result == MessageBoxResult.OK)
                    {
                        this.Close();
                    }

                }
                else
                {
                    MessageBox.Show("确认模具号 与 模具号不一致");
                }
            }
            else
            {
                MessageBox.Show("请完整填写 申领员工号,压接机号,确认模具号");
            }
        }
        /// <summary>
        /// 显示模具位置
        /// </summary>
        private void ShowMoldPosition()
        {
            ConditionServiceClient conditionclient = new ConditionServiceClient();
            BasicMessage bmsg = new BasicMessage();
            if (!conditionclient.MoldExist(MoldNRTB.Text))
            {
                bmsg.Result = false;
                MoldPosiNRTB.Text = string.Empty;
            }
            if (bmsg.Result == false)
            {

                return;
            }
            MoldPartInfoServiceClient moldpartClient = new MoldPartInfoServiceClient();
            MoldPosiNRTB.Text = moldpartClient.GetMoldPositionByNr(MoldNRTB.Text).PositionNR;
        }
        /// <summary>
        /// 按钮点击事件-模具入库
        /// </summary>
        /// <param name="sender">事件源</param>
        /// <param name="e">事件参数</param>
        private void OKBtn_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(MoldNRTB.Text) || string.IsNullOrWhiteSpace(OperatorTB.Text) )
            {
                MessageBox.Show("请将 模具号,操作员号 填写完整");
            }
            else
            {
                ConditionServiceClient conditionclient = new ConditionServiceClient();
                BasicMessage bmsg = new BasicMessage();

                if (!conditionclient.MoldExist(MoldNRTB.Text))
                {
                    bmsg.Result = false;
                    bmsg.MsgContent.Add("模具");
                }
                if (OperatorTB.Text.Length != 0 && !conditionclient.EmpExist(OperatorTB.Text))
                {
                    bmsg.Result = false;
                    bmsg.MsgContent.Add("操作员");
                }
                if (bmsg.Result == false)
                {
                    MessageBox.Show(bmsg.MsgText + " 不存在,请重新输入");
                    return;
                }
                StorageManageServiceClient client = new StorageManageServiceClient();
               // Message msg = client.MoldInStore(MoldNRTB.Text, OperatorTB.Text, WarehouseNRTB.Text, PositionNRTB.Text);
                Message msg = client.ReturnMoldInPosition(MoldNRTB.Text, OperatorTB.Text, RemarkTB.Text);
                MessageBoxResult result = MessageBox.Show(msg.Content);
                if (result == MessageBoxResult.OK)
                {
                    this.Close();
                }

            }
        }
        /// <summary>
        /// 按钮点击事件-上传报告
        /// </summary>
        /// <param name="sender">事件源</param>
        /// <param name="e">事件参数</param>
        private void UpReportBtn_Click(object sender, RoutedEventArgs e)
        {
            if (MoldNRTB.Text.Length > 0 && OperatorNRTB.Text.Length > 0)
            {
                StorageManageServiceClient client = new StorageManageServiceClient();
                ConditionServiceClient conditionclient = new ConditionServiceClient();
                BasicMessage bmsg = new BasicMessage();
                if (!conditionclient.MoldExist(MoldNRTB.Text))
                {
                    bmsg.Result = false;
                    bmsg.MsgContent.Add("模具");
                }
                if (OperatorNRTB.Text.Length != 0 && !conditionclient.EmpExist(OperatorNRTB.Text))
                {
                    bmsg.Result = false;
                    bmsg.MsgContent.Add("试验员");
                }
                if (bmsg.Result == false)
                {
                    MessageBox.Show(bmsg.MsgText + " 不存在,请重新输入");
                    return;
                }
                // MoldPartInfoServiceClient bclient = new MoldPartInfoServiceClient();
                //MoldBaseInfo moldBaseInfo = bclient.GetMoldBaseInfoByNR(MoldNRTB.Text);
                //if (moldBaseInfo.State == ToolingManWPF.MoldPartInfoServiceReference.MoldStateType.NotReturned)
                //{
                //    MessageBox.Show("模具还未归还!");
                //    return;
                //}

                List<FileUP> files = null;
                long fileTotalLength = 0;
                if (FileNameList.Items.Count > 0)
                {
                    files = new List<FileUP>();
                    UserListBoxItem userListBoxItem;

                    imageFilter = FileFilterUtil.GetImageFilters();
                    documentFilter = FileFilterUtil.GetDocumentFilters();

                    foreach (object item in FileNameList.Items)
                    {
                        userListBoxItem = item as UserListBoxItem;
                        string path = userListBoxItem.Value;

                        if (File.Exists(path))
                        {
                            string fileType = path.Substring(path.LastIndexOf('.'), path.Length - path.LastIndexOf('.'));
                            string fileName = userListBoxItem.Display;

                            Stream stream = File.Open(path, FileMode.Open, FileAccess.Read);
                            byte[] data = new byte[stream.Length];
                            stream.Read(data, 0, data.Length);
                            stream.Seek(0, SeekOrigin.Begin);

                            fileTotalLength += stream.Length;

                            ToolingManWPF.StorageManageServiceReference.AttachmentType attachType = ToolingManWPF.StorageManageServiceReference.AttachmentType.PICTURE;

                            if (imageFilter.Contains(fileType))
                            {
                                attachType = ToolingManWPF.StorageManageServiceReference.AttachmentType.PICTURE;
                            }
                            else if (documentFilter.Contains(fileType))
                            {
                                attachType = ToolingManWPF.StorageManageServiceReference.AttachmentType.DOCUMENT;
                            }
                            files.Add(new FileUP() { Name = fileName, FileType = fileType, Type = attachType, Data = data });
                        }
                    }

                }

                if (fileTotalLength < long.Parse((new ConfigUtil("MAXFILELENGTH")).Get("MAXLENGTH")))
                {
                    Message msg = new Message();
                    switch ((ToolingManWPF.MoldPartInfoServiceReference.ReportType)int.Parse(MaintainTypeCB.SelectedValue.ToString()))
                    {
                        case ToolingManWPF.MoldPartInfoServiceReference.ReportType.MaintainReport:
                           // msg = client.MoldMaintain(MoldNRTB.Text, OperatorNRTB.Text, files, (bool)MoldStateCheckBox.IsChecked);
                            msg = client.MoldMaintain(MoldNRTB.Text, OperatorNRTB.Text, files, false);
                            break;
                        case ToolingManWPF.MoldPartInfoServiceReference.ReportType.TestReport:
                            int c = 0;
                            //int.TryParse(CurrentCutTimeTB.Text,out c);
                            msg = client.MoldTest(MoldNRTB.Text, OperatorNRTB.Text, files, c, false);
                            //msg = client.MoldTest(MoldNRTB.Text, OperatorNRTB.Text, files, c, (bool)MoldStateCheckBox.IsChecked);
                            break;
                    }

                    MessageBox.Show(msg.Content);
                }
                else
                    MessageBox.Show("一次上传文件大小不可大于50M", "", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        /// <summary>
        /// 按钮点击事件-模具归还
        /// </summary>
        /// <param name="sender">事件源</param>
        /// <param name="e">事件参数</param>
        private void ReturnMoldBtn_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(MoldNRTB.Text) && !string.IsNullOrWhiteSpace(ApplicantNRTB.Text))
            {
                ConditionServiceClient conditionclient = new ConditionServiceClient();
                BasicMessage bmsg = new BasicMessage();

                if (!conditionclient.MoldExist(MoldNRTB.Text))
                {
                    bmsg.Result = false;
                    bmsg.MsgContent.Add("模具");
                }
                if (ApplicantNRTB.Text.Length != 0 && !conditionclient.EmpExist(ApplicantNRTB.Text))
                {
                    bmsg.Result = false;
                    bmsg.MsgContent.Add("退料员工");
                }
                if (bmsg.Result == false)
                {
                    MessageBox.Show(bmsg.MsgText + " 不存在,请重新输入");
                    return;
                }

                StorageManageServiceClient client = new StorageManageServiceClient();
                Message msg = client.ReturnMold(MoldNRTB.Text, ApplicantNRTB.Text, "", RemarkTB.Text, (MoldReturnStateType)int.Parse(MoldSateCB.SelectedValue.ToString()));
                MessageBox.Show(msg.Content);
                if (msg.MsgType == MsgType.OK)
                {
                    MoldPosiSP.Visibility = Visibility.Visible;
                    MoldPartInfoServiceClient moldpartClient = new MoldPartInfoServiceClient();
                    MoldPosiNRTB.Text = moldpartClient.GetMoldPositionByNr(MoldNRTB.Text).PositionNR;
                    MoldInStoreBtn.IsEnabled = true;
                }
            }
            else
            {
                MessageBox.Show("请将 模具号,退料员工号 填写完整");
            }
        }