Пример #1
0
 private void VideoPlayer_Load(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(url))
     {
         //解析视频地址
         videoList = url.Split(';');
         if (videoList.Length > 0)
         {
             url = videoList[0];
         }
         if (!string.IsNullOrEmpty(url))
         {
             string serverUrl = CommonUtil.getServerIpAndPort();
             string videoUrl  = serverUrl + "inspection/videoPlayer.jsp?video_url=" + url;
             this.webBrowser1.Url = new Uri(videoUrl);
         }
         else
         {
             MessagePrompt.Show("未找到视频链接,重新打开试一下!");
         }
     }
     else
     {
         MessagePrompt.Show("未找到视频链接,重新打开试一下!");
     }
 }
Пример #2
0
 private void txt_MouseDown(TextBox tb)
 {
     try
     {
         if (tb.Tag.ToString().Contains("English"))
         {
             //设置英文输入法中输入框变量等于当前获取焦点的输入框
             AlphabetKeyboardForm.inputTxt = tb;
             //设置英文输入法输入框内容为当前输入框内容
             AlphabetKeyboardForm.getForm().Textbox_display.Text = tb.Text.Trim();
             AlphabetKeyboardForm.getForm().Show();
             //设置输入法在最顶部显示
             AlphabetKeyboardForm.getForm().TopMost = true;
             //设置英文输入法头部显示的输入框名称为当前输入框名称
             if (tb.Name.Contains("txtLoginName"))
             {
                 AlphabetKeyboardForm.getForm().lblEnglishTitle.Text = "用户名";
             }
             if (tb.Name.Contains("txtLoginPwd"))
             {
                 AlphabetKeyboardForm.getForm().lblEnglishTitle.Text = "密码";
             }
         }
     }
     catch (Exception e)
     {
         MessagePrompt.Show("系统出错,错误信息:" + e.Message);
     }
 }
Пример #3
0
 private void btnChange_Click_1(object sender, EventArgs e)
 {
     try
     {
         if (index < videoList.Length - 1)
         {
             index++;
         }
         else
         {
             index = 0;
         }
         string serverUrl = CommonUtil.getServerIpAndPort();
         url = videoList[index];
         if (!string.IsNullOrEmpty(url))
         {
             string videoUrl = serverUrl + "inspection/videoPlayer.jsp?video_url=" + url;
             this.webBrowser1.Url = new Uri(videoUrl);
         }
     }
     catch (Exception ex)
     {
         MessagePrompt.Show("播放时出错,错误信息:" + ex.Message);
     }
 }
Пример #4
0
 private void  务器设置ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         new ServerSetting().Show();
     }
     catch (Exception ex) {
         MessagePrompt.Show("打开服务器设置页面时出错,错误信息:" + ex.Message);
     }
 }
Пример #5
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定要删除吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
     {
         try
         {
             int    index = this.dataGridView1.CurrentRow.Index;
             object obj0 = this.dataGridView1.Rows[index].Cells["operator_no"].Value;
             object obj1 = this.dataGridView1.Rows[index].Cells["inspection_time"].Value;
             string operator_no = null, inspection_time = null;
             //获取选中行的记录,并通过选中行记录获取此条记录提交的时间和提交此条记录的操作工工号
             if (obj0 != null)
             {
                 operator_no = obj0.ToString();
             }
             if (obj1 != null)
             {
                 inspection_time = obj1.ToString();
             }
             //如果没有查到提交该记录的操作工工号或提交时间
             if (string.IsNullOrWhiteSpace(operator_no) || string.IsNullOrWhiteSpace(inspection_time))
             {
                 MessagePrompt.Show("系统繁忙,请稍后修改!");
                 return;
             }
             DateTime dt = DateTime.Parse(inspection_time);
             //判断当前时间与螺纹检验记录提交时间间隔
             if (Convert.ToSingle((DateTime.Now - dt).TotalHours.ToString()) > 12)
             {
                 MessagePrompt.Show("已超过12小时的记录不能删除!");
                 return;
             }
             //判断用户是否已经掉线
             if (string.IsNullOrWhiteSpace(Person.pname) || string.IsNullOrWhiteSpace(Person.employee_no))
             {
                 MessagePrompt.Show("您已掉线,请重新登录!");
                 Application.Exit();
                 return;
             }
             //判断删除的是否时自己提交的
             if (!operator_no.Equals(Person.employee_no))
             {
                 MessagePrompt.Show("只能删除自己的表单数据!");
                 return;
             }
             //删除检验记录
             excuteDelteInspectionRecord(index);
         }
         catch (Exception ex)
         {
             MessagePrompt.Show("删除失败,失败原因:" + ex.Message);
         }
     }
 }
Пример #6
0
 private void 读码器设置ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         //打开读码器设置窗体
         YYKeyenceReaderConsole.getForm().Show();
     }
     catch (Exception ex) {
         MessagePrompt.Show("打开读码器设置页面时出错,错误信息:" + ex.Message);
     }
 }
Пример #7
0
 private void 未提交ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         //打开未提交表单窗体
         new UnSubmitForm().Show();
     }
     catch (Exception ex) {
         MessagePrompt.Show("查看未提交表单时出错,错误信息:" + ex.Message);
     }
 }
Пример #8
0
 private void 录像设置ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         //打开录像设置窗体
         MainWindow.getForm().Show();
         MainWindow.isRecordClick = true;
     }
     catch (Exception ex) {
         MessagePrompt.Show("打开录像设置页面时出错,错误信息:" + ex.Message);
     }
 }
Пример #9
0
 private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         //打开螺纹检验窗体
         ThreadingForm.getMyForm().Show();
     }
     catch (Exception ex)
     {
         MessagePrompt.Show("新建表单时出错,错误信息:" + ex.Message);
     }
 }
