コード例 #1
0
ファイル: EditCompany.aspx.cs プロジェクト: LUKEMANN/AdMonk
    protected void Button2_Click1(object sender, EventArgs e)
    {
        DataView dv = SqlDataSourceCompany.Select(DataSourceSelectArguments.Empty) as DataView;

        bool Exists = false;


        if (dv != null)
        {
            for (int i = 0; i < dv.Table.Rows.Count; i++)
            {
                if (Session["cid"].ToString() == dv.Table.Rows[i]["Company_Id"].ToString() &&
                    password.Text == dv.Table.Rows[i]["Password"].ToString())
                {
                    Exists = true;
                    break;
                }
            }
            if (Exists)
            {
                SqlDataSourceCompany.Delete();
                Response.Redirect("Company.aspx");
            }
            else
            {
                msg.Text     = "incorrect password";
                msg.CssClass = "text-danger";
            }
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "$('#myModal').modal('hide');$('body').removeClass('modal-open');$('.modal-backdrop').remove();$('#myModal').modal('show');", true);
        }
    }
コード例 #2
0
ファイル: EditCompany.aspx.cs プロジェクト: LUKEMANN/AdMonk
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["cid"] == null)
        {
            Response.Redirect("LoginCompany.aspx");
        }

        if (!IsPostBack)
        {
            DataView dv = SqlDataSourceCompany.Select(DataSourceSelectArguments.Empty) as DataView;

            if (dv != null)
            {
                for (int i = 0; i < dv.Table.Rows.Count; i++)
                {
                    if (Session["cid"].ToString() == dv.Table.Rows[i]["Company_Id"].ToString())
                    {
                        username.Text = dv.Table.Rows[i]["Name"].ToString();
                        mobile.Text   = dv.Table.Rows[i]["Contact"].ToString();
                        emailid.Text  = dv.Table.Rows[i]["Email"].ToString();
                        break;
                    }
                }
            }
        }
    }
コード例 #3
0
    protected void changepass_Click(object sender, EventArgs e)
    {
        DataView dv = SqlDataSourceCompany.Select(DataSourceSelectArguments.Empty) as DataView;
        bool exists = false;
        if (dv != null)
        {
            for (int i = 0; i < dv.Table.Rows.Count; i++)
            {
                if (email.Text == dv.Table.Rows[i]["Email"].ToString() &&
                    oldpass.Text == dv.Table.Rows[i]["Password"].ToString())
                {
                    Session["cid"] = dv.Table.Rows[i]["Company_Id"].ToString();
                    exists = true;
                    break;
                }
            }
            if (exists)
            {
                SqlDataSourceCompany.Update();
                Response.Redirect("LoginCompany.aspx");
            }
            else
            {
                msg.Text = "Invalid email-id or password";
                msg.CssClass = "text-danger";
            }
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "$('#myModal').modal('hide');$('body').removeClass('modal-open');$('.modal-backdrop').remove();$('#myModal').modal('show');", true);

        }

    }
コード例 #4
0
    protected void Button1_Command(object sender, CommandEventArgs e)
    {
        HiddenFieldStatus.Value = e.CommandName;
        HiddenFieldId.Value     = e.CommandArgument.ToString();

        if (HiddenFieldStatus.Value == "blocked")
        {
            HiddenFieldStatus.Value = "";
        }
        else
        {
            HiddenFieldStatus.Value = "blocked";
        }

        SqlDataSourceCompany.Update();
        GridView1.DataBind();
    }
コード例 #5
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        DataView dv = SqlDataSourceCompany.Select(DataSourceSelectArguments.Empty) as DataView;

        if (dv != null)
        {
            bool exists  = false;
            bool existsc = false;      //for contact
            for (int i = 0; i < dv.Table.Rows.Count; i++)
            {
                if (emailid.Text.ToLower() == dv.Table.Rows[i]["Email"].ToString().ToLower() || company_name.Text.ToLower() == dv.Table.Rows[i]["Name"].ToString().ToLower())
                {
                    exists = true;
                    break;
                }
            }
            //-- contact validation--

            for (int i = 0; i < dv.Table.Rows.Count; i++)
            {
                if (mobile.Text == dv.Table.Rows[i]["Contact"].ToString())
                {
                    existsc = true;
                    break;
                }
            }
            if (exists)
            {
                msg.Text     = "Account already exists with Company Name or E-mail ID";
                msg.CssClass = "text-danger";
            }
            else if (existsc)         //for contact
            {
                msg.Text     = "Account already exists with contact";
                msg.CssClass = "text-danger";
            }
            else
            {
                msg.Text = "";
                SqlDataSourceCompany.Insert();
                msg.Text     = "Account created successfully!";
                msg.CssClass = "text-success";
            }
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "$('#myModal').modal('hide');$('body').removeClass('modal-open');$('.modal-backdrop').remove();$('#myModal').modal('show');", true);
        }
    }
コード例 #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         LabelErrorMessage.Text = "";
         dv = (DataView)SqlDataSourceCompany.Select(DataSourceSelectArguments.Empty);
         Ddlist.DataSource = dv;
         if (dv.Count > 0)
         {
             Ddlist.DataValueField = "CompanyID";
             Ddlist.DataTextField  = "CMPCompanyName";
             Ddlist.DataBind();
             Ddlist.Items.Insert(0, new ListItem("Select One", "-1"));
         }
         else
         {
             LabelErrorMessage.Text = "This is the last level";
         }
     }
 }
コード例 #7
0
        protected void ButtonAdduser_Click(object sender, EventArgs e)
        {
            SqlDataSourceCompany.DataBind();
            DataView dview = (DataView)SqlDataSourceCompany.Select(DataSourceSelectArguments.Empty);

            if (dview.Count == 0)
            {
                errorLabel.Text    = "Въведеният администратор вече съществува!";
                errorLabel.Visible = true;
            }
            else if (Convert.ToString(TextBoxPassword.Text) != Convert.ToString(TextBoxPasswordRepeat.Text))
            {
                errorLabel.Text    = "Паролите не съвпадат";
                errorLabel.Visible = true;
            }
            else
            {
                HashPass HashPass = new HashPass();
                TextBoxPasswordRepeat.Text = HashPass.HashPassword(TextBoxPasswordRepeat.Text);

                var procedure = "CreateUser";
                connection.Open();
                SqlCommand comm = new SqlCommand(procedure, connection);
                comm.CommandType = CommandType.StoredProcedure;

                comm.Parameters.AddWithValue("@Username", TextBoxUsername.Text);
                comm.Parameters.AddWithValue("@Password", TextBoxPasswordRepeat.Text);
                comm.Parameters.AddWithValue("@Email", TextBoxEmail.Text);
                comm.Parameters.AddWithValue("@FirstName", TextBoxFirstName.Text);
                comm.Parameters.AddWithValue("@LastName", TextBoxLastName.Text);
                comm.Parameters.AddWithValue("@CompanyID", DropDownListCompany.SelectedItem.Value);

                comm.ExecuteNonQuery();
                connection.Close();

                errorLabel.Visible = false;


                this.GridView1.PageIndex = this.GridView1.PageCount - 1;
            }
        }