コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Deny normal user access
            if (Session["userType"].ToString() == Reference.USR_MEM)
            {
                /* string script = "alert('You do not have access to the page.');";
                 * ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true); */

                ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('You do not have access to this page'); window.location='" +
                                                    Request.ApplicationPath + "ProfileInfo.aspx';", true);
            }

            if (!IsPostBack)
            {
                if (Session["userType"].ToString() == Reference.USR_ADM)
                {
                    Billboard            BillboardObj = new Billboard();
                    Billboard_Management bDao         = new Billboard_Management();
                    //Company CompanyObj = new Company();
                    // Company_Management CDao = new Company_Management();

                    BillboardObj = bDao.getBillboardByID(Session["BillboardID"].ToString());
                    latitude     = BillboardObj.latitude;
                    longtitude   = BillboardObj.Longtitude;
                    //CompanyObj = CDao.getCompanyByID(Session["CompanyID"].ToString());
                    Database db = new Database();
                    //SqlCommand cmd = new SqlCommand("select CodeValue,CodeDesc from CodeReferece where CodeType=Industry ");
                    //DataTable dt = db.getDataTable(cmd);
                    //CoIndustry.DataSource = dt;
                    //CoIndustry.DataValueField = "CodeValue";
                    //CoIndustry.DataTextField = "CodeDesc";
                    //CoIndustry.DataBind();
                    //CoIndustry.Items.Insert(0, new ListItem("---Select An Industry---", "0"));
                    SqlCommand cmd = new SqlCommand("select CodeValue,CodeDesc from CodeReferece where CodeType='Country' ");
                    DataTable  dt  = db.getDataTable(cmd);
                    BBCountry.DataSource     = dt;
                    BBCountry.DataValueField = "CodeValue";
                    BBCountry.DataTextField  = "CodeDesc";
                    BBCountry.DataBind();
                    BBCountry.Items.Insert(0, new ListItem("---Select A Country---", "0"));


                    BBAddLn1.Text           = BillboardObj.AddressLn1;
                    BBAddLn2.Text           = BillboardObj.AddressLn2;
                    BBCity.Text             = BillboardObj.City;
                    BBCountry.SelectedValue = BillboardObj.Country;
                    BBLatitude.Text         = BillboardObj.latitude;
                    BBLongtitude.Text       = BillboardObj.Longtitude;

                    BBPostalCode.Text = BillboardObj.postalCode;
                }
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Billboard            BillboardObj = new Billboard();
                Billboard_Management bDao         = new Billboard_Management();
                //Company CompanyObj = new Company();
                // Company_Management CDao = new Company_Management();

                BillboardObj = bDao.getBillboardByID(Session["BillboardID"].ToString());
                latitude     = BillboardObj.latitude;
                longtitude   = BillboardObj.Longtitude;
                //CompanyObj = CDao.getCompanyByID(Session["CompanyID"].ToString());
                Database db = new Database();
                //SqlCommand cmd = new SqlCommand("select CodeValue,CodeDesc from CodeReferece where CodeType=Industry ");
                //DataTable dt = db.getDataTable(cmd);
                //CoIndustry.DataSource = dt;
                //CoIndustry.DataValueField = "CodeValue";
                //CoIndustry.DataTextField = "CodeDesc";
                //CoIndustry.DataBind();
                //CoIndustry.Items.Insert(0, new ListItem("---Select An Industry---", "0"));
                SqlCommand cmd = new SqlCommand("select CodeValue,CodeDesc from CodeReferece where CodeType='Country' ");
                DataTable  dt  = db.getDataTable(cmd);
                BBCountry.DataSource     = dt;
                BBCountry.DataValueField = "CodeValue";
                BBCountry.DataTextField  = "CodeDesc";
                BBCountry.DataBind();
                BBCountry.Items.Insert(0, new ListItem("---Select A Country---", "0"));


                BBAddLn1.Text           = BillboardObj.AddressLn1;
                BBAddLn2.Text           = BillboardObj.AddressLn2;
                BBCity.Text             = BillboardObj.City;
                BBCountry.SelectedValue = BillboardObj.Country;
                BBLatitude.Text         = BillboardObj.latitude;
                BBLongtitude.Text       = BillboardObj.Longtitude;

                BBPostalCode.Text = BillboardObj.postalCode;
            }
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Billboard            BillboardObj = new Billboard();
                Billboard_Management bDao         = new Billboard_Management();

                BillboardObj = bDao.getBillboardByID(Session["BillboardID"].ToString());
                latitude     = BillboardObj.latitude;
                longtitude   = BillboardObj.Longtitude;
                this.BindGrid();
            }

            try
            {
                var rowIndex    = 0;
                var hiddenvalue = (string)GridView1.DataKeys[rowIndex]["BillboardCode"];
                BillboardCodelabel.Text = " for " + hiddenvalue.ToString();
            }
            catch (System.ArgumentOutOfRangeException ArgumentOutOfRangeException)
            {
            }
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Deny normal user access
            if (Session["userType"].ToString() == Reference.USR_MEM)
            {
                /* string script = "alert('You do not have access to the page.');";
                 * ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true); */

                ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('You do not have access to this page'); window.location='" +
                                                    Request.ApplicationPath + "ProfileInfo.aspx';", true);
            }

            if (!IsPostBack)
            {
                if (Session["userType"].ToString() == Reference.USR_ADM)
                {
                    Billboard            BillboardObj = new Billboard();
                    Billboard_Management bDao         = new Billboard_Management();

                    BillboardObj = bDao.getBillboardByID(Session["BillboardID"].ToString());
                    latitude     = BillboardObj.latitude;
                    longtitude   = BillboardObj.Longtitude;
                    this.BindGrid();
                }
            }

            try
            {
                var rowIndex    = 0;
                var hiddenvalue = (string)GridView1.DataKeys[rowIndex]["BillboardCode"];
                BillboardCodelabel.Text = " for " + hiddenvalue.ToString();
            }
            catch (System.ArgumentOutOfRangeException ArgumentOutOfRangeException)
            {
            }
        }
