Пример #1
0
        public void SaveAlarm()
        {
            try
            {
                string    SQL = "select * from " + YBSetAlarm + " where GUIDSTR='" + ProDefine.g_SMExpermentParam.GUID.ToString() + "'";
                DataTable dt  = AccessHelper.GetDataTableFromDB(SQL);
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        SQL = "delete from " + YBSetAlarm + " where GUIDSTR='" + ProDefine.g_SMExpermentParam.GUID.ToString() + "'";
                        AccessHelper.ExcuteSql(SQL);
                    }
                    foreach (var info in ProDefine.g_YBAlarm)
                    {
                        string Timestr  = "";
                        string ValueStr = "";
                        string YbStr    = "";



                        SQL = "insert into " + YBSetAlarm + " Values('" + ProDefine.g_SMExpermentParam.GUID.ToString() + "','" + info.GNFcontion + "','" + info.AlarmH + "','"
                              + info.AlarmL + "','" + info.AlarmDataAbs + "','" + info.AlarmTimeAbs + "','')";
                        AccessHelper.ExcuteSql(SQL);
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Пример #2
0
 public void SaveYBChannelInfo()
 {
     try
     {
         string    SQL = "select * from " + YBChannelInfo + " where GUIDSTR='" + ProDefine.g_SMExpermentParam.GUID.ToString() + "'";
         DataTable dt  = AccessHelper.GetDataTableFromDB(SQL);
         if (dt != null)
         {
             if (dt.Rows.Count > 0)
             {
                 SQL = "delete from " + YBChannelInfo + " where GUIDSTR='" + ProDefine.g_SMExpermentParam.GUID.ToString() + "'";
                 AccessHelper.ExcuteSql(SQL);
             }
             foreach (var info in ProDefine.g_FunctionChannel)
             {
                 /*SQL = "insert into " + ChannelSetDBName + " Values('" + ProDefine.g_SMExpermentParam.GUID.ToString() + "','" + info.FunctionName + "','" + info.Duanzi + "','"
                  + info.Xianhao + "','" + info.hzZQ + "','" + info.PerReadNumber + "','" + info.ChannelType + "','" + info.channelNumber + "')";
                  + AccessHelper.ExcuteSql(SQL);*/
                 {
                     SQL = "insert into " + YBChannelInfo + " Values('" + ProDefine.g_SMExpermentParam.GUID.ToString() + "','" + info.IndexStr + "','" + info.FunctionName + "','"
                           + info.ChannelNumber.ToString() + "','" + info.YBNumber.ToString() + "','" + info.InfoType + "')";
                     AccessHelper.ExcuteSql(SQL);
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
     }
 }
Пример #3
0
        public void SaveChannelSetInfo()
        {
            try
            {
                string SQL = "select * from " + ChannelSetDBName + " where GUIDSTR='" + ProDefine.g_SMExpermentParam.GUID.ToString() + "'";

                DataTable dt = AccessHelper.GetDataTableFromDB(SQL);

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        SQL = "delete from " + ChannelSetDBName + " where GUIDSTR='" + ProDefine.g_SMExpermentParam.GUID.ToString() + "'";
                        AccessHelper.ExcuteSql(SQL);
                    }
                    foreach (var info in ProDefine.g_ChannelInfos)
                    {
                        SQL = "insert into " + ChannelSetDBName + " Values('" + ProDefine.g_SMExpermentParam.GUID.ToString() + "','" + info.IndexStr + "','" + info.FucntionName + "','"
                              + info.FunctionType + "','" + info.XianHao + "','" + info.Duanzi + "','" + info.Hz.ToString() + "','" + info.PerCount.ToString() + "','" + info.IsFunctionSelect.ToString() + "')";
                        AccessHelper.ExcuteSql(SQL);
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Пример #4
0
        public void SaveExpermentInfo(SMExpermentParam experParam)
        {
            try {
                string    SQL = "select * from " + ExperParmaDBName + " where GUIDSTR = '" + experParam.GUID.ToString() + "'";
                DataTable dt  = AccessHelper.GetDataTableFromDB(SQL);

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        SQL = "delete from " + ExperParmaDBName + " where GUIDSTR='" + ProDefine.g_SMExpermentParam.GUID.ToString() + "'";
                        AccessHelper.ExcuteSql(SQL);

                        //SQL = "update " + ExperParmaDBName + " set GUIDSTR='" + experParam.GUID.ToString() + "',ExpermentType='" + experParam.ExpermentType + "',YLType='" + experParam.YLType.ToString() + "',JSMode='"
                        //    + experParam.JSMode.ToString() + "',YLSetType='" + experParam.YLSetType.ToString() + "',CGTemperature='"+ experParam.CGTemperature + "',CGXDSD='" + experParam.CGXDSD + "',CPJXTemperature='" + experParam.CPJXTemperature + "',CPJXXDSD='" + experParam.CPJXXDSD
                        //    + "',YLNumber='" + experParam.YLNumber + "',YBNumber='" + experParam.YBNumber + "',JWType='" + experParam.JWType + "',CGZD='" + experParam.CGZD + "',CGDYL='" + experParam.CGDYL + "',JXZD='" + experParam.JXZD + "',JXDYL='" + experParam.JXDYL + "' where GUIDSTR='" + experParam.GUID.ToString() + "'";
                    }

                    SQL = "insert into " + ExperParmaDBName + " values('" + experParam.GUID.ToString() + "','" + experParam.ExpermentType + "','" + experParam.YLType.ToString() + "','"
                          + experParam.JSMode.ToString() + "','" + experParam.YLSetType.ToString() + "','" + experParam.CGTemperature + "','" + experParam.CGXDSD + "','" + experParam.CPJXTemperature + "','" + experParam.CPJXXDSD
                          + "','" + experParam.YLNumber + "','" + experParam.YBNumber + "','" + experParam.JWType + "','" + experParam.CGZD + "','" + experParam.CGDYL + "','" + experParam.JXZD + "','" + experParam.JXDYL + "')";


                    AccessHelper.ExcuteSql(SQL);
                }
            }
            catch { }
        }
Пример #5
0
        public void DelProFromList(ProjectInfo pro)
        {
            try {
                string SQL = "delete from " + ProjectInfoDBName + " where ProjectName='" + pro.ProjectName + "'";

                AccessHelper.ExcuteSql(SQL);
            }
            catch {
            }
        }
Пример #6
0
 public bool ChangeProjectInfo(ProjectInfo pro)
 {
     try {
         string SQL = "update " + ProjectInfoDBName + " set ProjectName='" + pro.ProjectName + "',ProductName='" + pro.ProductName + "',ProductGN='" + pro.ProductGN + "',ProductUse='"
                      + pro.ProductUse + "',ExperTime='" + pro.ExperTime + "',ExperAddress='" + pro.ExperAddress + "' where GUIDSTR='" + pro.GUID.ToString() + "'";
         if (AccessHelper.ExcuteSql(SQL) > 0)
         {
             return(true);
         }
         return(false);
     }
     catch {
         return(true);
     }
 }
Пример #7
0
        public void SaveYBSetSignelOut()
        {
            try
            {
                string    SQL = "select * from " + YBSetOutSignle + " where GUIDSTR='" + ProDefine.g_SMExpermentParam.GUID.ToString() + "'";
                DataTable dt  = AccessHelper.GetDataTableFromDB(SQL);
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        SQL = "delete from " + YBSetOutSignle + " where GUIDSTR='" + ProDefine.g_SMExpermentParam.GUID.ToString() + "'";
                        AccessHelper.ExcuteSql(SQL);
                    }
                    foreach (var info in ProDefine.g_YBSetSignleOut)
                    {
                        string Timestr  = "";
                        string ValueStr = "";
                        string YbStr    = "";
                        foreach (var kkk in info.m_TimeList)
                        {
                            Timestr = Timestr + kkk.ToString() + ",";
                        }
                        foreach (var kkk in info.m_ValueList)
                        {
                            ValueStr = ValueStr + kkk.ToString() + ",";
                        }

                        Timestr  = Timestr.Substring(0, Timestr.Length - 1);
                        ValueStr = ValueStr.Substring(0, ValueStr.Length - 1);


                        SQL = "insert into " + YBSetOutSignle + " Values('" + ProDefine.g_SMExpermentParam.GUID.ToString() + "','" + info.GNFunction + "','" + Timestr + "','"
                              + ValueStr + "','','" + info.SetType.ToString() + "')";
                        AccessHelper.ExcuteSql(SQL);
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Пример #8
0
   private void button1_Click(object sender, EventArgs e)
   {
       // 更新  
           try  
           {  
               //UPDATE Person SET Address = 'Zhongshan 23', City = 'Nanjing'WHERE LastName = 'Wilson'  
               string sql = "update ycyx set fwhm='"+textBox1.Text+"',khmc='"+textBox2.Text+"',gsdq='"+textBox3.Text+"',dqpp='"+textBox4.Text+  
                   "',dqtc='"+textBox5.Text+"',dqzt='"+textBox6.Text+"' where ID="+iid;  
                     
 
               int ret = achelp.ExcuteSql(sql);  
               if (ret > -1)  
               {  
                   this.Hide();  
                   MessageBox.Show("更新成功", "查询");  
               }  
           }  
           catch (Exception ex)  
           {  
               MessageBox.Show(ex.Message);  
           }  
   }
Пример #9
0
        public void SaveExpermentDesign()
        {
            try {
                string SQL = "select * from " + ExperDesignDBName + " where GUIDSTR='" + ProDefine.g_SMExpermentParam.GUID.ToString() + "'";

                DataTable dt = AccessHelper.GetDataTableFromDB(SQL);

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        SQL = "delete from " + ExperDesignDBName + " where GUIDSTR='" + ProDefine.g_SMExpermentParam.GUID.ToString() + "'";
                        AccessHelper.ExcuteSql(SQL);
                    }
                    foreach (var info in ProDefine.g_SMExpermentDesin.ExpParamList)
                    {
                        SQL = "insert into " + ExperDesignDBName + " Values('" + ProDefine.g_SMExpermentParam.GUID.ToString() + "','" + info.Temperature + "','" + info.SD + "','"
                              + info.YBNumber + "','" + info.ExpermentTime + "')";
                        AccessHelper.ExcuteSql(SQL);
                    }
                }
            }
            catch { }
        }
Пример #10
0
        //保存按钮
        private void button7_Click(object sender, EventArgs e)
        {
            //进行处理
            string stuName       = textBox1.Text.Trim();
            string stuSex        = textBox2.Text.Trim();
            string idCardNum     = textBox3.Text.Trim();
            string stuId         = textBox4.Text.Trim();
            string stuDept       = textBox5.Text.Trim();
            string stuProfession = textBox6.Text.Trim();
            string stuClass      = textBox7.Text.Trim();
            string stuLevel      = textBox8.Text.Trim();
            string years         = textBox9.Text.Trim();
            string grade         = textBox10.Text.Trim();
            string graduateYear  = textBox11.Text.Trim();
            string isPay;
            //ID,用来区分是新增保存还是直接修改
            string ID = IDtextBox12.Text.Trim();

            if (radioButton1.Checked == true)
            {
                isPay = "1";
            }
            else
            {
                isPay = "0";
            }

            //其中,身份证号,姓名必填,其他依照需要选填
            if ("" == idCardNum)
            {
                MessageBox.Show("请输入身份证号!");
            }
            else if ("" == stuName)
            {
                MessageBox.Show("请输入学生姓名!");
            }
            //else if ("" == stuSex)
            //    MessageBox.Show("请输入学生性别!");
            else if (idCardNum.Trim().Trim().ToCharArray().Length != 18)
            {
                MessageBox.Show("身份证号输入有误!请重新输入!");
            }
            else
            {
                //先进行提示:
                MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
                DialogResult      dr         = MessageBox.Show("保存后不可删除,只可修改!确定要保存吗? ", "系统提示", messButton);
                if (dr == DialogResult.OK)//如果点击“确定”按钮
                {
                    Utils.AccessHelper accessHelper = new AccessHelper(Utils.FileUtils.ProjectPath + projectName + "\\dbf\\photoSystem.accdb");
                    if (string.IsNullOrEmpty(ID))
                    {           //说明此人没有进行编号,则进行新增保存操作
                        //查出数据库中最大的id
                        string maxIdSqlStr = "select Max(ID) from info";
                        //如果表中一条数据都没有,则执行结果为""
                        int maxId;
                        if (string.IsNullOrEmpty(accessHelper.GetDataTableFromDB(maxIdSqlStr).Rows[0][0].ToString()))
                        {
                            maxId = 1;
                        }
                        else
                        {
                            maxId = int.Parse(accessHelper.GetDataTableFromDB(maxIdSqlStr).Rows[0][0].ToString()) + 1;
                        }
                        string isPhoto  = "1";  //已照相
                        string isManual = "1";  //手动输入标记
                        //新增之后立马输出这个学生的身份证,姓名,照片编号,代表此学生已经照相
                        string sqlStr = string.Format("Insert into info (" +
                                                      "ID , stuName,	stuSex,	idCardNum,	stuID,	stuDepartment,	stuProfession,	stuClass,	stuLevel,	years,   grade, graduateYear,	isPay ,isPhoto , isManual"+
                                                      ") Values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}')", maxId, stuName, stuSex, idCardNum, stuId, stuDept, stuProfession, stuClass, stuLevel, years, grade, graduateYear, isPay, isPhoto, isManual);
                        accessHelper.ExcuteSql(sqlStr);
                        //清空textbox框,避免多次点击按钮时会插入多次
                        clearTextbox();
                        //进行弹窗照相操作
                        string showStr = idCardNum + "\n" + stuName + "\n" + maxId;
                        MessageBox.Show(showStr);
                    }
                    else        //说明此人有编号,则进行修改保操作操作
                    {
                        string sqlStr = string.Format("update info set  stuName = '{0}', stuSex = '{1}', idCardNum = '{2}', stuID = '{3}', stuDepartment = '{4}', stuProfession = '{5}', stuClass = '{6}', stuLevel = '{7}', years = '{8}', grade = '{9}', graduateYear = '{10}', isPay = '{11}' where ID = {12}",
                                                      stuName, stuSex, idCardNum, stuId, stuDept, stuProfession, stuClass, stuLevel, years, grade, graduateYear, isPay, ID);
                        accessHelper.ExcuteSql(sqlStr);
                    }

                    //更新table表
                    string sqlStr1 = "select * from info where ID <> 0 order by ID desc;";//筛选出数据库中编号不为0和空的数据
                    dataTable = accessHelper.GetDataTableFromDB(sqlStr1);
                    //设置datagridview的数据源
                    dataGridView1.DataSource = dataTable;
                    //第一行显示为红色
                    dataGridView1.Rows[0].DefaultCellStyle.BackColor = Color.Red;
                }
            }
        }
Пример #11
0
        private void readCard()
        {
            if (this.InvokeRequired)
            {
                delegateReadCard drc = new delegateReadCard(readCard);
                this.Invoke(drc);
            }
            else
            {
                try
                {
                    //int len = 0;
                    StringBuilder Name        = new StringBuilder(31);
                    StringBuilder Gender      = new StringBuilder(3);
                    StringBuilder Folk        = new StringBuilder(10);
                    StringBuilder BirthDay    = new StringBuilder(9);
                    StringBuilder Code        = new StringBuilder(19);
                    StringBuilder Address     = new StringBuilder(71);
                    StringBuilder Agency      = new StringBuilder(31);
                    StringBuilder ExpireStart = new StringBuilder(9);
                    StringBuilder ExpireEnd   = new StringBuilder(9);
                    //StringBuilder directory = new StringBuilder(100);
                    StringBuilder pucFPMsg = new StringBuilder(1024);
                    StringBuilder pMsg     = new StringBuilder(100);


                    //如果有照片,先删除
                    if (File.Exists(System.Environment.CurrentDirectory + "\\photo.bmp"))
                    {
                        File.Delete(System.Environment.CurrentDirectory + "\\photo.bmp");
                    }
                    //读取信息,存照片
                    int ReadBaseInfosRet = DeviceUtils.ReadBaseInfos(Name, Gender, Folk, BirthDay, Code, Address, Agency, ExpireStart, ExpireEnd);  //读取信息同时会保存图片,
                    if (ReadBaseInfosRet != 1)
                    {
                        MessageBox.Show("身份证信息:读身份证失败");
                        DeviceUtils.CloseComm();
                        return;
                    }
                    else
                    {
                        //读取成功,此时照片被保存到bin//debug目录下
                        //挪动照片
                        if ((File.Exists(System.Environment.CurrentDirectory + "\\photo.bmp")) && (File.Exists(FileUtils.ProjectPath + projectName + "\\bmp\\" + Code + ".bmp")))
                        {
                            File.Copy(System.Environment.CurrentDirectory + "\\photo.bmp", FileUtils.ProjectPath + projectName + "\\bmp\\" + Code + ".bmp", true);
                            File.Delete(System.Environment.CurrentDirectory + "\\photo.bmp");
                        }
                        if ((File.Exists(System.Environment.CurrentDirectory + "\\photo.bmp")) && (!File.Exists(FileUtils.ProjectPath + projectName + "\\bmp\\" + Code + ".bmp")))
                        {
                            File.Move(System.Environment.CurrentDirectory + "\\photo.bmp", FileUtils.ProjectPath + projectName + "\\bmp\\" + Code + ".bmp");
                        }
                    }

                    Utils.AccessHelper accessHelper = new AccessHelper(Utils.FileUtils.ProjectPath + projectName + "\\dbf\\photoSystem.accdb");
                    //先判断已排除这种情况:此学生已经刷身份证了,在数据库中有信息,也已经编号,此时再次刷身份证,则提示已刷过请不要重复刷
                    DataTable d = accessHelper.GetDataTableFromDB("select * from info where idCardNum = '" + Code + "' and ID is not null ");
                    int       i = d.Rows.Count;
                    if (i != 0)       //存在已有信息且这个学生已编号的情况
                    {
                        MessageBox.Show("此学生已照相过,请勿重复刷身份证!");
                        return;
                    }
                    //查出数据库中最大的id
                    string maxIdSqlStr = "select Max(ID) from info";
                    //如果表中一条数据都没有,则执行结果为""
                    int maxId;
                    if (string.IsNullOrEmpty(accessHelper.GetDataTableFromDB(maxIdSqlStr).Rows[0][0].ToString()))
                    {
                        maxId = 1;
                    }
                    else
                    {
                        maxId = int.Parse(accessHelper.GetDataTableFromDB(maxIdSqlStr).Rows[0][0].ToString()) + 1;
                    }

                    //根据身份证去数据库查是否有这个学生的记录,
                    DataTable dataTable1 = accessHelper.GetDataTableFromDB("select * from info where idCardNum = '" + Code + "' ");
                    int       count      = dataTable1.Rows.Count;

                    //如果有:
                    if (count != 0)
                    {
                        //给次学生编号
                        accessHelper.ExcuteSql("update info set ID = " + maxId + " where idCardNum = '" + Code + "' ");
                    }
                    else
                    {
                        //数据库中没有此学生
                        //添加学生信息并编号
                        string isPhoto  = "1"; //已照相
                        string isManual = "0"; //手动输入标记
                        string isPay    = "0"; //未缴费
                        //新增之后立马输出这个学生的身份证,姓名,照片编号,代表此学生已经照相
                        string sqlStr = string.Format("Insert into info (" +
                                                      "ID , stuName,	stuSex,	idCardNum,	stuID,	stuDepartment,	stuProfession,	stuClass,	stuLevel,	years,   grade, graduateYear,	isPay ,isPhoto , isManual"+
                                                      ") Values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}')", maxId, Name, Gender, Code, "", "", "", "", "", "", "", "", isPay, isPhoto, isManual);
                        accessHelper.ExcuteSql(sqlStr);
                    }


                    //填充中间的姓名和照片编号
                    studentNameLabel.Text = Name.ToString();
                    PhotoNumberLabel.Text = maxId.ToString();
                    //展示身份证图片(先清除后展示)
                    //清除图片
                    pictureBox1.Image = null;
                    pictureBox2.Image = null;

                    //显示身份证图片和采集图片(如果有则显示)
                    //身份证图片绝对路径
                    string idCardPicture = Utils.FileUtils.ProjectPath + projectName + "\\bmp\\" + Code + ".bmp";
                    //采集照片的绝对路径
                    string photo = Utils.FileUtils.ProjectPath + projectName + "\\photo\\" + Code + ".JPG";

                    if (File.Exists(idCardPicture))
                    {
                        //pictureBox1.Image = Image.FromFile(idCardPicture);   会占用此图片
                        System.Drawing.Image img = System.Drawing.Image.FromFile(idCardPicture);
                        System.Drawing.Image bmp = new System.Drawing.Bitmap(img);
                        img.Dispose();
                        pictureBox1.Image = bmp;
                    }
                    if (File.Exists(photo))
                    {       /*pictureBox2.Load("d:\\DSC_7006.JPG");*/
                        //pictureBox2.Image = Image.FromFile(photo);
                        System.Drawing.Image img = System.Drawing.Image.FromFile(photo);
                        System.Drawing.Image bmp = new System.Drawing.Bitmap(img);
                        img.Dispose();
                        pictureBox2.Image = bmp;
                    }


                    //更新展示列表数据源
                    string sqlStr1 = "select * from info where ID <> 0 order by ID desc;";//筛选出数据库中编号不为0和空的数据
                    dataTable = accessHelper.GetDataTableFromDB(sqlStr1);
                    //设置datagridview的数据源
                    dataGridView1.DataSource = dataTable;
                    //第一行显示为红色
                    dataGridView1.Rows[0].DefaultCellStyle.BackColor = Color.Red;

                    //清除textbox
                    clearTextbox();

                    //进行弹窗照相操作
                    string showStr = Code + "\n" + Name + "\n" + maxId;
                    MessageBox.Show(showStr);
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }
        }