Exemple #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)
            {
            }
        }
Exemple #2
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 (Convert.ToInt32(Session["CoUpdate"]) == 2)
            {
                updateSuccess.Visible = true;
                Session.Remove("CoUpdate");
            }
            if (Convert.ToInt32(Session["CoCreate"]) == 2)
            {
                createSuccess.Visible = true;
                Session.Remove("CoCreate");
            }

            if (!IsPostBack)
            {
                Company_Management coMgmt = new Company_Management();
                DataTable          dt     = coMgmt.CoInfoRead();

                //GridView3.DataSource = dt;
                GridView3.DataBind();
            }
        }
        protected void SubmitBtn_Click(object sender, EventArgs e)
        {
            String   Industry    = (CoIndustry.SelectedItem.Value.ToString());
            String   CompanyName = CoName.Text.ToString();
            DateTime CreatedOn   = DateTime.Now;

            Company_Management coMgmt = new Company_Management();
            Boolean            result = coMgmt.CoInfoInsert(CompanyName, Industry, CreatedOn);

            // if (CoName.Text == "" || CoIndustry.SelectedValue == "")
            //{
            //    alertWarning.Visible = true;
            //    alertSuccess.Visible = false;

            //    warningLocation.Text = "Please ensure you have filled in all required fields";
            //}
            //else
            //{
            alertWarning.Visible          = false;
            alertSuccess.Visible          = true;
            CoName.Text                   = String.Empty;
            CoIndustry.SelectedItem.Value = "";
            Session["CoCreate"]           = 2;
            Response.Redirect("CompanyList.aspx");
            //}
        }
        protected void updateBtn_Click(object sender, EventArgs e)
        {
            if (CoName.Text == "" || CoIndustry.SelectedValue == "")
            {
                alertWarning.Visible = true;
                alertSuccess.Visible = false;
            }

            else
            {
                Company_Management cDAO        = new Company_Management();
                string             companyName = CoName.Text;
                string             Industry    = CoIndustry.SelectedItem.Value.ToString();
                string             lastUpdBy   = Session["userID"].ToString();
                string             lastUpdOn   = DateTime.Now.ToString("MM/dd/yyyy h:mm tt");
                Boolean            insCnt      = cDAO.CoInfoUpdate(Session["CompanyID"].ToString(), companyName, Industry, lastUpdBy, lastUpdOn);

                alertWarning.Visible          = false;
                alertSuccess.Visible          = true;
                CoName.Text                   = String.Empty;
                CoIndustry.SelectedItem.Value = "";
                Session["CoUpdate"]           = 2;
                Response.Redirect("CompanyList.aspx");
            }
        }
Exemple #5
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"));
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Convert.ToInt32(Session["CoUpdate"]) == 2)
            {
                updateSuccess.Visible = true;
                Session.Remove("CoUpdate");
            }
            if (Convert.ToInt32(Session["CoCreate"]) == 2)
            {
                createSuccess.Visible = true;
                Session.Remove("CoCreate");
            }

            if (!IsPostBack)
            {
                Company_Management coMgmt = new Company_Management();
                DataTable          dt     = coMgmt.CoInfoRead();

                //GridView3.DataSource = dt;
                GridView3.DataBind();
            }
        }
Exemple #8
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();
            }
        }