コード例 #1
0
        public List <clsDirector> GetAllDirectors()
        {
            List <clsDirector> lst = new List <clsDirector>();

            using (SqlConnection conn = new SqlConnection(strConn))
            {
                conn.Open();

                using (SqlCommand cmd = new SqlCommand("TMR_USP_GetDirectors"))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection  = conn;

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        var info = new clsDirector();

                        info.strName = reader["DirectorName"].ToString();
                        info.strCNIC = reader["Cnic"].ToString();
                        info.id      = Convert.ToInt32(reader["ID"]);

                        lst.Add(info);
                    }
                    conn.Close();
                }
            }
            return(lst);
        }
コード例 #2
0
        public bool AddDirector(clsDirector info)
        {
            int st = 0;

            try
            {
                using (SqlConnection conn = new SqlConnection(strConn))
                {
                    conn.Open();

                    {
                        using (SqlCommand cmd = new SqlCommand("TMR_USP_AddDirector"))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Connection  = conn;
                            cmd.Parameters.AddWithValue("@DirectorName", info.strName);
                            cmd.Parameters.AddWithValue("@CNIC", info.strCNIC);

                            st = cmd.ExecuteNonQuery();
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex) { }
            if (st > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }