protected void Send_Click(object sender, EventArgs e)
    {
        //add cty to db
        ch_cities cty = new ch_cities();

        cty.cty_Name = DDLCity.SelectedItem.Text;

        //בדיקה אם קיים בWS
        Cities.Cities ctyWs = new Cities.Cities();
        if (!ctyWs.IsExist(cty.cty_Name))
        {
            lblErr.Text = "העיר כבר לא קיימת במאגר הנתונים הארצי";
            return;
        }
        ch_citiesSvc.AddCity(cty);


        ch_users usr1 = new ch_users();

        usr1.usr_Identity   = txtTchIdentity.Text.Trim();
        usr1.usr_First_Name = txtFirstName.Text.Trim();
        usr1.usr_Last_Name  = txtLastName.Text.Trim();
        DateTime dt = Convert.ToDateTime(DateTextBox.Text);

        usr1.usr_Birth_Date = dt.ToString("yyyy/MM/dd");
        usr1.usr_Gender     = rbtGender.SelectedValue;
        usr1.cty_Id         = ch_citiesSvc.GetIdByCtyName(cty.cty_Name);
        usr1.usr_Address    = txtAddress.Text.Trim();
        usr1.usr_Home_Phone = txtHomePhone.Text.Trim();
        usr1.usr_Cellphone  = txtCellphone.Text.Trim();
        usr1.sc_Id          = Convert.ToInt32(DDLSchools.SelectedValue);
        usr1.usr_Email      = txtEmail.Text.Trim();
        usr1.usr_Password   = txtTchIdentity.Text.Trim() + "t";
        usr1.lvl_Id         = Convert.ToInt32(ddlLevels.SelectedValue);

        // ביצוע הרשמה וכתיבת השגיאות אם יש!
        lblErr.Text = ch_usersSvc.AddUser(usr1);

        ch_teachers tch1 = new ch_teachers();

        tch1.usr_Id = ch_usersSvc.GetMaxId();

        lblErr.Text = ch_teachersSvc.AddTeacher(tch1);

        foreach (ListItem li in lbProfessions.Items)
        {
            if (li.Selected)
            {
                ch_teachers_professions tch_pro = new ch_teachers_professions(Convert.ToInt32(li.Value), tch1.usr_Id);
                ch_teachers_professionsSvc.AddTeacherProfessions(tch_pro);
            }
        }
        //אם אין שגיאות בהרשמה
        if (lblErr.Text == "")
        {
            //Response.Write("<script>alert('המשתמש נרשם בהצלחה');</script>");
            Response.Redirect("TeachersData.aspx");
        }
    }
示例#2
0
    /// <summary>
    /// Add a teacher to the database
    /// </summary>
    /// <param name="tch1">the new teacher to add</param>
    /// <returns>string of an error or a string.Empty if the action is completed</returns>
    public static string AddTeacher(ch_teachers tch1)
    {
        if (ch_usersSvc.GetUsrType(tch1.usr_Id) != "usr")
        {
            return("User already exists!");
        }

        string strSql = "INSERT INTO ch_teachers(usr_id)  ";

        strSql += "VALUES(" + tch1.usr_Id + ")";
        Connect.DoAction(strSql, "ch_teachers");
        return("");
    }