Example #1
0
        public static void LoadWriter(SqlDataReader reader)
        {
            while (reader.Read())
            {
                Writers writer = new Writers();

                writer.WriterID  = (int)reader["WriterID"];
                writer.FirstName = reader["FirstName"].ToString();
                writer.LastName  = reader["LastName"].ToString();

                writers.Add(writer);
            }
        }
        public static void LoadWriter(SqlDataReader reader)
        {
         
            while (reader.Read())
            {
                Writers writer = new Writers();

                writer.WriterID = (int)reader["WriterID"];
                writer.FirstName = reader["FirstName"].ToString();
                writer.LastName = reader["LastName"].ToString();

                writers.Add(writer);
            }
        }
Example #3
0
        public static Writers GetWriter(int id)
        {
            Writers writer = new Writers();

            SearchConnect();

            //string query = string.Format("select * from Writers where WriterID = {0}", id.ToString());
            //if (!DataBase.GetStateConnection())
            //{
            //    if (DataBase.GetSqlConnection().State == ConnectionState.Open)
            //    {
            //        SqlCommand command = new SqlCommand(query, DataBase.Sql);
            //        SqlDataReader reader = command.ExecuteReader();
            //        reader.Read();

            //        writer.WriterID = (int)reader["WriterID"];
            //        writer.FirstName = reader["FirstName"].ToString();
            //        writer.LastName = reader["LastName"].ToString();
            //        reader.Close();
            //    }
            //}
            //else
            //{
            //    SqlCommand command = new SqlCommand(query, DataBase.Sql);
            //    SqlDataReader reader = command.ExecuteReader();
            //    reader.Read();

            //    writer.WriterID = (int)reader["WriterID"];
            //    writer.FirstName = reader["FirstName"].ToString();
            //    writer.LastName = reader["LastName"].ToString();
            //    reader.Close();
            //}

            foreach (Writers wrt in WritersManager.Writers)
            {
                if (wrt.WriterID == id)
                {
                    writer = wrt;
                }
            }

            return(writer);
        }
        public static Writers GetWriter(int id)
        {
            Writers writer = new Writers();

            SearchConnect();

            //string query = string.Format("select * from Writers where WriterID = {0}", id.ToString());
            //if (!DataBase.GetStateConnection())
            //{
            //    if (DataBase.GetSqlConnection().State == ConnectionState.Open)
            //    {
            //        SqlCommand command = new SqlCommand(query, DataBase.Sql);
            //        SqlDataReader reader = command.ExecuteReader();
            //        reader.Read();

            //        writer.WriterID = (int)reader["WriterID"];
            //        writer.FirstName = reader["FirstName"].ToString();
            //        writer.LastName = reader["LastName"].ToString();
            //        reader.Close();
            //    }
            //}
            //else
            //{
            //    SqlCommand command = new SqlCommand(query, DataBase.Sql);
            //    SqlDataReader reader = command.ExecuteReader();
            //    reader.Read();

            //    writer.WriterID = (int)reader["WriterID"];
            //    writer.FirstName = reader["FirstName"].ToString();
            //    writer.LastName = reader["LastName"].ToString();
            //    reader.Close();
            //}

            foreach (Writers wrt in WritersManager.Writers)
            {
                if (wrt.WriterID == id)
                    writer = wrt;
            }

            return writer;
        }
Example #5
0
        public Form3(Writers wrt)
        {
            wrtrs = wrt;
            type = 2;
            InitializeComponent();
            for (int i = 0; i < 3; i++)
            {
                Label lb = new Label();
                lb.Location = new System.Drawing.Point(5, i * 20 + i * 2 + 5);
                lb.AutoSize = true;
                switch (i)
                {
                    case 0: lb.Text = "WriterID :"; break;
                    case 1: lb.Text = "First Name :"; break;
                    case 2: lb.Text = "Last Name :"; break;
                    default: break;
                }


                TextBox tB = new TextBox();
                tB.Location = new System.Drawing.Point(90, i * 20 + i * 2 + 5);
                tB.Size = new System.Drawing.Size(222, 20);
                //tB.ReadOnly = true;
                switch (i)
                {
                    case 0: tB.Text = wrt.WriterID.ToString(); tB.ReadOnly = true; break;
                    case 1: tB.Text = wrt.FirstName.ToString(); break;
                    case 2: tB.Text = wrt.LastName.ToString(); break;
                    default: break;
                }

                this.Controls.Add(lb);
                this.Controls.Add(tB);
                //Console.WriteLine("{0}: {1}", reader.GetName(i), reader[i]);
            }
        }
Example #6
0
 public Writer(Writers wrt, string fn, string ln)
 {
     writerFromList = wrt;
     firstLastName = fn + " " + ln;
 }