コード例 #5
0
        protected void btnDelete_Command(object sender, CommandEventArgs e)
        {
            if (e.CommandName == "DeleteBBMessage")
            {
                SqlConnection conn   = null;
                SqlDataReader reader = null;



                // instantiate and open connection
                conn = new
                       SqlConnection(Reference.Constr);
                conn.Open();


                int index = Convert.ToInt32(e.CommandArgument);


                // Retrieve the row that contains the button
                // from the Rows collection.
                GridViewRow row        = GridView1.Rows[index];
                LinkButton  btnButton1 = sender as LinkButton;
                GridViewRow gvRow1     = (GridViewRow)btnButton1.NamingContainer;
                Billboard   bObj       = new Billboard();

                Billboard_Management bDao = new Billboard_Management();



                Label lb_msgId = (Label)gvRow1.FindControl("lb_BillboardID");

                bObj = bDao.getBillboardByID(lb_msgId.Text);
                string     BBCode   = bObj.BillboardCode;
                SqlCommand cmdcount = new SqlCommand("Select count(*) as total from BillboardLocation as b inner join AdvertisementLocation al on b.BillboardID=al.BillboardID inner join Advertisement a2 on" +
                                                     " al.AdvID=a2.AdvID where al.BillboardID=@ID and a2.status=1", conn);
                SqlParameter paramCount = new SqlParameter();
                paramCount.ParameterName = "@ID";
                paramCount.Value         = bObj.BillboardID.ToString();
                cmdcount.Parameters.Add(paramCount);
                SqlDataAdapter sdacount = new SqlDataAdapter();
                DataTable      dt       = new DataTable();
                cmdcount.Connection    = conn;
                sdacount.SelectCommand = cmdcount;
                sdacount.Fill(dt);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    int count = Convert.ToInt32(dt.Rows[i]["total"]);
                    if (count == 0)
                    {
                        Boolean insCnt = bDao.deleteBillboard(lb_msgId.Text);

                        //VIC: never inform if the delete is successful or not?
                        alertSuccess.Visible  = true;
                        DeleteFailure.Visible = false;
                        createSuccess.Visible = false;
                        updateSuccess.Visible = false;
                        msgSuccess.Text       = " Billboard #" + BBCode + " has been deleted successfully!";
                    }
                    else
                    {
                        DeleteFailure.Visible = true;
                        alertSuccess.Visible  = false;
                        createSuccess.Visible = false;
                        updateSuccess.Visible = false;
                        LabelError.Text       = "There are " + count + " Advertisement(s) in Billboard " + BBCode + ".Please delete existing advertisement(s) first before proceeding to delete the Billboard.";
                    }
                }



                Database db = new Database();

                SqlCommand cmd = new SqlCommand("Select * from [BillboardLocation] WHERE Status = 1");
                DataSet    ds  = db.getDataSet(cmd);

                //gvUser.DataSource = ds;
                GridView1.DataBind();
            }
        }