protected void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                List <int> selectedRows = new List <int>();

                foreach (GridViewRow gvr in GridView1.Rows)
                {
                    if ((gvr.FindControl("CheckBox2") as CheckBox).Checked == true)
                    {
                        selectedRows.Add(gvr.Cells[0].Text.ToInt());
                    }
                }

                if (selectedRows.Count > 0)
                {
                    PersonsAdminsRepository pair = new PersonsAdminsRepository();
                    pair.DeletePerson(selectedRows);
                    LoadStdData();
                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgDeleteSuccessfull, Color.Green);
                }
            }
            catch
            {
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDeleteFailed, Color.Red);
            }
        }
        public void loadform(string perid)
        {
            try
            {
                PersonsAdminsRepository per    = new PersonsAdminsRepository();
                PersonsAdmin            person = per.FindByid(perid.ToInt());

                if (person != null)
                {
                    lbllecid.Text            = person.AdminID.ToString();
                    txtname.Text             = person.FirstName;
                    txtlastname.Text         = person.LastName;
                    lblusername.Text         = person.Username;
                    Session["pass"]          = person.Password;
                    chkActiveAccount.Checked = (person.Status.Value == 0 ? true : false);
                }
                else
                {
                    Redirector.Goto(Redirector.PageName.errorpage);
                }
            }
            catch
            {
                Redirector.Goto(Redirector.PageName.errorpage);
            }
        }
        protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
        {
            lblmessage.Text = "";
            if (txtsearch.Text.Length > 0)
            {
                if (DropDownList1.SelectedValue == "0")
                {
                    try
                    {
                        WebServiceAccountsRepository pair = new WebServiceAccountsRepository();

                        Session["stddatafindid"] = pair.Searchid(txtsearch.Text.ToInt());
                        GridView1.DataSource     = Session["stddatafindid"];
                        GridView1.DataBind();

                        lblrecordcount.Text       = string.Format("{0} : {1}", pair.webacountcount().ToString(), Resources.DashboardText.RecordCount);
                        lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["stddatafindid"] as DataTable).Rows.Count.ToString(), Resources.DashboardText.SelectRecordCount);
                    }
                    catch
                    {
                        PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errSearch, Color.Red);
                        lblrecordcount.Text       = string.Format("{0} : {1}", "0", Resources.DashboardText.RecordCount);
                        lblSelectedDataCount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.SelectRecordCount);
                    }
                }
                if (DropDownList1.SelectedValue == "1")
                {
                    try
                    {
                        PersonsAdminsRepository pair = new PersonsAdminsRepository();
                        Session["stddatafindcode"] = pair.SearchFirstName(txtsearch.Text);
                        GridView1.DataSource       = Session["stddatafindcode"];
                        GridView1.DataBind();

                        lblrecordcount.Text       = string.Format("{0} : {1}", pair.PersonAdmincount().ToString(), Resources.DashboardText.RecordCount);
                        lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["stddatafindcode"] as DataTable).Rows.Count.ToString(), Resources.DashboardText.SelectRecordCount);
                    }
                    catch
                    {
                        PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errSearch, Color.Red);
                        lblrecordcount.Text       = string.Format("{0} : {1}", "0", Resources.DashboardText.RecordCount);
                        lblSelectedDataCount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.SelectRecordCount);
                    }
                }

                else
                {
                    LoadStdData();
                }
            }
        }
示例#4
0
        protected void btnSubmitCaptcha_Click(object sender, EventArgs e)
        {
            bool success = false;

            if (Session["Captcha"] != null)
            {
                //Match captcha text entered by user and the one stored in session
                if (Convert.ToString(Session["Captcha"]) == txtCaptchaText.Text.Trim())
                {
                    success = true;
                }
            }

            lblStatus.Visible = true;
            if (success)
            {
                lblStatus.Text = "Success";
                PersonsAdminsRepository perir       = new PersonsAdminsRepository();
                PersonsAdmin            currentuser = perir.FindByUserName(tbxusername.Text);

                if (currentuser == null)
                {
                    PersonTools.ShowMessage(lblStatus, Resources.DashboardText.errInvalidUserPass, Color.Red);

                    return;
                }

                if (tbxpass.Text != currentuser.Password)
                {
                    PersonTools.ShowMessage(lblStatus, Resources.DashboardText.errInvalidUserPass, Color.Red);
                    return;
                }

                if (currentuser.Status.Value == 1)
                {
                    PersonTools.ShowMessage(lblStatus, Resources.DashboardText.errAccountIsLocked, Color.Red);
                    return;
                }


                Session["CurrentUser"] = currentuser;

                Redirector.Goto(Redirector.PageName.DepartmentsManager);
            }
            else
            {
                PersonTools.ShowMessage(lblStatus, Resources.DashboardText.errInvalidUserPass, Color.Red);
            }
        }
        public void LoadStdData()
        {
            try
            {
                PersonsAdminsRepository pair = new PersonsAdminsRepository();
                Session["padata"]    = pair.GetAlldata();
                GridView1.DataSource = Session["padata"];
                GridView1.DataBind();

                lblrecordcount.Text = string.Format("{0} : {1}", pair.PersonAdmincount().ToString().ToFarsiNumber(), Resources.DashboardText.RecordCount);

                lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["padata"] as DataTable).Rows.Count.ToString().ToFarsiNumber(), Resources.DashboardText.SelectRecordCount);
            }
            catch
            {
                Redirector.Goto(Redirector.PageName.errorpage);
            }
        }
示例#6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            PersonsAdminsRepository parir = new PersonsAdminsRepository();

            if (parir.FindByUserName(txtusername.Text) != null)
            {
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDuplicateUsername, Color.Red);
                return;
            }



            bool successfullCreateAccount = true;

            try
            {
                PersonsAdminsRepository pair  = new PersonsAdminsRepository();
                PersonsAdmin            newpa = new PersonsAdmin();
                newpa.FirstName = txtname.Text.Trim();
                newpa.LastName  = txtlastname.Text.Trim();
                newpa.Username  = txtusername.Text.Trim();
                newpa.Password  = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5");
                newpa.Status    = (chkActiveAccount.Checked == true ? 0 : 1);

                pair.SavePerson(newpa);


                clearform();
            }
            catch (System.Exception err)
            {
                //OnlineTools.ShowMessage(lblMessage, err.Message, Color.Red);
                successfullCreateAccount = false;
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailed, Color.Red);
            }
            if (successfullCreateAccount)
            {
                // ClearForm();
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green);
            }
        }