Пример #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)
                {
                    Company            CompanyObj = new Company();
                    Company_Management cDao       = new Company_Management();

                    CompanyObj = cDao.getCompanyByID(Session["CompanyID"].ToString());
                    this.BindGrid();
                }
            }

            try
            {
                var rowIndex    = 0;
                var hiddenvalue = (string)GridView1.DataKeys[rowIndex]["Name"];
                company_name_label.Text = " for " + hiddenvalue.ToString();
            }
            catch (System.ArgumentOutOfRangeException ArgumentOutOfRangeException)
            {
            }
        }
Пример #2
0
        //CoName=companynametextboxID
        //CoIndustry=companyIndustrytextboxID
        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)
                {
                    Company            CompanyObj = new Company();
                    Company_Management CDao       = new Company_Management();


                    CompanyObj = CDao.getCompanyByID(Session["CompanyID"].ToString());

                    CoName.Text = CompanyObj.Name;
                    CoIndustry.SelectedValue = CompanyObj.Industry;
                    Database   db  = new Database();
                    SqlCommand cmd = new SqlCommand("select * from CodeReferece where CodeType='Industry' ");
                    DataTable  dt  = db.getDataTable(cmd);
                    CoIndustry.DataSource     = dt;
                    CoIndustry.DataValueField = "CodeValue";
                    CoIndustry.DataTextField  = "CodeValue";
                    CoIndustry.DataBind();
                    CoIndustry.Items.Insert(0, new ListItem("---Select An Industry---", "0"));
                }
            }
        }
        //CoName=companynametextboxID
        //CoIndustry=companyIndustrytextboxID
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Company            CompanyObj = new Company();
                Company_Management CDao       = new Company_Management();


                CompanyObj = CDao.getCompanyByID(Session["CompanyID"].ToString());

                CoName.Text = CompanyObj.Name;
                CoIndustry.SelectedValue = CompanyObj.Industry;
                Database   db  = new Database();
                SqlCommand cmd = new SqlCommand("select * from CodeReferece where CodeType='Industry' ");
                DataTable  dt  = db.getDataTable(cmd);
                CoIndustry.DataSource     = dt;
                CoIndustry.DataValueField = "CodeValue";
                CoIndustry.DataTextField  = "CodeValue";
                CoIndustry.DataBind();
                CoIndustry.Items.Insert(0, new ListItem("---Select An Industry---", "0"));
            }
        }
Пример #4
0
        protected void btnDelete_Command(object sender, CommandEventArgs e)
        {
            if (e.CommandName == "DeleteMessage")
            {
                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        = GridView3.Rows[index];
                LinkButton  btnButton1 = sender as LinkButton;
                GridViewRow gvRow1     = (GridViewRow)btnButton1.NamingContainer;

                Company            Obj  = new Company();
                Company_Management cDao = new Company_Management();

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

                Obj = cDao.getCompanyByID(lb_msgId.Text);

                SqlCommand   cmdCount    = new SqlCommand("select count(*) as total from Advertisement as a inner join Company as c on a.companyID=c.CompanyID where c.CompanyID=@ID and a.status=1", conn);
                string       CompanyName = Obj.Name;
                SqlParameter param1      = new SqlParameter();
                param1.ParameterName = "@ID";
                param1.Value         = Obj.CompanyID.ToString();
                cmdCount.Parameters.Add(param1);
                SqlDataAdapter sda1 = new SqlDataAdapter();
                DataTable      dt   = new DataTable();
                cmdCount.Connection = conn;
                sda1.SelectCommand  = cmdCount;
                sda1.Fill(dt);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    int count = (Convert.ToInt32(dt.Rows[i]["total"]));
                    if (count == 0)
                    {
                        Boolean insCnt = cDao.deleteCompany(lb_msgId.Text);
                        //VIC: never inform if the delete is successful or not?
                        alertSuccess.Visible  = true;
                        DeleteError.Visible   = false;
                        createSuccess.Visible = false;
                        updateSuccess.Visible = false;
                        msgSuccess.Text       = CompanyName + " Has Been Deleted Successfully!";
                    }
                    else
                    {
                        DeleteError.Visible   = true;
                        alertSuccess.Visible  = false;
                        createSuccess.Visible = false;
                        updateSuccess.Visible = false;
                        DeleteLabel.Text      = "Hi, there is/are still " + count + " advertisement(s) under " + CompanyName + ". Please delete existing advertisement(s) first before proceeding to delete the company.";
                    }
                }



                Database db = new Database();

                SqlCommand cmd = new SqlCommand("Select * from [Company] where Status = 1");

                //  cmd.Parameters.AddWithValue("@paraType", (string)Session["userType"]);
                DataSet ds = db.getDataSet(cmd);


                GridView3.DataBind();
            }
        }