예제 #1
0
        public static DDesignProfile SelectByID(int ID)
        {
            SqlConnection connection = new SqlConnection(Atend.Control.ConnectionString.ServercnString);
            SqlCommand    command    = new SqlCommand("B_DesignProfile_SelectByCode", connection);

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("iCode", ID));
            DDesignProfile DP = new DDesignProfile();

            try
            {
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    DP.Id         = Convert.ToInt32(reader["Id"].ToString());
                    DP.DesignId   = Convert.ToInt32(reader["DesignId"].ToString());
                    DP.DesignName = reader["DesignName"].ToString();
                    DP.DesignCode = Convert.ToString(reader["DesignCode"]);
                    DP.Scale      = Convert.ToSingle(reader["Scale"].ToString());
                    DP.DesignDate = Convert.ToDateTime(reader["DesignDate"].ToString());
                    DP.Address    = reader["Address"].ToString();
                    DP.Zone       = Convert.ToInt32(reader["Zone"].ToString());
                    DP.Validate   = reader["Validate"].ToString();
                    DP.Employer   = reader["Employer"].ToString();
                    DP.Adviser    = reader["Adviser"].ToString();
                    DP.Designer   = reader["Designer"].ToString();
                    DP.Controller = reader["Controller"].ToString();
                    DP.Supporter  = reader["Supporter"].ToString();
                    DP.Approval   = reader["Approval"].ToString();
                    DP.Planner    = reader["Planner"].ToString();
                }
                else
                {
                    DP.id         = -1;
                    DP.DesignCode = "";
                    DP.DesignName = "NONE";
                    DP.Scale      = 0;
                    Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
                    ed.WriteMessage(string.Format("No Record found for DesignCode : \n", ""));
                }
                reader.Close();
                connection.Close();
            }
            catch (System.Exception ex1)
            {
                Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
                ed.WriteMessage(string.Format("Error DDesignProfile.Select : {0} \n", ex1.Message));
                connection.Close();
            }
            return(DP);
        }
예제 #2
0
        //frmDesignSaveServer
        public static DDesignProfile AccessSelect(OleDbTransaction _transaction, OleDbConnection _connection)
        {
            Editor          ed         = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            OleDbConnection connection = _connection;
            OleDbCommand    command    = new OleDbCommand("D_DesignProfile_Select", connection);

            command.Transaction = _transaction;

            command.CommandType = CommandType.StoredProcedure;
            DDesignProfile DP = new DDesignProfile();

            //ed.WriteMessage("a2\n");
            try
            {
                OleDbDataReader reader = command.ExecuteReader();
                //ed.WriteMessage("a3\n");
                if (reader.Read())
                {
                    //ed.WriteMessage("a4\n");
                    DP.Id         = Convert.ToInt32(reader["Id"].ToString());
                    DP.DesignId   = Convert.ToInt32(reader["DesignId"].ToString());
                    DP.DesignName = reader["DesignName"].ToString();
                    DP.DesignCode = Convert.ToString(reader["DesignCode"]);
                    DP.Scale      = Convert.ToSingle(reader["Scale"].ToString());
                    try
                    {
                        DP.DesignDate = Convert.ToDateTime(reader["DesignDate"].ToString());
                    }
                    catch
                    {
                        DP.DesignDate = DateTime.Now;
                    }
                    DP.Address  = reader["Address"].ToString();
                    DP.Zone     = Convert.ToInt32(reader["Zone"].ToString());
                    DP.Validate = reader["Validate"].ToString();
                    ed.WriteMessage("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Validate:{0}\n", DP.Validate);
                    DP.Employer   = reader["Employer"].ToString();
                    DP.Adviser    = reader["Adviser"].ToString();
                    DP.Designer   = reader["Designer"].ToString();
                    DP.Controller = reader["Controller"].ToString();
                    DP.Supporter  = reader["Supporter"].ToString();
                    DP.Approval   = reader["Approval"].ToString();
                    DP.Edition    = reader["Edition"].ToString();
                    DP.Planner    = reader["Planner"].ToString();
                    //DP.AdditionalCode = Convert.ToInt32( reader["AdditionalCode"].ToString());
                    ed.WriteMessage("Record found \n");
                }
                else
                {
                    ed.WriteMessage("a5\n");
                    DP.Id         = 0;
                    DP.DesignId   = -1;
                    DP.DesignCode = "";
                    DP.DesignName = "NONE";
                    DP.Scale      = 0;
                    //Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
                    ed.WriteMessage(string.Format("No Record found for DesignCode  \n"));
                }
                reader.Close();
            }
            catch (System.Exception ex1)
            {
                ed.WriteMessage(string.Format("Error DDesignProfile.AccessSelect : {0} \n", ex1.Message));
            }
            return(DP);
        }