protected void btnThem_Click(object sender, EventArgs e)
        {
            Tin t = new Tin();

            if (txtMaTin.Text == "")
            {
                Response.Write("<script>alert('" + "Bạn chưa nhập mã tin!" + "')</script>");
                txtMaTin.Focus();
            }
            else
            {
                if (txtTieuDe.Text == "")
                {
                    Response.Write("<script>alert('" + "Bạn chưa nhập tiêu đề!" + "')</script>");
                    txtTieuDe.Focus();
                }
                else
                {
                    if (txtTomTat.Text == "")
                    {
                        Response.Write("<script>alert('" + "Bạn chưa nhập tóm tắt!" + "')</script>");
                        txtTomTat.Focus();
                    }
                    else
                    {
                        if (txtNgayDang.Text == "")
                        {
                            Response.Write("<script>alert('" + "Bạn chưa nhập ngày!" + "')</script>");
                            txtNgayDang.Focus();
                        }
                        else
                        {
                            if (CKEditorControl1.Text == "")
                            {
                                Response.Write("<script>alert('" + "Bạn chưa nhập nội dung!" + "')</script>");
                                CKEditorControl1.Focus();
                            }
                            else
                            {
                                if (txtHinhAnh.Text == "")
                                {
                                    Response.Write("<script>alert('" + "Bạn chưa nhập tên hình ảnh!" + "')</script>");
                                    upImages.Focus();
                                }
                                else
                                {
                                    if (txtLuotXem.Text == "")
                                    {
                                        Response.Write("<script>alert('" + "Bạn chưa nhập lượt xem!" + "')</script>");
                                        txtLuotXem.Focus();
                                    }
                                    else
                                    {
                                        if (txtTrangThai.Text == "")
                                        {
                                            Response.Write("<script>alert('" + "Bạn chưa nhập trạng thái!" + "')</script>");
                                            txtTrangThai.Focus();
                                        }
                                        else
                                        {
                                            t.MaTin     = txtMaTin.Text;
                                            t.TieuDe    = txtTieuDe.Text;
                                            t.TomTat    = txtTomTat.Text;
                                            t.NgayDang  = txtNgayDang.Text;
                                            t.NoiDung   = CKEditorControl1.Text;
                                            t.HinhAnh   = txtHinhAnh.Text;
                                            t.SoLanXem  = txtLuotXem.Text;
                                            t.TrangThai = txtTrangThai.Text;
                                            t.MaLoaiTin = ddlMaLoaiTin.SelectedValue;
                                            Response.Write("<script>alert('" + " Thêm thành công! " + "')</script>");
                                            tdal.ThemTin(t);
                                            Load();

                                            txtMaTin.Text         = "";
                                            txtTieuDe.Text        = "";
                                            txtTomTat.Text        = "";
                                            CKEditorControl1.Text = "";
                                            txtHinhAnh.Text       = "";
                                            txtNgayDang.Text      = "";
                                            txtLuotXem.Text       = "";
                                            txtTrangThai.Text     = "";
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
 public void ThemTin(Tin t)
 {
     tdal.ThemTin(t);
 }