Пример #10
0
 private MainWindow()
 {
     InitializeComponent();
     //设置窗体总体字体大小
     this.Font = new Font("宋体", 12, FontStyle.Bold);
     try
     {
         //初始化数据,用于录像机页面重置(注释在上面)
         mainWindowX      = this.Left; mainWindowY = this.Top;
         mainWindowWidth  = this.Width; mainWindowHeight = this.Height;
         realTimeX        = RealPlayWnd.Left; realTimeY = RealPlayWnd.Top;
         realTimeWidth    = RealPlayWnd.Width; realTimeHeigh = RealPlayWnd.Height;
         RealPlayWnd.Dock = DockStyle.None;
         //录像机初始化
         m_bInitSDK = CHCNetSDK.NET_DVR_Init();
         if (m_bInitSDK == false)
         {
             DebugInfo("录像机初始化失败!");
             recordStatus = 5;
         }
         else
         {
             //保存SDK日志 To save the SDK log
             string basePath = Application.StartupPath + "\\SdkLog";
             if (!Directory.Exists(basePath))
             {
                 Directory.CreateDirectory(basePath);
             }
             //设置录像机日志存放的目录
             CHCNetSDK.NET_DVR_SetLogToFile(3, basePath, true);
             comboBoxView.SelectedIndex = 0;
             for (int i = 0; i < 64; i++)
             {
                 iIPDevID[i]    = -1;
                 iChannelNum[i] = -1;
             }
         }
     }
     catch (Exception ex)
     {
         MessagePrompt.Show("初始化录像机错误,错误信息:" + ex.Message);
     }
     finally {
         myForm = this;
     }
 }
 public static void Show(string msg)
 {
     if (messagePrompt != null)
     {
         messagePrompt.Show();
         messagePrompt.TopMost = true;
     }
     else
     {
         messagePrompt         = new MessagePrompt();
         messagePrompt.TopMost = true;
         messagePrompt.Show();
     }
     messagePrompt.label2.Text = msg;
     messagePrompt.BringToFront();
     messagePrompt.TopMost = true;
 }
        private YYKeyenceReaderConsole()
        {
            InitializeComponent();
            this.Font = new Font("宋体", 10, FontStyle.Bold);
            //初始化客户端Socket连接读码器数组
            clientSocketInstance = new ClientSocket[READER_COUNT];
            //遍历数组时的索引
            int readerIndex = 0;
            //定义读码器发送命令的端口(默认为9003)
            int CommandPort = 9003;
            //定义读码器发送数据的端口(默认为9004)
            int DataPort = 9004;

            //设置控件值
            CommandPortInput.Text = Convert.ToString(CommandPort);
            DataPortInput.Text    = Convert.ToString(DataPort);
            try
            {
                //设置读码完成的声音文件路径
                audioFilePath = Application.StartupPath + "\\audio\\completed.wav";
                //读取本地目录config.txt文件,读出所有读码器IP地址
                string configPath = Application.StartupPath + "\\config.txt";
                string str        = File.ReadAllText(configPath);
                str = str.Replace("\n", "");
                string[] strIPArray = str.Split('\r');
                //两种方式初始化构造
                for (int i = 0; i < strIPArray.Length; i++)
                {
                    if (strIPArray[i].Length > 2)
                    {
                        //实例化客户端Socket连接读码器数组
                        clientSocketInstance[readerIndex] = new ClientSocket(strIPArray[i], CommandPort, DataPort);  // 9003 for command, 9004 for data
                        readerIndex++;
                    }
                }
            }
            catch (Exception e)
            {
                MessagePrompt.Show("实例化客户端连接读码器时错误,错误信息:" + e.Message);
            }
            finally {
                myselfForm = this;
            }
        }
Пример #13
0
 private void getUnSummitFile()
 {
     try
     {
         dataGridView1.Rows.Clear();
         //bin目录下unsubmit文件为未上传成功的文件(.txt格式)
         string path = Application.StartupPath + "\\unsubmit\\";
         //判断路径是否存在
         if (Directory.Exists(path))
         {
             DirectoryInfo dir = new DirectoryInfo(path);
             //获取目录下所有的.txt文件
             foreach (FileInfo file in dir.GetFiles("*.txt"))
             {
                 //添加到dataGridView1中
                 dataGridView1.Rows.Add(false, file.Name);//显示
             }
         }
     }
     catch (Exception ex)
     {
         MessagePrompt.Show("获取未上传成功的文件时出错,错误信息:" + ex.Message);
     }
 }
