/// <summary> /// 添加按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_ok_Click(object sender, EventArgs e) { foreach (Control c in panel_new.Controls) //循环判断输入框是否为空 { if (c is TextBox && c.Text == "") { isnull = false; MessageBox.Show("请填写完整!", "提示"); return; } } isnull = true; if (!isnull) { MessageBox.Show("请填写完整!", "提示"); return; } cm.Client_name = text_new_client_name.Text; //将输入框的值赋给实体类 cm.Client_address = text_new_client_position.Text; cm.Client_contacts = text_new_client_contacts.Text; cm.Client_phone = text_new_client_phone.Text; cm.Client_note = text_new_client_note.Text; cb.Insert(cm); MessageBox.Show("添加成功!", "提示"); btn_manager_Click(sender, e); }
public ActionResult Create([Bind(Include = "Id,Name,LastName,DNI,Address,Phone,Email")] ClientModel client) { try { if (client.Name == null || client.Name == string.Empty) { ModelState.AddModelError("Name", "Debe ingresar un nombre"); } if (client.LastName == null || client.LastName == string.Empty) { ModelState.AddModelError("LastName", "Debe ingresar un apellido"); } if (client.DNI == 0) { ModelState.AddModelError("DNI", "Debe ingresar un DNI"); } if (client.Address == null || client.Address == string.Empty) { ModelState.AddModelError("Address", "Debe ingresar una dirección"); } if (client.Phone == null || client.Phone == string.Empty) { ModelState.AddModelError("Phone", "Debe ingresar un teléfono"); } if (client.Email == null || client.Email == string.Empty) { ModelState.AddModelError("Email", "Debe ingresar un email"); } IEnumerable <Client> rooms = clientBusiness.GetByFilters(ClientModel.FromModel(client)); if (rooms.ToList().Count > 0) { ModelState.AddModelError("Model", "Ya existe un cliente con DNI: " + client.DNI); } if (ModelState.IsValid) { clientBusiness.Insert(ClientModel.FromModel(client)); return(RedirectToAction("Index")); } return(View(client)); } catch (Exception ex) { Log.Error(ex.Message, ex); return(View()); } }
public ActionResult Create([Bind(Include = "Id,FullName,Email,PhoneNumber")] Client client) { if (ModelState.IsValid) { clientBLL.Insert(client); return(RedirectToAction("Index")); } return(View(client)); }
private void btnInsert_Click(object sender, EventArgs e) { client.Name = txtName.Text; client.CPF = txtCPF.Text; client.RG = txtRG.Text; client.PhoneNumber1 = txtPhoneNumber1.Text; client.PhoneNumber2 = txtPhoneNumber2.Text; client.Email = txtEmail.Text; MessageBox.Show(clientBLL.Insert(client).Message); }
protected void btnRegisterClient_Click(object sender, EventArgs e) { try { ClientDTO clientDTO = new ClientDTO(); ClientBLL clientBLL = new ClientBLL(); clientDTO.Name = txtRegisterName.Text; clientDTO.Type = dropRegisterType.SelectedValue; clientDTO.Cpf = txtRegisterCpf.Text; clientDTO.Phone = txtRegisterPhone.Text; clientDTO.Email = txtRegisterEmail.Text; clientDTO.Password = txtRegisterPass.Text; string clientId = clientBLL.ReturnID(clientDTO.Email); if (clientId == "NOT_FOUND") { clientBLL.Insert(clientDTO); clientId = clientBLL.ReturnID(clientDTO.Email); string clientType = clientBLL.ConsultID(int.Parse(clientId)).Rows[0]["type"].ToString(); Session["UserEmail"] = clientDTO.Email; Session["UserId"] = clientId; Session["UserType"] = clientType; string msg = string.Format($@"Seja bem vindo ao nosso sistema '{clientDTO.Name}'"); SuccessMessage(msg); switch (clientType) { case "client": Response.Redirect("clientHome.aspx"); break; case "admin": Response.Redirect("home.aspx"); break; default: Response.Redirect("clientHome.aspx"); break; } } else { string msg = string.Format($@"Não foi possível finalizar o cadastro. Já existe um usuário com o e-mail: '{clientDTO.Email}'"); ErrorMessage(msg); } } catch (Exception error) { ErrorMessage(error.Message); } }
protected void btnSendToConfirm_OnClick(object sender, EventArgs e) { try { using (TransactionScope trans = new TransactionScope()) { #region Objects //Client Object Client client = new Client(); //Case object ClientCase clientCase = new ClientCase(); //Session ibject Sessions casesession = new Sessions(); SessionQuestion sessionQuestions = new SessionQuestion(); //Prescription Object Prescription prsc = new Prescription(); PrescriptionSession prescSession = new PrescriptionSession(); PrescriptionCourses prscCourse = new PrescriptionCourses(); PrescriptionCD prscCd = new PrescriptionCD(); #endregion #region CLient and relation data //Load the data into the object client.FirstName = txtFName.Text; client.MiddleName = txtMiddleName.Text; client.SurrName = txtSurrName.Text; client.CreationDate = DateTime.Now; client.CreatedBy = userName; client.IsActive = IsActive.Active; client.Notes = txtNotes.Text; //ClientDetail client.CLientId = client.CLientId; client.City = txtCity.Text; client.Country = drpCountry.Text; client.Address = txtAdress.Text; client.Telephone = txtTelephone.Text; client.Mob = txtMob.Text; client.DateOfBirth = Convert.ToDateTime(txtDateOf.Text); client.Gender = drpGender.Text; if (HasArelation()) { client.HasArelation = HasRelations.yes; } else { client.HasArelation = HasRelations.no; } client.CLientId = ClientBLL.Insert(client); Thread.Sleep(150); #region Relation Data if (HasArelation()) { Relatives relative = new Relatives(); relative.ClientId = client.CLientId; relative.CLientRelId = Convert.ToInt32(drpClients.SelectedItem.Value); relative.RelationName = txtRelName.Text; Thread.Sleep(150); RelativesBLL.Insert(relative); } #endregion #endregion #region Client case clientCase.ClientId = client.CLientId; clientCase.CaseNumber = txtCaseNumber.Text; clientCase.CaseStatus = CaseStatus.opened; clientCase.dateTime = DateTime.Now; Thread.Sleep(150); clientCase.CaseId = ClientCaseBLL.Insert(clientCase); #endregion #region Questions and answers //Session Insertion casesession.CaseId = clientCase.CaseId; casesession.Report = txtReport.Text; casesession.Notes = string.Empty; //Session Questions Insertion Thread.Sleep(150); int sessionId = SessionBLL.Insert(casesession); foreach (RepeaterItem item in questionRepeater.Items) { sessionQuestions.SessionId = sessionId; Label lblQuestion = (Label)item.FindControl("lblQuestion"); sessionQuestions.Question = lblQuestion.Text; TextBox txtAns = (TextBox)item.FindControl("txtAns"); sessionQuestions.Answer = ""; sessionQuestions.Answer = txtAns.Text; if (txtAns != null) { SessionQuestionBLL.Insert(sessionQuestions); } } #endregion #region Prescription #region Prescription Insertion prsc.CaseId = clientCase.CaseId; prsc.Report = txtFinalReport.Text; prsc.Status = PrescriptionStatus.onhold; //Init prsc.ConfirmedComment prsc.ConfermedComment = string.Empty; Thread.Sleep(150); int prescriptionId = PrescriptionBLL.Insert(prsc); #endregion //Prescription CD #region Prescription CD foreach (ListItem cdItem in lstCD.Items) { if (cdItem.Selected) { prscCd.PrescriptionId = prescriptionId; prscCd.CdName = cdItem.Text; prscCd.Note = string.Empty; PrescriptionCdBLL.Insert(prscCd); } } #endregion //Prescription Coursesls #region Prescription Courseslst foreach (ListItem courseItem in lstCourses.Items) { if (courseItem.Selected) { prscCourse.PrescriptionId = prescriptionId; prscCourse.CourseName = courseItem.Text; prscCourse.Notes = string.Empty; PrescriptionCoursesBLL.Insert(prscCourse); } } #endregion //Prescription Sessions #region Prescription Sessions foreach (RepeaterItem sessionItem in repeatSessions.Items) { prescSession.PrescriptionId = prescriptionId; CheckBox chkSession = (CheckBox)sessionItem.FindControl("chkCourse"); if (chkSession.Checked) { //Session Name TextBox txtSessionName = (TextBox)sessionItem.FindControl("txtSessionName"); prescSession.SessionName = ""; prescSession.SessionName = txtSessionName.Text; //Session Counter TextBox txtCounter = (TextBox)sessionItem.FindControl("txtCounter"); prescSession.Number = Convert.ToInt32(txtCounter.Text); TextBox txtComment = (TextBox)sessionItem.FindControl("txtComment"); prescSession.Comment = ""; prescSession.Comment = txtComment.Text; PrescriptionSessionBLL.Insert(prescSession); } } #endregion #endregion trans.Complete(); //session fore firing the jquery notify string message = "CLient has been saved and waiting to be revised"; Response.Redirect("/Clients/Clients.aspx?message=" + message, false); } } catch (Exception ex) { string message = ex.Message; Response.Redirect("/Clients/Clients.aspx?message=" + message, false); } }