Пример #1
0
        private bool Reinsert(ref CReport_Pipe pipe)
        {
            MySqlDataReader reader;
            MySqlCommand cmd = null;
            string strcmd = "INSERT INTO [Report_Pipe]([PipeID],[ReportPath]) values(" + pipe.PipeID + " ,'" + pipe.ReportPath + "')";
            try
            {
               
                connect.Open();
                cmd = new MySqlCommand();
                cmd.Connection = connect;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = strcmd;

                strcmd = "SELECT MAX([ID]) AS MAXID FROM [Report_Pipe]";
                cmd.ExecuteNonQuery();
                cmd.CommandText = strcmd;
                reader = cmd.ExecuteReader();
                reader.Read();
                pipe.ID = Convert.ToInt32(reader[0].ToString());
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("Pipe of Report error : " + ex.Message);
                return false;
            }
            return true;
        }
Пример #2
0
 public bool Delete_Report_Pipe(CReport_Pipe pipe)
 {
     List<string> listcmd = new List<string>();
     try
     {
         string cmd = "DELETE * FROM [Report_Pipe] where ID = " + pipe.ID;
         listcmd.Add(cmd);
         ExectueCmd(listcmd);
     }
     catch (System.Exception ex)
     {
         Console.WriteLine("Pipe of Pic error : " + ex.Message);
         return false;
     }
     return true;
 }
Пример #3
0
        private List<CReport_Pipe> Select(string cmd)
        {
            List<CReport_Pipe> listpipe = new List<CReport_Pipe>();
            MySqlCommand com;
            MySqlDataReader reader;

            try
            {
                if (ConnectionState.Closed == connect.State)
                    connect.Open();
                com = new MySqlCommand(cmd, connect);
                reader = com.ExecuteReader();
                while (reader.Read())
                {
                    CReport_Pipe pipe = new CReport_Pipe();
                    int i = 0;
                    string tmp;
                    pipe.ID = Convert.ToInt32(reader[i++].ToString());
                    tmp = reader[i++].ToString();
                    if (tmp != null && tmp.Length > 0)
                        pipe.PipeID = Convert.ToInt32(tmp);
                    pipe.ReportPath = reader[i++].ToString();
                    listpipe.Add(pipe);
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("Pipe of Pic error : " + ex.Message);
                return null;
            }
            finally
            {
                if(connect!=null)
                connect.Close();
            }
            return listpipe;
        }
Пример #4
0
        public bool Insert_Report_Pipe(ref CReport_Pipe pipe)
        {
            MySqlDataReader reader;
            MySqlCommand cmd = null;
            string strcmd = "INSERT INTO [Report_Pipe]([PipeID],[ReportPath]) values(" + pipe.PipeID + " ,'" + pipe.ReportPath + "')";
            try
            {
                if (ConnectionState.Closed == connect.State)
                {
                    connect.Open();
                    cmd = new MySqlCommand();
                    count = 0;
                }
                else if (count >= NUMBER)
                {
                    count = 0;
                    connect.Close();
                    mysqlcmd = new MySqlCommand();
                    cmd = mysqlcmd;
                    connect.Open();
                }
                else
                {
                    count++;
                    cmd = mysqlcmd.Clone();
                }
                cmd.Connection = connect;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = strcmd;

                strcmd = "SELECT MAX([ID]) AS MAXID FROM [Report_Pipe]";
                cmd.ExecuteNonQuery();
                cmd.CommandText = strcmd;
                reader = cmd.ExecuteReader();
                reader.Read();
                pipe.ID = Convert.ToInt32(reader[0].ToString());
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("Pipe of Report error : " + ex.Message);
                Console.WriteLine("Reinsert Report");
                connect.Close();
                return Reinsert(ref pipe);
            }
            finally
            {
                //connect.Close();
            }
            return true;
        }