Пример #14
0
 private void btnUpload_Click(object sender, EventArgs e)
 {
     try
     {
         //定义存放未提交表单的所有的文件字典集合(参数为 文件名、文件路径)
         Dictionary <string, string> listFormDir = new Dictionary <string, string>();
         DataGridViewCheckBoxCell    cell        = null;
         //如果dataGridView1中有未提交的表单
         if (this.dataGridView1.Rows.Count > 0)
         {
             //遍历所有未提交的表单
             for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
             {
                 cell = (DataGridViewCheckBoxCell)this.dataGridView1.Rows[i].Cells["checkbox1"];
                 //获取当前表单是否选中要提交
                 bool flag = Convert.ToBoolean(cell.Value);
                 if (flag)
                 {
                     //如果选中上传,则将要上传的文件名添加到字典集合中
                     listFormDir.Add(this.dataGridView1.Rows[i].Cells["filename"].Value.ToString(), "");
                 }
             }
             totalForm = listFormDir.Count();
             string path = Application.StartupPath + "\\unsubmit\\";
             //获取选中表单的路径集合
             DirectoryInfo folder = new DirectoryInfo(path);
             //遍历unsubmit目录下所有的.txt文件
             foreach (FileInfo file in folder.GetFiles("*.txt"))
             {
                 //如果字典集合中的键包含当前文件的文件名
                 if (listFormDir.ContainsKey(file.Name))
                 {
                     //设置该字典的键对应的值为此文件的路径
                     listFormDir[file.Name] = path + "\\" + file.Name;
                 }
             }
             //如果有选中的文件
             if (listFormDir.Count > 0)
             {
                 int    tempTotal   = 0;
                 string jsonContent = "";
                 //遍历listPath找到未提交文件,然后读出json数据
                 foreach (string item in listFormDir.Values)
                 {
                     //读取当前txt文件中的所有的json格式的数据
                     jsonContent = File.ReadAllText(item, Encoding.UTF8).Trim();
                     if (!string.IsNullOrWhiteSpace(jsonContent))
                     {
                         //开始上传该表单
                         if (uploadUnSubmitForm(jsonContent))
                         {
                             //如果上传成功删除文件
                             File.Delete(item);
                             tempTotal++;
                         }
                         else
                         {
                             MessagePrompt.Show("上传出现问题,总共上传" + totalForm + "个,成功" + tempTotal + "个!");
                             break;
                         }
                         jsonContent = "";
                     }
                 }
                 MessagePrompt.Show("上传完毕," + tempTotal + "个成功" + (totalForm - tempTotal) + "个失败!");
                 getUnSummitFile();
             }
             else
             {
                 MessagePrompt.Show("请选中要上传的表单!");
             }
         }
         else
         {
             MessagePrompt.Show("暂未有可提交的表单!");
         }
     }
     catch (Exception ex)
     {
         MessagePrompt.Show("系统出了点问题!错误原因:" + ex.Message + ",请联系系统人员维护!");
     }
 }
 private void button_enter_Click(object sender, EventArgs e)
 {
     //回车,清楚末尾无用的.
     if (this.Textbox_display.Text.Contains(".") && this.Textbox_display.Text.LastIndexOf('.') == this.Textbox_display.Text.Length - 1)
     {
         this.Textbox_display.Text = this.Textbox_display.Text.Substring(0, this.Textbox_display.Text.Length - 1);
     }
     //判断输入法内容是否包含"."
     if (Textbox_display.Text.Contains("."))
     {
         try
         {
             //将数字专程float类型 为了转换如"3."格式的数字
             float tempf = Convert.ToSingle(Textbox_display.Text);
             Textbox_display.Text = tempf.ToString();
         }
         catch
         {
             Textbox_display.Text = "0";
         }
     }
     //鼠标焦点所在的TextBox控件不为空
     if (inputTxt != null)
     {
         //设置输入框的内容为输入法输入的内容
         inputTxt.Text = this.Textbox_display.Text.Trim();
         //将输入法内容清空
         this.Textbox_display.Text = "";
         //获取鼠标焦点所在的TextBox控件
         string inputTxtName = inputTxt.Name;
         try
         {
             //如果鼠标焦点所在的TextBox控件名称为空
             if (string.IsNullOrWhiteSpace(inputTxtName))
             {
                 return;
             }
             //判断输入的内容是否为数字
             if (!CommonUtil.IsNumeric(inputTxt.Text)) {
                 //如果输入为合格
                 if (inputTxt.Text.Contains("不合格"))
                 {
                     //设置输入框标红
                     inputTxt.BackColor = Color.LightCoral;
                     if (flag == 0)
                     {
                         if (ThreadingForm.qualifiedList.ContainsKey(inputTxtName))
                             ThreadingForm.qualifiedList[inputTxtName] = false;
                     }
                     else if (flag == 1)
                     {
                         if (DetailForm.qualifiedList.ContainsKey(inputTxtName))
                             DetailForm.qualifiedList[inputTxtName] = false;
                     }
                 }
                 else
                 {
                     //设置输入框不标红
                     inputTxt.BackColor = Color.White;
                     //如果为表单页面
                     if (flag == 0)
                     {
                         if (ThreadingForm.qualifiedList.ContainsKey(inputTxtName))
                             ThreadingForm.qualifiedList[inputTxtName] = true;
                     }
                     else if (flag == 1)//如果为修改页面
                     {
                         //判断测量项是否合格的集合中是否存在该测量项
                         if (DetailForm.qualifiedList.ContainsKey(inputTxtName))
                             DetailForm.qualifiedList[inputTxtName] = true;
                     }
                 }
                 return;
             }
             //当前输入框得类型,0代表时最大值、最小值和均值,1代表椭圆度
             int tbType=0;
             //如果控件名包含以下字符则将这些字符替换为空
             if (inputTxtName.Contains("_A_Value"))
                 inputTxtName = inputTxtName.Replace("_A_Value", "");
             else if (inputTxtName.Contains("_B_Value"))
                 inputTxtName = inputTxtName.Replace("_B_Value", "");
             else if (inputTxtName.Contains("_MaxA_Value"))
                 inputTxtName = inputTxtName.Replace("_MaxA_Value", "");
             else if (inputTxtName.Contains("_MaxB_Value"))
                 inputTxtName = inputTxtName.Replace("_MaxB_Value", "");
             else if (inputTxtName.Contains("_MinA_Value"))
                 inputTxtName = inputTxtName.Replace("_MinA_Value", "");
             else if (inputTxtName.Contains("_MinB_Value"))
                 inputTxtName = inputTxtName.Replace("_MinB_Value", "");
             else if (inputTxtName.Contains("_AvgA"))
                 inputTxtName = inputTxtName.Replace("_AvgA", "");
             else if (inputTxtName.Contains("_AvgB"))
                 inputTxtName = inputTxtName.Replace("_AvgB", "");
             else if (inputTxtName.Contains("_OvalityA"))
             {
                 inputTxtName = inputTxtName.Replace("_OvalityA", "");
                 tbType = 1;
             }
             else if (inputTxtName.Contains("_OvalityB"))
             {
                 inputTxtName = inputTxtName.Replace("_OvalityB", "");
                 tbType = 1;
             }
             //找到该测量项的值范围、和椭圆度最大值
             float maxVal = 0, minVal = 0, txtVal = float.MaxValue, maxOvality = 0, sdVal = 0;
             Dictionary<string, string> dic = null;
             if (flag == 0)
             {
                 if(ThreadingForm.measureInfoDic.ContainsKey(inputTxtName))
                    dic = ThreadingForm.measureInfoDic[inputTxtName];
             }
             else if (flag == 1) {
                 if(DetailForm.measureInfoDic.ContainsKey(inputTxtName))
                    dic = DetailForm.measureInfoDic[inputTxtName];
             }
             if (dic != null)
             {
                 string item_max_value = null, item_min_value = null, ovality_max = null, item_std_value = null;
                 if (dic.ContainsKey("item_max_value"))
                 {
                     item_max_value = Convert.ToString(dic["item_max_value"]);
                     if (CommonUtil.IsNumeric(item_max_value))
                         maxVal = Convert.ToSingle(item_max_value);
                 }
                 if (dic.ContainsKey("item_min_value"))
                 {
                     item_min_value = Convert.ToString(dic["item_min_value"]);
                     if (CommonUtil.IsNumeric(item_min_value))
                         minVal = Convert.ToSingle(dic["item_min_value"]);
                 }
                 if (dic.ContainsKey("ovality_max"))
                 {
                     ovality_max = Convert.ToString(dic["ovality_max"]);
                     if (CommonUtil.IsNumeric(ovality_max))
                         maxOvality = Convert.ToSingle(dic["ovality_max"]);
                 }
                 if (dic.ContainsKey("item_std_value"))
                 {
                     item_std_value = Convert.ToString(dic["item_std_value"]);
                     if (CommonUtil.IsNumeric(item_std_value))
                         sdVal = Convert.ToSingle(dic["item_std_value"]);
                 }
             }
             if (!string.IsNullOrWhiteSpace(inputTxt.Text.Trim())) {
                 txtVal = Convert.ToSingle(inputTxt.Text.Trim());
             }
             if (txtVal!=float.MaxValue)
             {
                 //如果输入法输入的值不符合标准
                 if (txtVal < minVal || txtVal > maxVal)
                 {
                     //设置存放测量值的输入框的背景色
                     inputTxt.BackColor = Color.LightCoral;
                     //如果该集合中包含该控件的名称
                     if (flag == 0)
                     {
                         if (ThreadingForm.qualifiedList.ContainsKey(inputTxtName))
                         {
                             ThreadingForm.qualifiedList[inputTxtName] = false;
                         }
                     }
                     else if (flag == 1) {
                         if (DetailForm.qualifiedList.ContainsKey(inputTxtName))
                         {
                             DetailForm.qualifiedList[inputTxtName] = false;
                         }
                     }
                 }
                 else
                 {
                     inputTxt.BackColor = Color.White;
                     if (flag == 0)
                     {
                         if (ThreadingForm.qualifiedList.ContainsKey(inputTxtName))
                         {
                             ThreadingForm.qualifiedList[inputTxtName] = true;
                         }
                     }
                     else if (flag == 1)
                     {
                         if (DetailForm.qualifiedList.ContainsKey(inputTxtName))
                         {
                             DetailForm.qualifiedList[inputTxtName] = true;
                         }
                     }
                 }
             }
             //找到该测量项A端、B端最大值、最小值,然后判断是否存在均值和椭圆度
             TextBox txtMaxOfA = null, txtMaxOfB = null, txtMinOfA = null, txtMinOfB = null, tbAvgOfA = null, tbOvalityA = null,
                   tbAvgOfB = null, tbOvalityB = null;
             if (flag == 0)
             {
                 if(ThreadingForm.controlTxtDir.ContainsKey(inputTxtName + "_MaxA_Value"))
                   txtMaxOfA = ThreadingForm.controlTxtDir[inputTxtName + "_MaxA_Value"];
                 if (ThreadingForm.controlTxtDir.ContainsKey(inputTxtName + "_MaxB_Value"))
                     txtMaxOfB = ThreadingForm.controlTxtDir[inputTxtName + "_MaxB_Value"];
                 if (ThreadingForm.controlTxtDir.ContainsKey(inputTxtName + "_MinA_Value"))
                     txtMinOfA = ThreadingForm.controlTxtDir[inputTxtName + "_MinA_Value"];
                 if (ThreadingForm.controlTxtDir.ContainsKey(inputTxtName + "_MinB_Value"))
                     txtMinOfB = ThreadingForm.controlTxtDir[inputTxtName + "_MinB_Value"];
                 if (ThreadingForm.controlTxtDir.ContainsKey(inputTxtName + "_AvgA"))
                     tbAvgOfA =  ThreadingForm.controlTxtDir[inputTxtName + "_AvgA"];
                 if (ThreadingForm.controlTxtDir.ContainsKey(inputTxtName + "_AvgB"))
                     tbAvgOfB = ThreadingForm.controlTxtDir[inputTxtName + "_AvgB"];
                 if (ThreadingForm.controlTxtDir.ContainsKey(inputTxtName + "_OvalityA"))
                     tbOvalityA = ThreadingForm.controlTxtDir[inputTxtName + "_OvalityA"];
                 if (ThreadingForm.controlTxtDir.ContainsKey(inputTxtName + "_OvalityB"))
                     tbOvalityB = ThreadingForm.controlTxtDir[inputTxtName + "_OvalityB"];
             }
             else if (flag == 1) {
                 if(DetailForm.controlTxtDir.ContainsKey(inputTxtName + "_MaxA_Value"))
                   txtMaxOfA = DetailForm.controlTxtDir[inputTxtName + "_MaxA_Value"];
                 if (DetailForm.controlTxtDir.ContainsKey(inputTxtName + "_MaxB_Value"))
                     txtMaxOfB = DetailForm.controlTxtDir[inputTxtName + "_MaxB_Value"];
                 if (DetailForm.controlTxtDir.ContainsKey(inputTxtName + "_MinA_Value"))
                     txtMinOfA = DetailForm.controlTxtDir[inputTxtName + "_MinA_Value"];
                 if (DetailForm.controlTxtDir.ContainsKey(inputTxtName + "_MinB_Value"))
                     txtMinOfB = DetailForm.controlTxtDir[inputTxtName + "_MinB_Value"];
                 if (DetailForm.controlTxtDir.ContainsKey(inputTxtName + "_AvgA"))
                     tbAvgOfA = DetailForm.controlTxtDir[inputTxtName + "_AvgA"];
                 if (DetailForm.controlTxtDir.ContainsKey(inputTxtName + "_AvgB"))
                     tbAvgOfB = DetailForm.controlTxtDir[inputTxtName + "_AvgB"];
                 if (DetailForm.controlTxtDir.ContainsKey(inputTxtName + "_OvalityA"))
                     tbOvalityA = DetailForm.controlTxtDir[inputTxtName + "_OvalityA"];
                 if (DetailForm.controlTxtDir.ContainsKey(inputTxtName + "_OvalityB"))
                     tbOvalityB = DetailForm.controlTxtDir[inputTxtName + "_OvalityB"];
             }
             //判断输入的数值是否合理
             bool reasonableFlag = false;
             switch (tbType) {
                 case 0:
                     if (maxVal != 0)
                     {
                         if (maxVal * 10 < txtVal)
                             reasonableFlag = true;
                     }
                     else {
                         if (txtVal > 10 || txtVal < -10)
                             reasonableFlag = true;
                     }
                     break;
                 case 1:
                     if (maxOvality != 0) {
                         if (maxOvality > 0 && maxOvality * 10 < txtVal)
                             reasonableFlag = true;
                     }
                     else
                     {
                         if (maxOvality+10<txtVal)
                             reasonableFlag = true;
                     }
                     break;
             }
             if (reasonableFlag)
             {
                 MessagePrompt.Show("输入的数据偏差过大, 请检查!");
             }
             //如果测量项A端最大值、最小值不为空
             if (txtMaxOfA != null && !string.IsNullOrWhiteSpace(txtMaxOfA.Text)
                 && txtMinOfA != null && !string.IsNullOrWhiteSpace(txtMinOfA.Text))
             {
                 //获取均值
                 float avg = ((Convert.ToSingle(txtMaxOfA.Text) + Convert.ToSingle(txtMinOfA.Text)) / 2);
                 //判断均值是否符合要求
                 if (tbAvgOfA != null)
                 {
                     //如果均值不符合标准
                     if (avg < minVal || avg > maxVal)
                     {
                         //设置显示均值的label控件的标红
                         tbAvgOfA.BackColor = Color.LightCoral;
                         if (flag == 0)
                         {
                             if (ThreadingForm.qualifiedList.ContainsKey(inputTxtName))
                                 ThreadingForm.qualifiedList[inputTxtName] = false;
                         }
                         else if (flag == 1) {
                             if (DetailForm.qualifiedList.ContainsKey(inputTxtName))
                                 DetailForm.qualifiedList[inputTxtName] = false;
                         }
                     }
                     else
                     {
                         tbAvgOfA.BackColor = Color.White;
                         if (flag == 0)
                         {
                             if (ThreadingForm.qualifiedList.ContainsKey(inputTxtName))
                                 ThreadingForm.qualifiedList[inputTxtName] = true;
                         }
                         else if (flag == 1) {
                             if (DetailForm.qualifiedList.ContainsKey(inputTxtName))
                                 DetailForm.qualifiedList[inputTxtName] = true;
                         }
                        
                     }
                     tbAvgOfA.Text = Convert.ToString(Math.Round(avg, 3));
                 }
                 //获取该测量项显示椭圆度的TextBox控件
                 //如果显示椭圆度的label控件存在
                 if (tbOvalityA != null)
                 {
                     float ovality = float.MaxValue;
                     //计算该测量项的椭圆度
                     if (sdVal!=0)
                       ovality = (Convert.ToSingle(txtMaxOfA.Text) - Convert.ToSingle(txtMinOfA.Text)) / sdVal;
                     //如果该测量项A端椭圆度不符合标准
                     if ((ovality > maxOvality || ovality < 0)&&ovality!=float.MaxValue)
                     {
                         //同上
                         tbOvalityA.BackColor = Color.LightCoral;
                         if (flag == 0)
                         {
                             if (ThreadingForm.qualifiedList.ContainsKey(inputTxtName))
                                 ThreadingForm.qualifiedList[inputTxtName] = false;
                         }
                         else if (flag == 1) {
                             if (DetailForm.qualifiedList.ContainsKey(inputTxtName))
                                 DetailForm.qualifiedList[inputTxtName] = false;
                         }
                     }
                     else
                     {
                         tbOvalityA.BackColor = Color.White;
                         if (flag == 0)
                         {
                             if (ThreadingForm.qualifiedList.ContainsKey(inputTxtName))
                                 ThreadingForm.qualifiedList[inputTxtName] = true;
                         }
                         else if (flag == 1) {
                             if (DetailForm.qualifiedList.ContainsKey(inputTxtName))
                                 DetailForm.qualifiedList[inputTxtName] = true;
                         }
                        
                     }
                     tbOvalityA.Text = Convert.ToString(Math.Round(ovality, 3));
                 }
             }
             //同上
             if (txtMaxOfB != null && !string.IsNullOrWhiteSpace(txtMaxOfB.Text)
                 && txtMinOfB != null && !string.IsNullOrWhiteSpace(txtMinOfB.Text))
             {
                 float avg = ((Convert.ToSingle(txtMaxOfB.Text) + Convert.ToSingle(txtMinOfB.Text)) / 2);
                 if (tbAvgOfB != null)
                 {
                     if (avg < minVal || avg > maxVal)
                     {
                         tbAvgOfB.BackColor = Color.LightCoral;
                         if (flag == 0)
                         {
                             if (ThreadingForm.qualifiedList.ContainsKey(inputTxtName))
                             {
                                 ThreadingForm.qualifiedList[inputTxtName] = false;
                             }
                         }
                         else if (flag == 1) {
                             if (DetailForm.qualifiedList.ContainsKey(inputTxtName))
                             {
                                 DetailForm.qualifiedList[inputTxtName] = false;
                             }
                         }
                        
                     }
                     else
                     {
                         tbAvgOfB.BackColor = Color.White;
                         if (flag == 0)
                         {
                             if (ThreadingForm.qualifiedList.ContainsKey(inputTxtName))
                                 ThreadingForm.qualifiedList[inputTxtName] = true;
                         }
                         else if (flag == 1)
                         {
                             if (DetailForm.qualifiedList.ContainsKey(inputTxtName))
                                 DetailForm.qualifiedList[inputTxtName] = true;
                         }
                        
                     }
                     tbAvgOfB.Text = Convert.ToString(Math.Round(avg, 3));
                 }
                 //判断椭圆度是否满足要求
                 if (tbOvalityB != null)
                 {
                     float ovality = float.MaxValue;
                     if(sdVal!=0)
                        ovality = (Convert.ToSingle(txtMaxOfB.Text) - Convert.ToSingle(txtMinOfB.Text)) / sdVal;
                     if ((ovality > maxOvality || ovality < 0)&&ovality!=float.MaxValue)
                     {
                         tbOvalityB.BackColor = Color.LightCoral;
                         if (flag == 0)
                         {
                             if (ThreadingForm.qualifiedList.ContainsKey(inputTxtName))
                                 ThreadingForm.qualifiedList[inputTxtName] = false;
                         }
                         else if (flag == 1)
                         {
                             if (DetailForm.qualifiedList.ContainsKey(inputTxtName))
                                 DetailForm.qualifiedList[inputTxtName] = false;
                         }
                        
                     }
                     else
                     {
                         tbOvalityB.BackColor = Color.White;
                         if (flag == 0)
                         {
                             if (ThreadingForm.qualifiedList.ContainsKey(inputTxtName))
                                 ThreadingForm.qualifiedList[inputTxtName] = true;
                         }
                         else if (flag == 1)
                         {
                             if (DetailForm.qualifiedList.ContainsKey(inputTxtName))
                                 DetailForm.qualifiedList[inputTxtName] = true;
                         }
                     }
                     tbOvalityB.Text = Convert.ToString(Math.Round(ovality, 3));
                 }
             }
         }
         catch (Exception ex)
         {
             //Console.WriteLine("英文键盘回车时出错,错误信息:" + ex.Message);
         }
         finally //跳转到下一个输入框
         {
             //查询鼠标焦点所在的TextBox控件在控件集合中的索引
             TextBox tb = null;int index =0;
             if (flag == 0)
             {
                 if (ThreadingForm.flpTabTwoTextBoxList != null)
                 {
                     index = ThreadingForm.flpTabTwoTextBoxList.IndexOf(inputTxt);
                     if (index != -1)
                     {
                         if (index < ThreadingForm.flpTabTwoTextBoxList.Count - 1)
                             index++;
                         if (ThreadingForm.flpTabTwoTextBoxList.Count > 0)
                             tb = ThreadingForm.flpTabTwoTextBoxList[index];
                     }
                 }
             }
             else if (flag == 1) {
                 if (DetailForm.flpTabTwoTextBoxList != null)
                 {
                     index = DetailForm.flpTabTwoTextBoxList.IndexOf(inputTxt);
                     if (index != -1)
                     {
                         if (index < DetailForm.flpTabTwoTextBoxList.Count - 1)
                             index++;
                         if (DetailForm.flpTabTwoTextBoxList.Count > 0)
                             tb = DetailForm.flpTabTwoTextBoxList[index];
                     }
                 }
             }
             //设置鼠标焦点在控件集合索引为index的控件上
             if (tb != null)
                 tb.Focus();
         }
     }
 }
