Ejemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit__user);

    Intialize();

    SelectDataBaseSqlite sdb = new SelectDataBaseSqlite(this);
    Cursor allrows = sdb.select_Member();
    allrows.moveToFirst();

    name.setText(allrows.getString(1));
    email.setText(allrows.getString(2));
    city.setText(query.getCityName(allrows.getInt(8)));
    getNameCity();
    phone.setText(allrows.getString(3));
    age.setText(String.valueOf(allrows.getInt(4)));
    pass.setText(allrows.getString(7));
    change_pass = allrows.getString(7);
    user.setText(allrows.getString(6));
    change_user = allrows.getString(6);
    SpinnerSetUp();

    sex.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {

            switch (pos) {
              case 0:
                Asex = false;
                break;
              case 1:
                Asex = true;
                break;
            }
          }

          public void onNothingSelected(AdapterView<?> arg0) {}
        });
  }
Ejemplo n.º 2
0
  public void edit_member(View v) {

    try {
      Aname = name.getText().toString();
      Aemail = email.getText().toString();
      Acity = city.getText().toString();
      Aphone = phone.getText().toString();
      Aage = Integer.parseInt(age.getText().toString());
      Ausername = user.getText().toString();
      Apass = pass.getText().toString();

      Integer cityid = query.getCityId(Acity);

      if (cityid <= 0) {
        city.requestFocus();
        city.setError("شهر خود را انتخاب کنید");

      } else if (Aname.length() < 3) {
        name.setError("بیش از 3 حرف وارد کنید");
        name.requestFocus();

      } else if (Aemail.length() > 0 && !isValidEmail(Aemail)) {

        email.setError("ایمیل نا معتبر است.");
      } else if (Ausername.length() < 5) {
        user.setError("نام کاربری باید حد اقل 5 حرف باشد");
        user.requestFocus();
      } else if (Apass.length() < 6) {
        pass.setError("رمز عبور باید حداقل 6 حرف باشد");
        pass.requestFocus();
      } else {

        _json =
            (json.getSqliteTOjson(
                Aname.trim(),
                Aemail.trim(),
                Aphone.trim(),
                Aage,
                Asex,
                Ausername.trim(),
                Apass.trim(),
                query.getCityId(Acity)));
        fc.SetMember_Name(Aname);
        fc.SetMember_Email(Aemail);
        fc.SetMember_Mobile(Aphone);
        fc.SetMember_Age(Aage);
        fc.SetMember_Sex(Asex);
        fc.SetMember_UserName(Ausername);
        fc.SetMember_Password(Apass);
        fc.SetMember_CityId(query.getCityId(Acity));

        sendPost = new HTTPPostMemberEditJson(this);
        sendPost.SetMember_Json(_json);
        sendPost.execute();
      }
    } catch (Exception e) {
      AlertDialog alertDialog = new AlertDialog.Builder(Edit_User.this).create();
      alertDialog.setTitle("هشدار ");
      alertDialog.setMessage("ویرایش نشد،دوباره امتحان کنید");
      alertDialog.setButton(
          "تایید",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {}
          });

      alertDialog.show();
    }
  }
Ejemplo n.º 3
0
  public void AddTOmember(View v) {
    try {

      Aname = name.getText().toString();
      Aemail = email.getText().toString();
      Acity = city.getText().toString();
      Aphone = phone.getText().toString();
      Aage = age.getText().toString();
      Asex = _sex;
      Ausername = username.getText().toString();
      Apass = pass.getText().toString();

      Integer cityid = 0;
      cityid = query.getCityId(Acity);

      if (cityid <= 0) {
        city.requestFocus();
        city.setError("شهر خود را انتخاب کنید");

      } else if (Aemail.length() > 0 && !isValidEmail(Aemail)) {

        email.setError("ایمیل نا معتبر است.");
      } else if (Aname.length() < 3) {
        name.setError("بیش از 3 حرف وارد کنید");
        name.requestFocus();
      } else if (Ausername.length() < 5) {
        username.setError("نام کاربری باید حد اقل 5 حرف باشد");
        username.requestFocus();
      } else if (Apass.length() < 6) {
        pass.setError("رمز عبور باید حداقل 6 حرف باشد");
        pass.requestFocus();

      } else if (Aage.equals(null) || Aage.length() == 0 || Aage.equals("null")) {
        age.setError("سن خود را وارد کنید");
        age.requestFocus();
      } else {
        _json =
            (json.getSqliteTOjson(
                Aname,
                Aemail,
                Aphone,
                Integer.parseInt(Aage),
                Asex,
                Ausername,
                Apass,
                query.getCityId(Acity)));
        fc.SetMember_Name(Aname);
        fc.SetMember_Email(Aemail);
        fc.SetMember_Mobile(Aphone);
        fc.SetMember_Age(Integer.parseInt(Aage));
        fc.SetMember_Sex(Asex);
        fc.SetMember_UserName(Ausername);
        fc.SetMember_Password(Apass);
        fc.SetMember_CityId(cityid);

        sendPost = new HTTPPostMemberJson(this);
        sendPost.SetMember_Json(_json);
        sendPost.execute();
      }

    } catch (Exception e) {
      Toast.makeText(getApplication(), e.toString(), Toast.LENGTH_LONG).show();
    }
  }