Esempio n. 1
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            //******************************************
            //关闭软键盘
            //******************************************
            try
            {
                kbpr.Kill();
            }
            catch
            {
            }

            if (textBoxID.Text == "")
            {
                PublicClass.message  = "姓名或者工号不能为空!";
                messageboxForm       = new MessageBoxForm(1);
                messageboxForm.Owner = this;
                messageboxForm.ShowDialog();
                return;
            }
            if (textBoxPassword.Text == "")
            {
                PublicClass.message  = "密码不能为空!";
                messageboxForm       = new MessageBoxForm(1);
                messageboxForm.Owner = this;
                messageboxForm.ShowDialog();
                return;
            }
            //******************************************
            //查询数据库,验证登录账户,密码,及用户权限
            //******************************************
            sqlcmd   = "select * from clothemployeedetails where employeeID='" + textBoxID.Text + "'";
            mysqlcmd = getSqlCommand(sqlcmd, PublicClass.conn);
            mysqldr  = mysqlcmd.ExecuteReader();
            if (mysqldr.HasRows)
            {
                mysqldr.Read();
                {
                    if (mysqldr["Password"].ToString() == textBoxPassword.Text)
                    {
                        //登录成功
                        if (Convert.ToInt32(mysqldr["Authority"].ToString()) == 1)
                        {
                            //管理员模式
                            AdminForm adminForm = new AdminForm();
                            adminForm.ShowDialog();
                        }
                        else
                        {
                            if (Convert.ToInt32(mysqldr["Department"].ToString()) == 1)
                            {
                                //检测部门
                                //   DetectForm detectForm = new DetectForm();


                                PublicClass.detecterName = mysqldr["employeename"].ToString();

                                PublicClass.detecterID = textBoxID.Text;

                                MultiBoardSyncGrabDemoDlg form = new MultiBoardSyncGrabDemoDlg();
                                Application.Run(form);
                                // form.ShowDialog();
                            }
                            else
                            {
                                //销售部门
                                PublicClass.message  = "非检测部门员工不能操作设备!";
                                messageboxForm       = new MessageBoxForm(1);
                                messageboxForm.Owner = this;
                                messageboxForm.ShowDialog();
                                return;
                            }
                        }
                    }
                    else
                    {
                        PublicClass.message  = "密码错误!";
                        messageboxForm       = new MessageBoxForm(1);
                        messageboxForm.Owner = this;
                        messageboxForm.ShowDialog();
                    }
                }
                mysqldr.Close();
            }
            else
            {
                mysqldr.Close();
                sqlcmd   = "select * from clothemployeedetails where employeename='" + textBoxID.Text + "'";
                mysqlcmd = getSqlCommand(sqlcmd, PublicClass.conn);
                mysqldr  = mysqlcmd.ExecuteReader();
                if (mysqldr.HasRows)
                {
                    mysqldr.Read();
                    {
                        if (mysqldr["Password"].ToString() == textBoxPassword.Text)
                        {
                            //登录成功
                            if (Convert.ToInt32(mysqldr["Authority"].ToString()) == 1)
                            {
                                mysqldr.Close();
                                //管理员模式
                                AdminForm adminForm = new AdminForm();
                                adminForm.ShowDialog();
                                this.Hide();
                            }
                            else
                            {
                                if (Convert.ToInt32(mysqldr["Department"].ToString()) == 1)
                                {
                                    //检测部门
                                    this.Hide();
                                    //PublicClass.message = "初始化相机中";
                                    //messageboxForm = new MessageBoxForm(1,1000);
                                    //messageboxForm.Owner = this;
                                    //messageboxForm.ShowDialog();


                                    PublicClass.detecterID = mysqldr["employeeID"].ToString();


                                    PublicClass.detecterName = textBoxID.Text;
                                    MultiBoardSyncGrabDemoDlg form = new MultiBoardSyncGrabDemoDlg();

                                    form.Show();
                                    //System.Threading.Thread.Sleep(1000);
                                    // this.Close();
                                }
                                else
                                {
                                    //销售部门
                                    PublicClass.message  = "非检测部门员工不能操作设备!";
                                    messageboxForm       = new MessageBoxForm(1);
                                    messageboxForm.Owner = this;
                                    messageboxForm.ShowDialog();
                                    return;
                                }
                            }
                        }

                        else
                        {
                            PublicClass.message  = "密码错误!";
                            messageboxForm       = new MessageBoxForm(1);
                            messageboxForm.Owner = this;
                            messageboxForm.ShowDialog();
                        }
                    }
                }
                else
                {
                    PublicClass.message  = "工号或者姓名不存在!";
                    messageboxForm       = new MessageBoxForm(1);
                    messageboxForm.Owner = this;
                    messageboxForm.ShowDialog();
                }
                mysqldr.Close();
            }
        }