Пример #16
0
 public void excuteDelteInspectionRecord(int index)
 {
     try
     {
         //获取删除选中行的检验记录编号
         object obj1 = this.dataGridView1.Rows[index].Cells["thread_inspection_record_code"].Value;
         if (obj1 == null)
         {
             MessagePrompt.Show("删除失败!");
             return;
         }
         string  thread_inspection_record_code = obj1.ToString();
         JObject jsonData = new JObject
         {
             { "thread_inspection_record_code", thread_inspection_record_code }
         };
         ASCIIEncoding  encoding = new ASCIIEncoding();
         String         content  = "";
         byte[]         data     = encoding.GetBytes(jsonData.ToString());
         string         url      = CommonUtil.getServerIpAndPort() + "ThreadingOperation/delThreadInspectionRecordOfWinform.action";
         HttpWebRequest request  = (HttpWebRequest)HttpWebRequest.Create(url);
         request.KeepAlive     = false;
         request.Method        = "POST";
         request.ContentType   = "application/json;characterSet:UTF-8";
         request.ContentLength = data.Length;
         using (Stream sm = request.GetRequestStream())
         {
             sm.Write(data, 0, data.Length);
         }
         HttpWebResponse response       = (HttpWebResponse)request.GetResponse();
         Stream          streamResponse = response.GetResponseStream();
         StreamReader    streamRead     = new StreamReader(streamResponse, Encoding.UTF8);
         Char[]          readBuff       = new Char[1024];
         int             count          = streamRead.Read(readBuff, 0, 1024);
         while (count > 0)
         {
             String outputData = new String(readBuff, 0, count);
             content += outputData;
             count    = streamRead.Read(readBuff, 0, 1024);
         }
         response.Close();
         string jsons = content;
         if (jsons == null)
         {
             MessagePrompt.Show("删除失败!");
             return;
         }
         JObject jobject  = JObject.Parse(jsons);
         string  rowsJson = jobject["rowsData"].ToString();
         if (rowsJson.Trim().Contains("{}"))
         {
             MessagePrompt.Show("删除失败!");
             return;
         }
         if (rowsJson.Contains("True"))
         {
             MessagePrompt.Show("删除成功!");
             //刷新检验记录列表(dataGridView)
             getThreadingProcessData();
         }
         else
         {
             MessagePrompt.Show("删除失败!");
         }
     }
     catch (Exception ex)
     {
         MessagePrompt.Show("删除失败,失败原因:" + ex.Message);
     }
 }
Пример #17
0
        private void button1_Click(object sender, EventArgs e)
        {
            //加密当前mac地址
            string verification_code = CommonUtil.Encrypt();
            //操作工工号
            string employee_no = this.txtLoginName.Text.Trim();
            //密码
            string upwd = this.txtLoginPwd.Text.Trim();

            this.button1.Text    = "登录中...";
            this.button1.Enabled = false;
            try
            {
                this.label_msg.Text = "发送登录请求。。。";
                //封装客户端登录所传数据
                JObject json = new JObject {
                    { "employee_no", employee_no },
                    { "ppassword", upwd },
                    { "verification_code", verification_code }
                };
                ASCIIEncoding  encoding = new ASCIIEncoding();
                String         content  = "";
                byte[]         data     = encoding.GetBytes(json.ToString());
                string         url      = CommonUtil.getServerIpAndPort() + "Login/userLoginOfWinform.action";
                HttpWebRequest request  = (HttpWebRequest)HttpWebRequest.Create(url);
                request.KeepAlive     = false;
                request.Method        = "POST";
                request.ContentType   = "application/json;characterSet:UTF-8";
                request.ContentLength = data.Length;
                using (Stream sm = request.GetRequestStream())
                {
                    sm.Write(data, 0, data.Length);
                }
                this.label_msg.Text = "登录验证中。。。";
                HttpWebResponse response       = (HttpWebResponse)request.GetResponse();
                Stream          streamResponse = response.GetResponseStream();
                using (StreamReader sr = new StreamReader(streamResponse))
                {
                    content = sr.ReadToEnd();
                }
                response.Close();
                if (content != null)
                {
                    //如果返回的数据为"{}"
                    this.label_msg.Text = "";
                    if (content.Trim().Contains("{}"))
                    {
                        this.label_msg.Text = "登录异常!";
                        MessagePrompt.Show("登录异常!");
                    }
                    else
                    {
                        //如果登录成功,返回的数据格式为{success:'True/False',msg:'',rowsData:''},rowsData存放的为当前登录用户的信息
                        JObject jobject   = JObject.Parse(content);
                        string  loginFlag = jobject["success"].ToString().Trim();
                        string  msg       = jobject["msg"].ToString().Trim();
                        if (loginFlag.Contains("True"))
                        {
                            string rowsJson = jobject["rowsData"].ToString();
                            if (rowsJson != null)
                            {
                                //登录成功返回当前登录用户的信息,将返回的json格式的信息转换成指定对象
                                this.label_msg.Text = "登录成功,初始化控件中...";
                                Person person = JsonConvert.DeserializeObject <Person>(rowsJson);
                                IndexWindow.getForm().Show();
                                NumberKeyboardForm.getForm();
                                AlphabetKeyboardForm.getForm();
                                ScanerHook.executeScanerHook();
                                this.Hide();
                            }
                            else
                            {
                                this.label_msg.Text = "系统繁忙,请稍后重试!";
                                MessagePrompt.Show("系统繁忙,请稍后重试!");
                            }
                        }
                        else
                        {
                            this.label_msg.Text = msg;
                            MessagePrompt.Show(msg);
                        }
                    }
                }
                this.button1.Enabled = true;
                this.button1.Text    = "登录";
            }
            catch (WebException ex) {
                MessagePrompt.Show("网络错误,错误信息:" + ex.Message);
                this.button1.Enabled = true;
                this.button1.Text    = "登录";
            }
            catch (Exception ec)
            {
                MessagePrompt.Show("连接服务器失败,失败原因:" + ec.Message);
                this.button1.Enabled = true;
                this.button1.Text    = "登录";
            }
        }
