Exemplo n.º 1
0
        public static DRemark SelectByCode(int Code)
        {
            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            SqlConnection Connection = new SqlConnection(Atend.Control.ConnectionString.LocalcnString);
            SqlCommand    command    = new SqlCommand("D_Remark_Select", Connection);

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("iCode", Code));
            Connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            DRemark       Rem    = new DRemark();

            if (reader.Read())
            {
                Rem.Code = Convert.ToInt16(reader["Code"].ToString());

                Rem.File = (byte[])(reader["File"]);
                Rem.Name = reader["Name"].ToString();
            }
            reader.Close();



            Connection.Close();
            return(Rem);
        }
Exemplo n.º 2
0
        //frmWordRemark
        public static DRemark AccessSelectByCode(int _Code)
        {
            Editor          ed         = Application.DocumentManager.MdiActiveDocument.Editor;
            OleDbConnection connection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString);
            OleDbCommand    command    = new OleDbCommand("D_Remark_SelectByCode", connection);

            command.CommandType = CommandType.StoredProcedure;

            command.Parameters.Add(new OleDbParameter("iCode", _Code));

            DRemark remark = new DRemark();

            try
            {
                connection.Open();
                OleDbDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    remark.Code = Convert.ToInt32(reader["Code"].ToString());

                    try
                    {
                        remark.File = (byte[])(reader["File"]);
                    }
                    catch
                    {
                        remark.File = new byte[0];
                    }
                }
                else
                {
                    remark.Code = -1;
                }
                reader.Close();
                connection.Close();
            }
            catch (System.Exception ex1)
            {
                ed.WriteMessage(string.Format(" ERROR DRemark.SelectByCode {0}\n", ex1.Message));
                connection.Close();
            }
            return(remark);
        }