Esempio n. 2
0
        private void SQLForm_Load(object sender, EventArgs e)
        {
            /*************************************
            *  读取色差等级
            *************************************/

            PublicClass.conn = new MySqlConnection(PublicClass.mysqlcon);
            PublicClass.conn.Open();
            PublicClass.message = "数据库连接成功!";


            sqlcmd = "select * from clothaberrationgrad";
            //  sqlcmd = "select * from clothdetectresult where ClothNumber ='" + tempClothNumber + "'";
            mysqlcmd = getSqlCommand(sqlcmd, PublicClass.conn);
            //mysqlcmd.CommandType = CommandType.Text;

            //adastAdapter = new MySqlDataAdapter(mysqlcmd);
            //DataTable pdt = new DataTable();
            //adastAdapter.Fill(pdt);
            //this.dataGridView1.DataSource = pdt;



            mysqldr = mysqlcmd.ExecuteReader();
            if (mysqldr.HasRows)
            {
                while (mysqldr.Read())
                {
                    chromaticAberration1 = Convert.ToDouble(mysqldr["clothaberrationgrad1"].ToString());
                    chromaticAberration2 = Convert.ToDouble(mysqldr["clothaberrationgrad2"].ToString());
                    chromaticAberration3 = Convert.ToDouble(mysqldr["clothaberrationgrad3"].ToString());
                    chromaticAberration4 = Convert.ToDouble(mysqldr["clothaberrationgrad4"].ToString());

                    break;
                }
            }
            mysqldr.Close();

            button6.Text = "0.0-" + chromaticAberration4.ToString();
            button5.Text = chromaticAberration4.ToString() + "-" + chromaticAberration3.ToString();
            button4.Text = chromaticAberration3.ToString() + "-" + chromaticAberration2.ToString();
            button3.Text = chromaticAberration2.ToString() + "-" + chromaticAberration1.ToString();
            button2.Text = ">" + chromaticAberration1.ToString();

            string tempClothNumber = PublicClass.clothNumber;//"201911032321";d

            sqlcmd               = "select * from clothdetectreport where ClothNumber ='" + tempClothNumber + "'";
            mysqlcmd             = getSqlCommand(sqlcmd, PublicClass.conn);
            mysqlcmd.CommandType = CommandType.Text;

            adastAdapter = new MySqlDataAdapter(mysqlcmd);
            DataTable pdt = new DataTable();

            adastAdapter.Fill(pdt);
            this.dataGridView1.DataSource = pdt;

            DataTable savepdt = new DataTable();

            savepdt = GetDgvToTable(dataGridView1);



            ExportToExcel(savepdt, PublicClass.reportpath + "色差检测详细表.xls");
            // ExportToExcel(pdt, PublicClass.reportpath + "text1.xls");



            tabControl1.Enabled = true;
            tempClothNumber     = PublicClass.clothNumber; //查询布匹编号string
            float standardColor = 0;                       //定义标准色差

            /*************************************
            *  查询销售员工名字
            *************************************/
            string theSourceName = "";

            sqlcmd   = "select * from clothemployeedetails where employeeID in (select SourceID from clothdetectdetail where ClothNumber =" + tempClothNumber + ")";
            mysqlcmd = getSqlCommand(sqlcmd, PublicClass.conn);
            mysqldr  = mysqlcmd.ExecuteReader();
            if (mysqldr.HasRows)
            {
                while (mysqldr.Read())
                {
                    theSourceName = mysqldr["employeeName"].ToString();
                    break;
                }
            }
            mysqldr.Close();


            /*************************************
            *   查询操作员工名字
            *************************************/
            string theOperatorName = "";

            sqlcmd   = "select * from clothemployeedetails where employeeID in (select OperatorID from clothdetectdetail where ClothNumber =" + tempClothNumber + ")";
            mysqlcmd = getSqlCommand(sqlcmd, PublicClass.conn);
            mysqldr  = mysqlcmd.ExecuteReader();
            if (mysqldr.HasRows)
            {
                while (mysqldr.Read())
                {
                    theOperatorName = mysqldr["employeeName"].ToString();
                    break;
                }
            }
            mysqldr.Close();

            /*************************************
            *   查询布匹检测详情,并加载到tagPage2里面
            *************************************/
            tabPage2.Invalidate();
            sqlcmd   = "select * from clothdetectdetail where ClothNumber =" + tempClothNumber;
            mysqlcmd = getSqlCommand(sqlcmd, PublicClass.conn);
            mysqldr  = mysqlcmd.ExecuteReader();
            if (mysqldr.HasRows)
            {
                while (mysqldr.Read())
                {
                    try
                    {
                        standardColor = Convert.ToSingle(mysqldr["StandardColorLAB"].ToString());
                    }
                    catch
                    {
                    }
                    labelClothNumber.Text     = mysqldr["ClothNumber"].ToString();
                    labelBatchNumber.Text     = mysqldr["BatchNumber"].ToString();
                    labelClassNumber.Text     = mysqldr["ClothClassNumber"].ToString();
                    labelEquipmentNumber.Text = mysqldr["EquipmentNumber"].ToString();
                    labelVolumn.Text          = mysqldr["TotalVolumn"].ToString() + "-" + mysqldr["VolumnNumber"].ToString();
                    labelCylinderNumber.Text  = mysqldr["CylinderNumber"].ToString();
                    labelSource.Text          = theSourceName;
                    labelOperator.Text        = theOperatorName;
                    labelMeters.Text          = mysqldr["LabelMeters"].ToString();

                    labelActualMeters.Text = mysqldr["ActualMeters"].ToString();
                    labelActualM1.Text     = mysqldr["ActualMeters"].ToString();
                    labelActualM.Text      = mysqldr["ActualMeters"].ToString();

                    labelMaxWidth.Text  = mysqldr["MaxWidth"].ToString();
                    labelMinWidth.Text  = mysqldr["MinWidth"].ToString();
                    labelMeanWidth.Text = mysqldr["MeanWidth"].ToString();
                    labelDate.Text      = mysqldr["Date"].ToString().Split(' ')[0];
                    labelStartTime.Text = mysqldr["StartTime"].ToString();
                    labelEndTime.Text   = mysqldr["EndTime"].ToString();

                    labelStandardL.Text   = mysqldr["StandardColorL"].ToString();
                    labelStandardA.Text   = mysqldr["StandardColorA"].ToString();
                    labelStandardB.Text   = mysqldr["StandardColorB"].ToString();
                    labelStandardLAB.Text = mysqldr["StandardColorLAB"].ToString();
                    labelMaxDiffL.Text    = mysqldr["MaxLDiff"].ToString();
                    labelMaxDiffA.Text    = mysqldr["MaxADiff"].ToString();
                    labelMaxDiffB.Text    = mysqldr["MaxBDiff"].ToString();
                    labelMaxDiffLAB.Text  = mysqldr["MaxLABDiff"].ToString();

                    labelStandardL1.Text   = mysqldr["StandardColorL"].ToString();
                    labelStandardA1.Text   = mysqldr["StandardColorA"].ToString();
                    labelStandardB1.Text   = mysqldr["StandardColorB"].ToString();
                    labelStandardLAB1.Text = mysqldr["StandardColorLAB"].ToString();
                    labelMaxDiffL1.Text    = mysqldr["MaxLDiff"].ToString();
                    labelMaxDiffA1.Text    = mysqldr["MaxADiff"].ToString();
                    labelMaxDiffB1.Text    = mysqldr["MaxBDiff"].ToString();
                    labelMaxDiffLAB1.Text  = mysqldr["MaxLABDiff"].ToString();

                    labelDefectNumber.Text = mysqldr["DefectNumber"].ToString();
                    richTextBox1.Clear();
                    richTextBox1.AppendText(mysqldr["AberrationDetails"].ToString() + "\r\n");
                    richTextBox1.AppendText(mysqldr["DefectDetails"].ToString() + "\r\n");
                    label11.Text = "色差详情:" + mysqldr["AberrationDetails"].ToString() + "\r\n";
                    label1.Text  = "缺陷详情:" + mysqldr["DefectDetails"].ToString() + "\r\n";

                    try
                    {
                        actualMeters          = Convert.ToSingle(mysqldr["ActualMeters"].ToString());
                        qualifiedMeters       = Convert.ToSingle(mysqldr["QualifiedMeters"].ToString());
                        aberrationGrad1Meters = Convert.ToSingle(mysqldr["AberrationGrad1Meters"].ToString());
                        aberrationGrad2Meters = Convert.ToSingle(mysqldr["AberrationGrad2Meters"].ToString());
                        aberrationGrad3Meters = Convert.ToSingle(mysqldr["AberrationGrad3Meters"].ToString());
                        aberrationGrad4Meters = Convert.ToSingle(mysqldr["AberrationGrad4Meters"].ToString());
                        aberrationGrad5Meters = Convert.ToSingle(mysqldr["AberrationGrad5Meters"].ToString());
                    }
                    catch
                    {
                    }

                    ImagePath = mysqldr["ImagePath"].ToString();
                    break;
                }
                mysqldr.Close();
            }
            else
            {
                PublicClass.message  = "没有检测结果";
                messageboxForm       = new MessageBoxForm(1);
                messageboxForm.Owner = this;
                messageboxForm.ShowDialog();
                mysqldr.Close();
                return;
            }



            /*************************************
            *  遍历布匹检测详情数据库
            *************************************/

            sqlcmd   = "select * from clothdetectresult where ClothNumber ='" + tempClothNumber + "'";
            mysqlcmd = getSqlCommand(sqlcmd, PublicClass.conn);
            mysqldr  = mysqlcmd.ExecuteReader();

            int j = 0;

            while (mysqldr.Read())
            {
                // intervalMeter = Convert.ToSingle(mysqldr["IntervalMeter"].ToString());//获取间隔米数
                label40.Text = "每格米数:" + mysqldr["IntervalMeter"].ToString();
                // boxNumber = mysqldr.GetInt32("BoxNumber");

                ImageFiles.Add(mysqldr["ImagePath"].ToString());
                //double []boxColors = new double[10];
                double MaxDiff = 0;

                for (int i = 1; i <= 1; i++)
                {
                    double tempColor = mysqldr["Box" + i.ToString() + "Color"] == DBNull.Value ? 0 : Convert.ToSingle(mysqldr["Box" + i.ToString() + "Color"]);

                    double tempDiff = tempColor;
                    //Math.Abs(tempColor - standardColor);
                    if (tempDiff > MaxDiff)
                    {
                        MaxDiff = tempDiff;
                    }
                }



                MaxDiffList.Add(MaxDiff);
                j++;
            }
            mysqldr.Close();
            tabPage1.Invalidate();

            /***************************************
             * 查询布匹检测详情,将结果放到图片浏览界面
             *************************************/
            //int ImageNumber =Convert.ToInt32( Math.Ceiling(actualMeters / intervalMeter));

            int ImageNumber = ImageFiles.Count;


            trackBar1.Value = 0;
            if (ImageNumber > 0 && ImageFiles[0] != null)
            {
                trackBar1.Minimum = 0;
                trackBar1.Maximum = ImageNumber - 1;
                try
                {
                    //  pictureBox1.Image = Image.FromFile(ImageFiles[0]);
                    string tempstr   = System.IO.Path.GetDirectoryName(ImagePath);
                    string imageFile = ImageFiles[0];
                    //   int Index1 = imageFile.IndexOf(".jpg");
                    //  int Index2 = imageFile.IndexOf("-");
                    //   string currentMeter = imageFile.Substring(Index2, Index1 - Index2);
                    if (checkBox1.Checked == false)
                    {
                        pictureBox1.Image = Image.FromFile(tempstr + "\\检测图\\" + (trackBar1.Value + 1).ToString() + ".jpg");
                    }
                    else
                    {
                        pictureBox1.Image = Image.FromFile(tempstr + "\\原图\\" + (trackBar1.Value + 1).ToString() + ".jpg");
                    }

                    //   labelCurrentM.Text = labelActualMeters.Text + currentMeter;
                }
                catch (Exception ed)
                {
                }
            }
            else
            {
                trackBar1.Enabled = false;
            }

            tabPage5.Invalidate();

            /*************************************
            *  查询布匹检测详情,将结果放到图表里面
            *************************************/
            float qualifiedPercents   = (qualifiedMeters / actualMeters);
            float unQualifiedPercents = (actualMeters - qualifiedMeters) / actualMeters;

            List <string> xData = new List <string>()
            {
                "合格率:" + (qualifiedPercents * 100).ToString("0.00") + "%", "折损率:" + (unQualifiedPercents * 100).ToString("0.00") + "%"
            };
            List <float> yData = new List <float>()
            {
                float.Parse(qualifiedPercents.ToString("0.00")), float.Parse(unQualifiedPercents.ToString("0.00"))
            };

            //chart1.seri
            // chart1.Series[0].Points[0].Color  = Color.Green;

            chart1.Series[0]["PieLabelStyle"] = "Outside";
            chart1.Series[0]["PieLabelStyle"] = "Outside"; //将文字移到外侧
            chart1.Series[0]["PieLineColor"]  = "Black";   //绘制黑色的连线。
            chart1.Series[0].Points.DataBindXY(xData, yData);
            labelActualM.Text   = actualMeters.ToString("0.00") + "米";
            labelQulifiedM.Text = qualifiedMeters.ToString("0.00") + "米";
            labelLoseM.Text     = (actualMeters - qualifiedMeters).ToString("0.00") + "米";

            chart2.Series[0].Points.AddXY("色差等级1", aberrationGrad1Meters);
            chart2.Series[0].Points.AddXY("色差等级2", aberrationGrad2Meters);
            chart2.Series[0].Points.AddXY("色差等级3", aberrationGrad3Meters);
            chart2.Series[0].Points.AddXY("色差等级4", aberrationGrad4Meters);
            chart2.Series[0].Points.AddXY("色差等级5", aberrationGrad5Meters);
            chart2.Series[0].Points[0].Color = Color.Green;
            chart2.Series[0].Points[1].Color = Color.LimeGreen;
            chart2.Series[0].Points[2].Color = Color.YellowGreen;
            chart2.Series[0].Points[3].Color = Color.Orange;
            chart2.Series[0].Points[4].Color = Color.Red;

            chart2.ChartAreas[0].AxisY.TitleFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            chart2.ChartAreas[0].AxisY.Title     = "单位:米数";
            chart2.Series[0].IsValueShownAsLabel = true;
            chart2.Series[0].Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            tabPage4.Invalidate();
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                kbpr.Kill();
            }
            catch
            {
            }
            if (textBoxID.Text == "")
            {
                PublicClass.message  = "姓名或者工号不能为空!";
                messageboxForm       = new MessageBoxForm(1);
                messageboxForm.Owner = this;
                messageboxForm.ShowDialog();
                return;
            }

            if (textBoxOldPassword.Text == "" || textBoxNewPassword.Text == "" || textBoxNewPassword1.Text == "")
            {
                PublicClass.message  = "密码不能为空!";
                messageboxForm       = new MessageBoxForm(1);
                messageboxForm.Owner = this;
                messageboxForm.ShowDialog();
                return;
            }

            if (textBoxNewPassword.Text != textBoxNewPassword1.Text)
            {
                PublicClass.message  = "两次密码不一致!";
                messageboxForm       = new MessageBoxForm(1);
                messageboxForm.Owner = this;
                messageboxForm.ShowDialog();
                return;
            }
            sqlcmd   = "select * from clothemployeedetails where employeeID='" + textBoxID.Text + "'";
            mysqlcmd = getSqlCommand(sqlcmd, PublicClass.conn);
            mysqldr  = mysqlcmd.ExecuteReader();
            if (mysqldr.HasRows)
            {
                mysqldr.Read();
                if (mysqldr["Password"].ToString() == textBoxOldPassword.Text)
                {
                    ID = mysqldr["employeeID"].ToString();
                    //登录成功
                    logSucces = true;
                }
                else
                {
                    PublicClass.message  = "旧密码错误!";
                    messageboxForm       = new MessageBoxForm(1);
                    messageboxForm.Owner = this;
                    messageboxForm.ShowDialog();
                }
                mysqldr.Close();
            }
            else
            {
                mysqldr.Close();
                sqlcmd   = "select * from clothemployeedetails where employeename='" + textBoxID.Text + "'";
                mysqlcmd = getSqlCommand(sqlcmd, PublicClass.conn);
                mysqldr  = mysqlcmd.ExecuteReader();
                if (mysqldr.HasRows)
                {
                    mysqldr.Read();
                    if (mysqldr["Password"].ToString() == textBoxOldPassword.Text)
                    {
                        ID = mysqldr["employeeID"].ToString();
                        //登录成功
                        logSucces = true;
                    }
                    else
                    {
                        PublicClass.message  = "旧密码错误!";
                        messageboxForm       = new MessageBoxForm(1);
                        messageboxForm.Owner = this;
                        messageboxForm.ShowDialog();
                    }
                }
                else
                {
                    PublicClass.message  = "工号或者姓名不存在!";
                    messageboxForm       = new MessageBoxForm(1);
                    messageboxForm.Owner = this;
                    messageboxForm.ShowDialog();
                }
                mysqldr.Close();
            }
            if (logSucces)
            {
                DialogResult result = MessageBox.Show("确定修改密码?", "温馨提示", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    try
                    {
                        sqlcmd   = "update clothemployeedetails set password='******' where employeeID = " + ID;
                        mysqlcmd = getSqlCommand(sqlcmd, PublicClass.conn);
                        mysqlcmd.ExecuteNonQuery();
                        PublicClass.message  = "密码修改成功!";
                        messageboxForm       = new MessageBoxForm(1);
                        messageboxForm.Owner = this;
                        messageboxForm.ShowDialog();
                    }
                    catch
                    {
                        PublicClass.message  = "密码修改失败!";
                        messageboxForm       = new MessageBoxForm(1);
                        messageboxForm.Owner = this;
                        messageboxForm.ShowDialog();
                    }
                }
            }
            logSucces = false;
        }