Пример #18
0
 private IndexWindow()
 {
     InitializeComponent();
     try
     {
         //获取模糊查询所需要的参数
         getSearchParam();
         //获取螺纹检验记录
         getThreadingProcessData();
         //设置datagridView字体
         this.dataGridView1.RowsDefaultCellStyle.Font = new Font("宋体", 18, FontStyle.Bold);
         DataGridViewCellStyle style = new DataGridViewCellStyle();
         style.Font = new Font("宋体", 18, FontStyle.Bold);
         //设置datagridView列和头部样式
         foreach (DataGridViewColumn col in this.dataGridView1.Columns)
         {
             col.HeaderCell.Style = style;
         }
         this.dataGridView1.EnableHeadersVisualStyles = false;
         myForm = this;
         //开启上传视频线程
         thread = new Thread(UploadVideo);
         thread.Start();
         thread.IsBackground = true;
     }
     catch (Exception e)
     {
         //thread.Abort();
     }
     finally {
         try
         {
             //初始化录像窗体
             MainWindow.getForm();
             //开启录像机
             if (MainWindow.recordStatus == 0)
             {
                 MainWindow.getForm().btnLogin_Click(null, null);
             }
             if (MainWindow.recordStatus == 1)
             {
                 MainWindow.getForm().btnPreview_Click_1(null, null);
             }
             //初始化读码器窗体
             YYKeyenceReaderConsole.getForm();
             //连接读码器
             if (YYKeyenceReaderConsole.readerStatus == 0)
             {
                 YYKeyenceReaderConsole.codeReaderConnect();
             }
             YYKeyenceReaderConsole.getForm().Show();
             YYKeyenceReaderConsole.getForm().Hide();
             //开启读码器,此处开启无法读码
             //if (YYKeyenceReaderConsole.readerStatus == 1)
             //    YYKeyenceReaderConsole.codeReaderLon();
             //初始化螺纹检验表单窗体
             ThreadingForm.getMyForm();
         }
         catch (Exception ex) {
             MessagePrompt.Show("初始化窗体异常,异常信息:" + ex.Message);
         }
     }
 }
