/// <summary> /// ִ�д洢���̻�SQL��䣬������һ��DataTable /// </summary> /// <param name="strProcedureName">Ҫ��DataTable�Ĵ洢���̻�SQL���</param> /// <returns></returns> public DataTable ExcuteProcedure(string strProcedureName) { DataTable dt = new DataTable(); SqlConnection conn=null; try { conn = new SqlConnection(ConfigurationSettings.AppSettings.GetValues("connection")[0]); SqlDataAdapter sda = new SqlDataAdapter(strProcedureName, conn); DataSet ds = new DataSet(); conn.Open(); sda.Fill(ds); dt = ds.Tables[0]; sda.Dispose(); conn.Close(); conn.Dispose(); } catch (Exception ex) { Err MyErr = new Err(ex.Message.ToString()); } return dt; }
/// <summary> /// ִ��SQL��䣬���������� /// </summary> /// <param name="strSQL">��Ҫ���з���ֵ��SQL����洢����</param> public void ExcuteSqlReturnNull(string strSQL) { SqlConnection conn = null; try { conn = new SqlConnection(ConfigurationSettings.AppSettings.GetValues("connection")[0]); conn.Open(); SqlCommand comm = new SqlCommand(strSQL, conn); comm.ExecuteNonQuery(); comm.Dispose(); conn.Close(); conn.Dispose(); } catch (Exception ex) { Err MyErr = new Err(ex.Message.ToString()); } }
//������д�ļ� public void CreateFile() { //���Ŀ¼�����ڣ���Ŀ¼ if (!Directory.Exists(strFileRoot)) { Directory.CreateDirectory(strFileRoot); } //���Ҫ�������ļ������ڣ����ļ� if (!File.Exists(strFileRoot + "\\" + strFileDateTime + strFileName)) { try { FileStream fs = File.Create(strFileRoot+"\\" + strFileDateTime + strFileName); fs.Close(); //�����ļ��ɹ�֮�������������ļ��������� File.AppendAllText(strFileRoot+"\\" + strFileDateTime + strFileName, strContent, Encoding.Default); } catch (Exception ex) { Err e = new Err(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + ex.Message.ToString()); } } else { try { //����ļ����ڣ���ֱ���� File.AppendAllText(strFileRoot+"\\" + strFileDateTime + strFileName, strContent, Encoding.Default); } catch (Exception ex) { Err MyErr = new Err(ex.Message.ToString()); } } }
public void Return_MineID() { try { string MineIDPath = Application.StartupPath + "\\config\\mineSystem.xml"; XmlDocument doc = new XmlDocument(); doc.Load(MineIDPath); XmlNodeList xmlnodelist = doc.FirstChild.NextSibling.ChildNodes; for (int x = 0; x < xmlnodelist.Count;x++ ) { if (x == 0) { MyMineID = xmlnodelist[x].InnerText.ToString(); } else { FilePath = xmlnodelist[x].InnerText.ToString(); } } //MyMineID = doc.FirstChild.NextSibling.ChildNodes[0].ChildNodes[0].InnerText.ToString(); //FilePath = doc.FirstChild.NextSibling.ChildNodes[0].ChildNodes[1].InnerText.ToString(); } catch (Exception ex) { Err myErr = new Err(ex.Message.ToString()); } }
public void DataProduct() { string dt = DateTime.Now.ToString("yyyyMMddHHmmss"); string strStartProcessPath = Application.StartupPath + "\\config"; if (txtShow.Lines.Length > 27)//��ʾ�ı�����27�о���գ��������� { try { string[] strFilePath = Directory.GetFiles(strStartProcessPath); for (int x = 0; x < strFilePath.Length; x++) { if (strFilePath[x].IndexOf("mine.xml") >= 0) { MyXML mxml = new MyXML(strFilePath[x], dt, FilePath);//����ú����Ϣ�ļ� txtShow.Text = ""; txtShow.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ������������ ú����Ϣ�ļ�" + Environment.NewLine; } if (strFilePath[x].IndexOf("area.xml") >= 0) { MyXML mxml = new MyXML(strFilePath[x], dt, FilePath);//�������������ļ� txtShow.Text = ""; txtShow.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ������������ ���������ļ�" + Environment.NewLine; } if (strFilePath[x].IndexOf("trackline.xml") >= 0) { MyXML mxml = new MyXML(strFilePath[x], dt, FilePath);//���ɹ켣�߶����ļ� txtShow.Text = ""; txtShow.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ������������ �켣�߶����ļ�" + Environment.NewLine; } if (strFilePath[x].IndexOf("person.xml") >= 0) { MyXML mxml = new MyXML(strFilePath[x], dt, FilePath);//������Ա��Ϣ�ļ� txtShow.Text = ""; txtShow.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ������������ ��Ա��Ϣ�ļ�" + Environment.NewLine; } if (strFilePath[x].IndexOf("track.xml") >= 0) { MyXML mxml = new MyXML(strFilePath[x], dt, FilePath);//����Ԥ��켣�ļ� txtShow.Text = ""; txtShow.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ������������ Ԥ��켣�ļ�" + Environment.NewLine; } } } catch (Exception ex) { Err myErr = new Err(ex.Message.ToString()); } } else { try { string[] strFilePath = Directory.GetFiles(strStartProcessPath); for (int x = 0; x < strFilePath.Length; x++) { if (strFilePath[x].IndexOf("mine.xml") >= 0) { MyXML mxml = new MyXML(strFilePath[x], dt, FilePath);//����ú����Ϣ�ļ� txtShow.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ������������ ú����Ϣ�ļ�" + Environment.NewLine; } if (strFilePath[x].IndexOf("area.xml") >= 0) { MyXML mxml = new MyXML(strFilePath[x], dt, FilePath);//�������������ļ� txtShow.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ������������ ���������ļ�" + Environment.NewLine; } if (strFilePath[x].IndexOf("trackline.xml") >= 0) { MyXML mxml = new MyXML(strFilePath[x], dt, FilePath);//���ɹ켣�߶����ļ� txtShow.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ������������ �켣�߶����ļ�" + Environment.NewLine; } if (strFilePath[x].IndexOf("person.xml") >= 0) { MyXML mxml = new MyXML(strFilePath[x], dt, FilePath);//������Ա��Ϣ�ļ� txtShow.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ������������ ��Ա��Ϣ�ļ�" + Environment.NewLine; } if (strFilePath[x].IndexOf("track.xml") >= 0) { MyXML mxml = new MyXML(strFilePath[x], dt, FilePath);//����Ԥ��켣�ļ� txtShow.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ������������ Ԥ��켣�ļ�" + Environment.NewLine; } } } catch (Exception ex) { Err myErr = new Err(ex.Message.ToString()); } } }
private void Time5Second_Tick(object sender, EventArgs e) { try { //iCount20S++; iCount2M++; #region��2���Ӷ�ʱ����ʵʱ�����ļ��� if (iCount2M >= 24) { //DO.ReturnDataSet_ExcuteSQL("update Station_Head_Info set StationHeadNO=selfno"); if (DO.ReturnDataSet_ExcuteSQL("exec proc_SXLW_SSGC_Select").Tables[0].Rows.Count > 0) { //ʵʱ�����ļ�----ʱ���+RYSS MyDataTable MDT = new MyDataTable(DO.ReturnDataSet_ExcuteSQL("exec proc_SXLW_SSGC").Tables[0], DateTime.Now.ToString("yyyyMMddHHmmss"), "RYSS", "D:\\Location"); SetFormMainListBoxMsg(MDT.returnStr); intProcdutCount++; //lblResult.Text = "��ǰ������Ѿ�����ʵʱ�ļ� [ " + intProcdutCount.ToString() + " ] ��"; } else { MyDataTable MDT = new MyDataTable(new DataTable(), DateTime.Now.ToString("yyyyMMddHHmmss"), "RYSS", "D:\\Location"); intProcdutCount++; SetFormMainListBoxMsg(MDT.returnStr); } iCount2M = 0; } #endregion #region���жϻ�����Ϣ�Ƿ��Ѿ�������ȫ�� try { DO.ReturnDataSet_ExcuteSQL(" declare @MineNOss varchar(30) set @MineNOss=(select distinct( MineNO) from Parameter_Mine) update Parameter_OverEmployee set MineNO =@MineNOss " + " update Parameter_RT_OverTime set MineNO=@MineNOss update Parameter_SpecialWT_Exception set MineNO=@MineNOss " + " update Parameter_Station_Break set MineNO=@MineNOss update Parameter_TrackLine set MineNO=@MineNOss "); //if (FindFormByName()) //{ // return; //�������ÿ���Ϣ���ݲ�����ʵʱ�ļ� //} dsTemp = DO.ReturnDataSet_ExcuteSQL(" SELECT MineFullName FROM Parameter_Mine " + " SELECT AreaNO from Parameter_Area where AreaNO IS NOT NULL " + " SELECT StationName AS ��ϵͳ��վ FROM Parameter_Station WHERE StationNO=NULL OR StationName NOT IN(SELECT StationName FROM Parameter_Area_Station ) " + " UNION ALL SELECT StationHeadPlace AS ��ϵͳ��վ FROM Station_Head_Info WHERE SelfNO NOT IN (SELECT SerialNumber FROM Parameter_Station ) " + " SELECT PersonName FROM dbo.Parameter_Person WHERE MineNO='' OR IDCard ='' OR WorkPlace='' OR WorkType='' OR birthDay IS NULL "); if (dsTemp.Tables[0].Rows.Count < 1 || dsTemp.Tables[0].Rows[0][0].ToString() == "") { if (isMine == false) { Err myErr = new Err(" δ¼�����Ϣ������¼�����Ϣ��--��ʼʱ��" + DateTime.Now.ToString("yyyy-MM-dd HH:ss:mm")); isMine = true; MessageBox.Show("δ¼�����Ϣ������¼�����Ϣ��", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); } // return; } else { isMine = false; } if (dsTemp.Tables[1].Rows.Count < 1) { if (isArea == false) { Err myErr = new Err(" δ����������Ϣ��������������Ϣ��--��ʼʱ��" + DateTime.Now.ToString("yyyy-MM-dd HH:ss:mm")); isArea = true; MessageBox.Show("δ����������Ϣ��������������Ϣ��", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); } // return; } else { isArea = false; } if (dsTemp.Tables[2].Rows.Count > 0) { if (isStat == false) { Err myErr = new Err(" ��վ��Ϣ���ò�ȫ�������÷�վ��Ϣ��--��ʼʱ��" + DateTime.Now.ToString("yyyy-MM-dd HH:ss:mm")); isStat = true; MessageBox.Show(" ��վ��Ϣ���ò�ȫ�������÷�վ��Ϣ��", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); } //return; } else { isStat = false; } if (dsTemp.Tables[3].Rows.Count > 0) { if (isPeople == false) { Err myErr = new Err(" ��Ա��Ϣ���ò�ȫ����������Ա��Ϣ��--��ʼʱ��" + DateTime.Now.ToString("yyyy-MM-dd HH:ss:mm"));///// isPeople = true; MessageBox.Show("��Ա��Ϣ���ò�ȫ����������Ա��Ϣ��", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); } // return; } else { isPeople = false; } } catch { Err myErr = new Err("����ʵʱ����ǰ�жϴ���"); } #endregion DO.ReturnDataSet_ExcuteSQL(" Proc_SXLW_GZYC_ADD "); DO.ReturnDataSet_ExcuteSQL(" IF EXISTS( SELECT 1 FROM Parameter_SpecialWT_Exception WHERE DATEDIFF(ss, CheckReachStationTime,GETDATE()) >0 and DATEDIFF(ss, CheckReachStationTime,GETDATE()) <6 ) " + " BEGIN update Parameter_SpecialWT_Exception SET IsRead=0 WHERE state='�ٵ�' OR (DATEDIFF(ss, CheckReachStationTime,GETDATE()) >=0 OR state='δ��') END "); //5������ϵͳ�����쳣�ļ� #region��5������ϵͳ�����쳣�ļ��� //*******Czlt-2011-07-10**������վ���ϱ���*XTYC-ϵͳ�쳣**************************** int tempCount = DO.ReturnDataSet_ExcuteSQL("Proc_SXLW_XTYC_Select").Tables[0].Rows.Count; if (tempCount > 0) { //DataSet dsStnNO = DO.ReturnDataSet_ExcuteSQL(" select StationNO from Parameter_Station_Break PSB where PSB.IsRead = 0 order by StationNO "); if (_stnLastCount == tempCount) { //ϵͳ�����쳣�ļ�-----ʱ���+RYYC MyDataTable mt = new MyDataTable(DO.ReturnDataSet_ExcuteSQL("Proc_SXLW_XTYC").Tables[0], DateTime.Now.ToString("yyyyMMddHHmmss"), "RYYC", "D:\\Location"); intProcdutCount++; SetFormMainListBoxMsg(mt.returnStr); //lblResult.Text = "��ǰ������Ѿ�����ʵʱ�ļ� [ " + intProcdutCount.ToString() + " ] ��"; } } _stnLastCount = tempCount; #endregion //20������ʵʱ�ļ� #region��5������ʵʱ�ļ��� //***************Czlt-2011-07-10 ��ʱ��������****************Start**************** int rtOver = Convert.ToInt32(DO.ReturnDataSet_ExcuteSQL("Select count(1) from Parameter_RT_OverTime where OverTimeEndTime is null").Tables[0].Rows[0][0].ToString()); if (rtOverTime != rtOver) { if (DO.ReturnDataSet_ExcuteSQL("exec Proc_SXLW_SSCS_Select") != null && DO.ReturnDataSet_ExcuteSQL("exec Proc_SXLW_SSCS_Select").Tables.Count > 0) { if (DO.ReturnDataSet_ExcuteSQL("exec Proc_SXLW_SSCS_Select").Tables[0].Rows.Count > 0) { //��ʱ�����ļ�-----ʱ���+RYSC MyDataTable MYT = new MyDataTable(DO.ReturnDataSet_ExcuteSQL("exec Proc_SXLW_SSCS").Tables[0], DateTime.Now.ToString("yyyyMMddHHmmss"), "RYCS", "D:\\Location"); intProcdutCount++; SetFormMainListBoxMsg(MYT.returnStr); //lblResult.Text = "��ǰ������Ѿ�����ʵʱ�ļ� [ " + intProcdutCount.ToString() + " ] ��"; } } rtOverTime = rtOver; } //***************Czlt-2011-07-10 ��ʱ��������****************End****************** int InOut = Convert.ToInt32(DO.ReturnDataSet_ExcuteSQL("Select count(1) from parameter_OverEmployee where AlarmEndTime is null").Tables[0].Rows[0][0].ToString()); if (InOut != dtInOutMine) { if (DO.ReturnDataSet_ExcuteSQL("exec Proc_SXLW_SSCY_Select").Tables[0].Rows.Count > 0) { //��Ա/�������������ļ�-----ʱ���+RYCY MyDataTable mdt = new MyDataTable(DO.ReturnDataSet_ExcuteSQL("exec Proc_SXLW_SSCY").Tables[0], DateTime.Now.ToString("yyyyMMddHHmmss"), "RYCYXZ", "D:\\Location"); intProcdutCount++; SetFormMainListBoxMsg(mdt.returnStr); //lblResult.Text = "��ǰ������Ѿ�����ʵʱ�ļ� [ " + intProcdutCount.ToString() + " ] ��"; } dtInOutMine = InOut; } if (DO.ReturnDataSet_ExcuteSQL("exec Proc_SXLW_GZYC_Select").Tables[0].Rows.Count > 0) { //������ҵ��Ա�����쳣-----ʱ���+RYTZ MyDataTable md = new MyDataTable(DO.ReturnDataSet_ExcuteSQL("exec Proc_SXLW_GZYC").Tables[0], DateTime.Now.ToString("yyyyMMddHHmmss"), "RYTZYC", "D:\\Location"); intProcdutCount++; SetFormMainListBoxMsg(md.returnStr); //lblResult.Text = "��ǰ������Ѿ�����ʵʱ�ļ� [ " + intProcdutCount.ToString() + " ] ��"; } #endregion } catch { //*********************Czlt-2011-05-19 ���ݿ����Ӳ���*Start**************************************** try { strMessage = DO.CheckConIsOpen(); lblMessage.Text = strMessage; } catch { lblMessage.Text = "���ݿ������쳣������������Ϣ��"; //*******Czlt-2011-05-05 ȡ����¼����******** this.MainPanel.Visible = true; IsLogin = true; return; } //*******************Czlt-2011-05-19 ���ݿ����Ӳ���*End***************************************** } }
public void GetStationFile() { string strStartProcessPath = Application.StartupPath + "\\config"; string dt = DateTime.Now.ToString("yyyyMMddHHmmss"); if (txtShow.Lines.Length > 27)//��ʾ�ı�����27�о���գ��������� { try { string[] strFilePath = Directory.GetFiles(strStartProcessPath); for (int x = 0; x < strFilePath.Length; x++) { if (strFilePath[x].IndexOf("station.xml") >= 0) { MyXMLToDataSet mxml = new MyXMLToDataSet(strFilePath[x], dt, FilePath);//ʱʱ���·�վ������Ϣ txtShow.Text = ""; txtShow.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ������������ ��վ/�켣�������ļ�" + Environment.NewLine; } } } catch (Exception ex) { Err myErr = new Err(ex.Message.ToString()); } } else { try { string[] strFilePath = Directory.GetFiles(strStartProcessPath); for (int x = 0; x < strFilePath.Length; x++) { if (strFilePath[x].IndexOf("station.xml") >= 0) { MyXMLToDataSet mxml = new MyXMLToDataSet(strFilePath[x], dt, FilePath);//ʱʱ���·�վ������Ϣ txtShow.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ������������ ��վ/�켣�������ļ�" + Environment.NewLine; } } } catch (Exception ex) { Err myErr = new Err(ex.Message.ToString()); } } }
public int RunProcedure(string storedProcName, IDataParameter[] parameters) { int intRowsCount = 0; using (SqlConnection connection = new SqlConnection(StrConnection)) { try { connection.Open(); SqlCommand command = BuildIntCommand(connection, storedProcName, parameters); intRowsCount = command.ExecuteNonQuery(); connection.Close(); command.Dispose(); connection.Dispose(); } catch (Exception ex) { Err err = new Err(storedProcName + ": " + ex.Message.ToString()); } } return intRowsCount; }
public int ReturnInt_ExcuteSQL(string strSQL) { int intI = 0; try { SqlConnection conn = new SqlConnection(StrConnection); conn.Open(); SqlCommand comm = new SqlCommand(strSQL, conn); intI = comm.ExecuteNonQuery(); comm.Dispose(); conn.Close(); conn.Dispose(); } catch (Exception EX) { Err err = new Err(strSQL + ": " + EX.Message.ToString()); } return intI; }
public DataSet ReturnDataSet_ExcuteSQL(string strSQL) { //������ݿ�����״̬ string strIsCon = CheckConIsOpen(); DataSet ds = new DataSet(); if (!strIsCon.Trim().Equals("���ݿ������쳣��")) { try { SqlConnection conn = new SqlConnection(StrConnection); SqlDataAdapter sda = new SqlDataAdapter(strSQL, conn); sda.Fill(ds); sda.Dispose(); } catch (Exception EX) { Err err = new Err(strSQL + ": " + EX.Message.ToString()); } } return ds; }
public DataSet GetUserPassWord(string UserName) { DataSet ds = new DataSet(); try { SqlConnection conn = new SqlConnection(StrConnection); string strSql = "select password from admins where Account='" + UserName + "'"; SqlDataAdapter sda = new SqlDataAdapter(strSql, conn); sda.Fill(ds); sda.Dispose(); conn.Dispose(); } catch (Exception ex) { Err err = new Err(UserName + ": " + ex.Message.ToString()); } return ds; }
/// <summary> /// ��ȡú�������Ϣ /// </summary> /// <returns></returns> public DataSet GetMineInfo() { //������ݿ�����״̬ string strIsCon = CheckConIsOpen(); DataSet ds = new DataSet(); if (!strIsCon.Trim().Equals("���ݿ������쳣��")) { string strSql = "select * from parameter_Mine"; try { SqlConnection conn = new SqlConnection(StrConnection); SqlDataAdapter sda = new SqlDataAdapter(strSql, conn); sda.Fill(ds); sda.Dispose(); } catch (Exception ex) { Err err = new Err(strSql + ": " + ex.Message.ToString()); } } return ds; }