Esempio n. 1
0
        public NewsGroupFile GetNewsGroupFileByID(int Id)
        {
            NewsGroupFile _newsGroupFile = null;

            using (SqlConnection connection = GetConnection())
            {
                SqlCommand command = new SqlCommand("_NewsGroupFileGetByID", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@NewsGroupFileID", Id);
                connection.Open();
                using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    if (reader.Read())
                    {
                        _newsGroupFile = NewsGroupFileReader(reader);
                    }
                    else
                    {
                        throw new DataAccessException("Không tìm thấy tin");
                    }
                }
                command.Dispose();
            }
            return(_newsGroupFile);
        }
Esempio n. 2
0
    private void initControl(int Id)
    {
        if (Id > 0)
        {
            btn_add.Visible  = false;
            btn_edit.Visible = true;

            btn_add1.Visible  = false;
            btn_edit1.Visible = true;
            try
            {
                NewsGroupFileBSO newsgroupFileBSO = new NewsGroupFileBSO();
                NewsGroupFile    newsgroupFile    = newsgroupFileBSO.GetNewsGroupFileByID(Id);


                hddNewsGroupFileID.Value = Convert.ToString(newsgroupFile.NewsGroupFileID);
                hddNewsGroupID.Value     = Convert.ToString(newsgroupFile.NewsGroupID);
                hddFileName.Value        = newsgroupFile.FileName;
                txtFileName.Text         = newsgroupFile.FileName;
                txtTitle.Text            = newsgroupFile.Title;
            }
            catch (Exception ex)
            {
                clientview.Text = ex.Message.ToString();
            }
        }
        else
        {
            btn_edit.Visible = false;
            btn_add.Visible  = true;

            btn_edit1.Visible = false;
            btn_add1.Visible  = true;
        }
    }
Esempio n. 3
0
    protected void btn_add_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtFileName.Text == "")
            {
                ViewFiles(Convert.ToInt32(hddNewsGroupID.Value));
                clientview.Text = "Chưa có file đính kèm";
            }
            else
            {
                NewsGroupFile file = new NewsGroupFile();
                file = ReceiveHtml();


                NewsGroupFileBSO filesBSO = new NewsGroupFileBSO();
                filesBSO.CreateNewsGroupFile(file);


                ViewFiles(Convert.ToInt32(hddNewsGroupID.Value));
                clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Thêm mới thành công !</div>";
            }
        }
        catch (Exception ex)
        {
            clientview.Text = ex.Message.ToString();
        }
    }
Esempio n. 4
0
    private NewsGroupFile ReceiveHtml()
    {
        NewsGroupFile newsgroupFile = new NewsGroupFile();

        newsgroupFile.NewsGroupFileID = (hddNewsGroupFileID.Value != "") ? Convert.ToInt32(hddNewsGroupFileID.Value) : 0;
        newsgroupFile.NewsGroupID     = Convert.ToInt32(hddNewsGroupID.Value);
        newsgroupFile.Title           = txtTitle.Text;
        newsgroupFile.FileName        = (txtFileName.Text != "") ? txtFileName.Text : hddFileName.Value;

        return(newsgroupFile);
    }
Esempio n. 5
0
        private NewsGroupFile NewsGroupFileReader(SqlDataReader reader)
        {
            NewsGroupFile _newsGroupFile = new NewsGroupFile();

            _newsGroupFile.NewsGroupFileID = (int)reader["NewsGroupFileID"];
            _newsGroupFile.NewsGroupID     = (int)reader["NewsGroupID"];
            _newsGroupFile.FileName        = (string)reader["FileName"];
            _newsGroupFile.Title           = (string)reader["Title"];

            return(_newsGroupFile);
        }
Esempio n. 6
0
    protected void btn_edit_Click(object sender, EventArgs e)
    {
        try
        {
            NewsGroupFile file = new NewsGroupFile();
            file = ReceiveHtml();


            NewsGroupFileBSO filesBSO = new NewsGroupFileBSO();
            filesBSO.UpdateNewsGroupFile(file);


            ViewFiles(Convert.ToInt32(hddNewsGroupID.Value));
            clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Cập nhật thành công !</div>";
        }
        catch (Exception ex)
        {
            clientview.Text = ex.Message.ToString();
        }
    }
Esempio n. 7
0
 public void UpdateNewsGroupFile(NewsGroupFile _newsGroupFile)
 {
     using (SqlConnection connection = GetConnection())
     {
         SqlCommand command = new SqlCommand("_NewsGroupFileUpdate", connection);
         command.CommandType = CommandType.StoredProcedure;
         command.Parameters.AddWithValue("@Type", 1);
         command.Parameters.AddWithValue("@NewsGroupFileID", _newsGroupFile.NewsGroupFileID);
         command.Parameters.AddWithValue("@NewsGroupID", _newsGroupFile.NewsGroupID);
         command.Parameters.AddWithValue("@FileName", _newsGroupFile.FileName);
         command.Parameters.AddWithValue("@Title", _newsGroupFile.Title);
         connection.Open();
         if (command.ExecuteNonQuery() <= 0)
         {
             throw new DataAccessException("Không thể cập nhật hình ảnh");
         }
         else
         {
             command.Dispose();
         }
     }
 }
Esempio n. 8
0
        public void UpdateNewsGroupFile(NewsGroupFile _newsGroupFile)
        {
            NewsGroupFileDAO _newsGroupFileDAO = new NewsGroupFileDAO();

            _newsGroupFileDAO.UpdateNewsGroupFile(_newsGroupFile);
        }
Esempio n. 9
0
        public void CreateNewsGroupFile(NewsGroupFile _newsGroupFile)
        {
            NewsGroupFileDAO _newsGroupFileDAO = new NewsGroupFileDAO();

            _newsGroupFileDAO.CreateNewsGroupFile(_newsGroupFile);
        }