Пример #19
0
 private void btnDetail_Click(object sender, EventArgs e)
 {
     try
     {
         //当前dataGridView(数据显示控件)选中行的索引
         int    index = this.dataGridView1.CurrentRow.Index;
         string operator_no = "", thread_inspection_record_code = "", coupling_heat_no = "", coupling_lot_no = "", production_line = "", machine_no = "", coupling_no = "",
                production_crew = "", production_shift = "", contract_no = "", inspection_result = "", videoNo = "", inspection_time = "";
         //获取选中行的数据
         object obj0  = this.dataGridView1.Rows[index].Cells["operator_no"].Value;
         object obj1  = this.dataGridView1.Rows[index].Cells["thread_inspection_record_code"].Value;
         object obj2  = this.dataGridView1.Rows[index].Cells["coupling_heat_no"].Value;
         object obj3  = this.dataGridView1.Rows[index].Cells["coupling_lot_no"].Value;
         object obj4  = this.dataGridView1.Rows[index].Cells["production_line"].Value;
         object obj5  = this.dataGridView1.Rows[index].Cells["machine_no"].Value;
         object obj6  = this.dataGridView1.Rows[index].Cells["coupling_no"].Value;
         object obj7  = this.dataGridView1.Rows[index].Cells["production_crew"].Value;
         object obj8  = this.dataGridView1.Rows[index].Cells["production_shift"].Value;
         object obj9  = this.dataGridView1.Rows[index].Cells["contract_no"].Value;
         object obj10 = this.dataGridView1.Rows[index].Cells["inspection_result"].Value;
         object obj11 = this.dataGridView1.Rows[index].Cells["video_no"].Value;
         object obj12 = this.dataGridView1.Rows[index].Cells["inspection_time"].Value;
         object obj13 = this.dataGridView1.Rows[index].Cells["inspection_result"].Value;
         if (obj0 != null)
         {
             operator_no = Convert.ToString(obj0);
         }
         if (obj1 != null)
         {
             thread_inspection_record_code = Convert.ToString(obj1);
         }
         if (obj2 != null)
         {
             coupling_heat_no = Convert.ToString(obj2);
         }
         if (obj3 != null)
         {
             coupling_lot_no = Convert.ToString(obj3);
         }
         if (obj4 != null)
         {
             production_line = Convert.ToString(obj4);
         }
         if (obj5 != null)
         {
             machine_no = Convert.ToString(obj5);
         }
         if (obj6 != null)
         {
             coupling_no = Convert.ToString(obj6);
         }
         if (obj7 != null)
         {
             production_crew = Convert.ToString(obj7);
         }
         if (obj8 != null)
         {
             production_shift = Convert.ToString(obj8);
         }
         if (obj9 != null)
         {
             contract_no = Convert.ToString(obj9);
         }
         if (obj10 != null)
         {
             inspection_result = Convert.ToString(obj10);
         }
         if (obj11 != null)
         {
             videoNo = Convert.ToString(obj11);
         }
         if (obj12 != null)
         {
             inspection_time = Convert.ToString(obj12);
         }
         if (obj13 != null)
         {
             inspection_result = Convert.ToString(obj13);
         }
         //将选中行的数据填充到DetailForm中对应的控件上
         DetailForm form = new DetailForm(operator_no, thread_inspection_record_code);
         form.txtProductionArea.Text           = production_line;
         form.txtMachineNo.Text                = machine_no;
         form.txtOperatorNo.Text               = operator_no;
         form.txtCoupingNo.Text                = coupling_heat_no;
         form.txtBatchNo.Text                  = coupling_lot_no;
         form.txtCoupingNo.Text                = coupling_no;
         form.cmbProductionCrew.SelectedIndex  = form.cmbProductionCrew.Items.IndexOf(production_crew);
         form.cmbProductionShift.SelectedIndex = form.cmbProductionShift.Items.IndexOf(production_shift);
         form.txtHeatNo.Text         = coupling_heat_no;
         form.txtBatchNo.Text        = coupling_lot_no;
         form.tbContractNo.Text      = contract_no;
         form.videoNoArr             = videoNo;
         form.lblresult1.Text        = inspection_result;
         form.lblresult2.Text        = inspection_result;
         form.lblInspectionTime.Text = inspection_time;
         form.video_url = videoNo;
         form.Show();
     }
     catch (Exception ex)
     {
         MessagePrompt.Show("打开检验记录时出错,错误信息:" + ex.Message);
     }
 }