| Server IP : 172.67.214.117  /  Your IP : 172.70.80.15 Web Server : Microsoft-IIS/10.0 System : Windows NT WAVE 10.0 build 20348 (Windows Server 2016) AMD64 User : IWPD_458(indias) ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/inetpub/vhosts/indiasmartbazaar.com/pimsharyana.in/admin/ | 
| Upload File : | 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using DevExpress.Web;
public partial class admin_department_notice : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            getDatanotice();
        }
        if (Session["username"] != null)
        {
        }
        else
        {
            Response.Redirect("login.aspx");
        }
    }
    private void getDatanotice()
    {
        SqlCommand cmd = new SqlCommand("Select * from tbl_department_notice order by ID Desc", con);
        SqlDataAdapter DA = new SqlDataAdapter(cmd);
        DataTable Dt = new DataTable();
        DA.Fill(Dt);
        if (Dt.Rows.Count > 0)
        {
            ASPxGridView1.DataSource = Dt;
            ASPxGridView1.DataBind();
        }
    }
    protected void Page_Init(object sender, EventArgs e)
    {
        SqlCommand cmd = new SqlCommand("Select * from tbl_department_notice order by ID Desc", con);
        SqlDataAdapter DA = new SqlDataAdapter(cmd);
        DataTable Dt = new DataTable();
        DA.Fill(Dt);
        if (Dt.Rows.Count > 0)
        {
            ASPxGridView1.DataSource = Dt;
            ASPxGridView1.DataBind();
        }
    }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        SqlCommand cmd = new SqlCommand("SP_department_notice", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add("@heading", SqlDbType.NVarChar).Value = txtheading.Text;
        cmd.Parameters.Add("@department", SqlDbType.NVarChar).Value = drpdepartment.SelectedItem.Text;
        cmd.Parameters.Add("@notice_content", SqlDbType.NVarChar).Value = CKEditorControl1.Text;
        cmd.Parameters.Add("@localtime", SqlDbType.NVarChar).Value = DateTime.Now.ToString("dd-MM-yyyy hh:mm tt");
        con.Open();
        int RA = cmd.ExecuteNonQuery();
        con.Close();
        if (RA > 0)
        {
            txtheading.Text = string.Empty;
            CKEditorControl1.Text = string.Empty;
            lblsucess.Visible = true;
            lblfailed.Visible = false;
            getDatanotice();
        }
        else
        {
            lblfailed.Visible = true;
            lblsucess.Visible = false;
        }
    }
    protected void ASPxGridView1_RowCommand(object sender, DevExpress.Web.ASPxGridViewRowCommandEventArgs e)
    {
        if (e.CommandArgs.CommandName == "Delete")
        {
            var gv = sender as ASPxGridView;
            var id = gv.GetRowValues(e.VisibleIndex, new string[] { "ID" });
            
            SqlCommand cmd = new SqlCommand("SP_Delete_Department_notice", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@ID", SqlDbType.Int).Value = id;
            con.Open();
            int RA = cmd.ExecuteNonQuery();
            con.Close();
            if (RA > 0)
            {
                getDatanotice();
            }
        }
        else
        {
            if (e.CommandArgs.CommandName == "Edit")
            {
                var gv = sender as ASPxGridView;
                var id = gv.GetRowValues(e.VisibleIndex, new string[] { "ID" });
                Response.Redirect(string.Format("editdepartment_notice.aspx?ID={0}", id));
            }
        }
    }
}