protected void Button1_Click1(object sender, EventArgs e) { if (lblid.Text.Length > 0) { try { TelContactsRepository telir = new TelContactsRepository(); if ((TextBox2.Text.Length > 0) && (TextBox2.Text != lbltelnumber.Text)) { if (telir.FindBytelnumber(TextBox2.Text) != null) { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errRepeatetelTitle, Color.Red); return; } } TelContactsRepository ecrir = new TelContactsRepository(); TelContact tel = new TelContact(); tel.UserTypeID = DropDownList1.SelectedItem.Value.ToInt(); // tel.UserID = ddluserid.SelectedValue.ToInt(); tel.UserID = Session["newuserid"].ToString().ToInt(); tel.TelTypeID = Session["newteltype"].ToString().ToInt(); // tel.TelTypeID = ddlTeltype.SelectedValue.ToInt(); tel.ID = lblid.Text.ToInt(); if ((TextBox2.Text.Length > 0) && (TextBox2.Text != lbltelnumber.Text)) { tel.TelNumber = TextBox2.Text.Trim(); } ecrir.SavetelContact(tel); clearform(); PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green); } catch { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red); } } }
protected void Button1_Click(object sender, EventArgs e) { TelContactsRepository tel = new TelContactsRepository(); if (tel.FindBytelnumber(TextBox1.Text) != null) { PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDuplicateUsername, Color.Red); return; } bool successfullCreateAccount = true; try { TelContact newcontact = new TelContact(); newcontact.UserTypeID = lblusertypeid.Text.ToInt(); newcontact.UserID = lbluserid.Text.ToInt(); newcontact.TelTypeID = ddlteltype.SelectedValue.ToInt(); newcontact.TelNumber = TextBox1.Text.Trim(); TelContactsRepository ecrir = new TelContactsRepository(); ecrir.SavetelContact(newcontact); ClearForm(); PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green); } catch (System.Exception err) { successfullCreateAccount = false; PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailed, Color.Red); } if (successfullCreateAccount) { // ClearForm(); PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green); } }