public static DDesignFile SelectById(int ID) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; SqlConnection connection = new SqlConnection(Atend.Control.ConnectionString.ServercnString); SqlCommand command = new SqlCommand("D_DesignFile_SelectById", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("iId", ID)); DDesignFile dDesignFile = new DDesignFile(); try { connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { dDesignFile.DesignId = Convert.ToInt32(reader["DesignId"].ToString()); dDesignFile.File = (byte[])(reader["File"]); dDesignFile.Id = Convert.ToInt32(reader["Id"]); dDesignFile.Image = (byte[])(reader["Image"]); dDesignFile.Book = (byte[])(reader["BooK"]); } else { dDesignFile.id = -1; } reader.Close(); connection.Close(); } catch (System.Exception ex1) { //Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage(string.Format(" ERROR DDesignFile.SelectByDesignCode {0}\n", ex1.Message)); connection.Close(); } return dDesignFile; }
//frmDesignSearch //frmSaveDesignServer public static DDesignFile SelectByDesignId(SqlTransaction _transaction, SqlConnection _connection, int DesignId) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; //ed.WriteMessage("Start SelectByDesignCode\n"); SqlConnection connection = _connection; SqlCommand command = new SqlCommand("D_DesignFile_SelectByDesignId", connection); command.CommandType = CommandType.StoredProcedure; command.Transaction = _transaction; command.Parameters.Add(new SqlParameter("iDesignId", DesignId)); DDesignFile dDesignFile = new DDesignFile(); try { SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { dDesignFile.DesignId = Convert.ToInt32(reader["DesignId"].ToString()); try { dDesignFile.File = (byte[])(reader["File"]); } catch { dDesignFile.File = new byte[0]; } dDesignFile.Id = Convert.ToInt32(reader["Id"]); try { dDesignFile.Image = (byte[])(reader["Image"]); } catch { dDesignFile.Image = new byte[0]; } try { dDesignFile.Book = (byte[])(reader["Book"]); } catch { dDesignFile.Book = new byte[0]; } } else { dDesignFile.Id = -1; } reader.Close(); } catch (System.Exception ex1) { //Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage(string.Format(" ERROR DDesignFile.SelectByDesignCode {0}\n", ex1.Message)); } return dDesignFile; }