protected void Send_Click(object sender, EventArgs e) { //בדיקה אם קיים בWS Cities.Cities ctyWs = new Cities.Cities(); if (!ctyWs.IsExist(DDLCity.SelectedItem.Text)) { lblErr.Text = "העיר כבר לא קיימת במאגר הנתונים הארצי"; return; } //add cty to db ch_cities cty = new ch_cities(); cty.cty_Name = DDLCity.SelectedItem.Text; ch_citiesSvc.AddCity(cty); ch_users usr1 = new ch_users(); usr1.usr_Identity = txtStuIdentity.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 = txtStuIdentity.Text.Trim() + "s"; usr1.lvl_Id = 0; ch_students stu1 = new ch_students(); stu1.usr_Id = ch_usersSvc.GetMaxId(); stu1.rm_Id = Convert.ToInt32(ddlRooms.SelectedValue); stu1.stu_Mom_Identity = txtMomIdentity.Text.Trim(); stu1.stu_Mom_First_Name = txtMomFirstName.Text.Trim(); stu1.stu_Mom_Cellphone = txtMomCellphone.Text; stu1.stu_Dad_Identity = txtDadIdentity.Text; stu1.stu_Dad_First_Name = txtDadFirstName.Text; stu1.stu_Dad_Cellphone = txtDadCellphone.Text; // ביצוע הרשמה וכתיבת השגיאות אם יש! lblErr.Text = ch_usersSvc.AddUser(usr1); stu1.usr_Id = ch_usersSvc.GetMaxId(); lblErr.Text = ch_studentsSvc.AddStudent(stu1); //אם אין שגיאות בהרשמה if (lblErr.Text == "") { //Response.Write("<script>alert('המשתמש נרשם בהצלחה');</script>"); Response.Redirect("StudentsData.aspx"); } }
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"); } }
protected void btn_insert_sc_Click(object sender, ImageClickEventArgs e) { ImageButton btn = (ImageButton)sender; GridViewRow gvr = (GridViewRow)btn.NamingContainer; TextBox txt_insert_sc_symbol = (TextBox)gvr.FindControl("txt_insert_sc_symbol"); TextBox txt_insert_sc_name = (TextBox)gvr.FindControl("txt_insert_sc_name"); DropDownList txt_insert_ddlCities = (DropDownList)gvr.FindControl("txt_insert_ddlCities"); TextBox txt_insert_sc_address = (TextBox)gvr.FindControl("txt_insert_sc_address"); TextBox txt_insert_sc_telephone = (TextBox)gvr.FindControl("txt_insert_sc_telephone"); //all vars to one object //add cty to db ch_cities cty = new ch_cities(); cty.cty_Name = txt_insert_ddlCities.SelectedItem.Text; //בדיקה אם קיים בWS Cities.Cities ctyWs = new Cities.Cities(); if (!ctyWs.IsExist(cty.cty_Name)) { lblErrGV.Text = "העיר כבר לא קיימת במאגר הנתונים הארצי"; return; } ch_citiesSvc.AddCity(cty); //all vars to one object ch_schools sc1 = new ch_schools(); sc1.sc_Symbol = txt_insert_sc_symbol.Text.Trim(); sc1.sc_Name = txt_insert_sc_name.Text.Trim(); sc1.cty_Id = ch_citiesSvc.GetIdByCtyName(cty.cty_Name); sc1.sc_Address = txt_insert_sc_address.Text.Trim(); sc1.sc_Telephone = txt_insert_sc_telephone.Text.Trim(); if ((lblErrGV.Text = Validation(sc1)) != "") { return; } string err = ch_schoolsSvc.AddSchool(sc1); if (err == "")//אם ההכנסה התבצע { lblErrGV.Text = ""; gvSchools.ShowFooter = false; btnInsert.Enabled = true; //Bind data to GridView gvBind(); } else { lblErrGV.Text = err; txt_insert_sc_name.Text = ""; //Bind data to GridView gvBind(); } }
protected void btn_update_sc_Click(object sender, ImageClickEventArgs e) { ImageButton btn = (ImageButton)sender; GridViewRow gvr = (GridViewRow)btn.NamingContainer; int sc_id = Convert.ToInt32(gvSchools.DataKeys[gvr.RowIndex].Value.ToString()); TextBox txt_edit_sc_symbol = (TextBox)gvr.FindControl("txt_edit_sc_symbol"); TextBox txt_edit_sc_name = (TextBox)gvr.FindControl("txt_edit_sc_name"); DropDownList txt_edit_ddlCities = (DropDownList)gvr.FindControl("txt_edit_ddlCities"); TextBox txt_edit_sc_address = (TextBox)gvr.FindControl("txt_edit_sc_address"); TextBox txt_edit_sc_telephone = (TextBox)gvr.FindControl("txt_edit_sc_telephone"); //all vars to one object //add cty to db ch_cities cty = new ch_cities(); cty.cty_Name = txt_edit_ddlCities.SelectedItem.Text; //בדיקה אם קיים בWS Cities.Cities ctyWs = new Cities.Cities(); if (!ctyWs.IsExist(cty.cty_Name)) { lblErrGV.Text = "העיר כבר לא קיימת במאגר הנתונים הארצי"; return; } ch_citiesSvc.AddCity(cty); //all vars to one object ch_schools sc1 = new ch_schools(); sc1.sc_Symbol = txt_edit_sc_symbol.Text.Trim(); sc1.sc_Name = txt_edit_sc_name.Text.Trim(); sc1.cty_Id = ch_citiesSvc.GetIdByCtyName(cty.cty_Name); sc1.sc_Address = txt_edit_sc_address.Text.Trim(); sc1.sc_Telephone = txt_edit_sc_telephone.Text.Trim(); if ((lblErrGV.Text = Validation(sc1)) == "") { string err = ch_schoolsSvc.UpdateSchoolById(sc_id, sc1); if (err == "")//אם העדכון התבצע { lblErrGV.Text = string.Empty; gvSchools.EditIndex = -1; //Bind data to GridView gvBind(); } else { lblErrGV.Text = err; //Bind data to GridView gvBind(); } } }
/// <summary> /// Check if the "cityName" Exist in the database. /// </summary> /// <param name="cty1">The city you want to check</param> /// <returns>true if exists. /// false if not exists.</returns> public static bool IsCityNameExist(ch_cities cty1) { string strSql = "SELECT COUNT(cty_id) FROM ch_cities WHERE cty_name = '" + cty1.cty_Name + "'"; int num = Convert.ToInt32(Connect.MathAction(strSql, "ch_cities")); if (num > 0) { return(true); } return(false); }
/// <summary> /// Add a new ch_cities record to the database /// </summary> /// <param name="cty1">a new city you want to add</param> /// <returns>string of an error or a string.Empty if the action is completed</returns> public static string AddCity(ch_cities cty1) { string strSql1 = "SELECT COUNT(cty_id) FROM ch_cities WHERE cty_name = '" + cty1.cty_Name + "'"; int num = Convert.ToInt32(Connect.MathAction(strSql1, "ch_cities")); if (num > 0) { return("העיר כבר קיימת במערכת"); } string strSql = "INSERT INTO ch_cities(cty_name) VALUES('" + cty1.cty_Name + "')"; Connect.DoAction(strSql, "ch_cities"); return(""); }
/// <summary> /// Update city using its id /// </summary> /// <param name="id">cty_id statement</param> /// <param name="newCty1">new city to update</param> public static string UpdateCityById(int id, ch_cities newCty1) { string strSql1 = "SELECT COUNT(cty_id) FROM ch_cities WHERE cty_name = '" + newCty1.cty_Name + "' AND cty_id <>" + id; int num = Convert.ToInt32(Connect.MathAction(strSql1, "ch_cities")); if (num > 0) { return("העיר כבר קיימת במערכת"); } string strSql = "UPDATE ch_cities SET cty_name='" + newCty1.cty_Name + "' WHERE cty_id=" + id; Connect.DoAction(strSql, "ch_cities"); return(""); }
protected void btn_update_cty_Click(object sender, ImageClickEventArgs e) { ImageButton btn = (ImageButton)sender; GridViewRow gvr = (GridViewRow)btn.NamingContainer; int cty_id = Convert.ToInt32(gvCities.DataKeys[gvr.RowIndex].Value.ToString()); TextBox txt_edit_cty_name = (TextBox)gvr.FindControl("txt_edit_cty_name"); if (txt_edit_cty_name.Text.Trim() != "") { if (Regex.IsMatch(txt_edit_cty_name.Text.Trim(), @"^[א-תa-zA-Z''-'\s]{2,35}$")) { //all vars to one object ch_cities cty1 = new ch_cities(); cty1.cty_Name = txt_edit_cty_name.Text.Trim(); string err = ch_citiesSvc.UpdateCityById(cty_id, cty1); if (err == "")//אם העדכון התבצע { lblErrGV.Text = string.Empty; gvCities.EditIndex = -1; gvBind(); } else { lblErrGV.Text = err; gvBind(); } } else { lblErrGV.Text = "הכנס אותיות בין 2 ל 35 תווים"; } } else { lblErrGV.Text = "הכנס עיר"; } }
protected void btn_insert_cty_Click(object sender, ImageClickEventArgs e) { ImageButton btn = (ImageButton)sender; GridViewRow gvr = (GridViewRow)btn.NamingContainer; TextBox txt_insert_cty_name = (TextBox)gvr.FindControl("txt_insert_cty_name"); if (txt_insert_cty_name.Text.Trim() != "") { if (Regex.IsMatch(txt_insert_cty_name.Text.Trim(), @"^[א-תa-zA-Z''-'\s]{2,35}$")) { //all vars to one object ch_cities cty1 = new ch_cities(); cty1.cty_Name = txt_insert_cty_name.Text.Trim(); string err = ch_citiesSvc.AddCity(cty1); if (err == "")//אם ההכנסה התבצע { lblErrGV.Text = ""; gvCities.ShowFooter = false; btnInsert.Enabled = true; gvBind(); } else { lblErrGV.Text = err; txt_insert_cty_name.Text = ""; gvBind(); } } else { lblErrGV.Text = "הכנס אותיות בין 2 ל 35 תווים"; } } else { lblErrGV.Text = "הכנס עיר"; } }
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); int usr_id = Convert.ToInt32(Session["usr_id"]); ch_users newUsr1 = new ch_users(); newUsr1.sc_Id = Convert.ToInt32(DDLSchools.SelectedValue); newUsr1.usr_Address = txtAddress.Text; newUsr1.usr_Birth_Date = DateTextBox.Text; newUsr1.cty_Id = ch_citiesSvc.GetIdByCtyName(cty.cty_Name); newUsr1.usr_Email = txtEmail.Text; newUsr1.usr_First_Name = txtFirstName.Text; newUsr1.usr_Gender = rbtGender.SelectedValue; newUsr1.usr_Home_Phone = txtHomePhone.Text; newUsr1.usr_Cellphone = txtCellphone.Text; newUsr1.usr_Identity = txtIdentity.Text; newUsr1.usr_Last_Name = txtLastName.Text; if (ch_usersSvc.GetUsrType(usr_id) == "tch") { if (ValidateTch()) { foreach (ListItem li in lbProfessions.Items) { ch_teachers_professions tch_pro = new ch_teachers_professions(Convert.ToInt32(li.Value), usr_id); if (!ch_teachers_professionsSvc.IsExist(tch_pro) && li.Selected) { ch_teachers_professionsSvc.AddTeacherProfessions(tch_pro); } else if (ch_teachers_professionsSvc.IsExist(tch_pro) && !li.Selected) { ch_teachers_professionsSvc.DeleteTeacherProfessions(tch_pro); } } } else { lblErr.Text = "הכנס מקצועות עליהם עברת הכשרה"; } } if (ch_usersSvc.GetUsrType(usr_id) == "crw") { ch_crew newCrw1 = new ch_crew(); newCrw1.job_Id = Convert.ToInt32(ddlJobs.SelectedValue); newCrw1.usr_Id = usr_id; ch_crewSvc.UpdateCrwById(newCrw1); } ch_usersSvc.UpdateUserById(usr_id, newUsr1); //update sessions Session["sc_id"] = newUsr1.sc_Id; Session["gender"] = newUsr1.usr_Gender; Session["fullName"] = newUsr1.usr_First_Name + " " + newUsr1.usr_Last_Name; Response.Redirect("UsrProfile.aspx"); }