public ActionResult DeleteConfirmed(int id) { contacts contact = db.contacts.Find(id); db.contacts.Remove(contact); IEnumerable <projects> projects1 = db.projects.Where(p => p.executorID == id); foreach (projects p in projects1) { p.executorID = null; } IEnumerable <projects> projects2 = db.projects.Where(p => p.clientID == id); foreach (projects p in projects2) { p.clientID = null; } IEnumerable <projects> projects3 = db.projects.Where(p => p.managerID == id); foreach (projects p in projects3) { p.managerID = null; } IEnumerable <projects> projects4 = db.projects.Where(p => p.showmanID == id); foreach (projects p in projects4) { p.showmanID = null; } db.SaveChanges(); return(RedirectToAction("Index")); }
public List <contacts> getAllRecordsBySystemUserId() { List <contacts> dataList = new List <contacts>(); using (contactDatabaseLogicLayer contactDatabase = new contactDatabaseLogicLayer()) { SqlDataReader reader = contactDatabase.getAllRecordsBySystemUserId(applicationStatics.currentSystemUser.id); while (reader.Read()) { contacts temp = new contacts(); temp.id = reader.IsDBNull(0) ? Guid.Empty : reader.GetGuid(0); temp.firstName = reader.IsDBNull(1) ? string.Empty : reader.GetString(1); temp.lastName = reader.IsDBNull(2) ? string.Empty : reader.GetString(2); temp.company = reader.IsDBNull(3) ? string.Empty : reader.GetString(3); temp.title = reader.IsDBNull(4) ? string.Empty : reader.GetString(4); temp.systemUserId = reader.IsDBNull(5) ? Guid.Empty : reader.GetGuid(5); temp.createDate = reader.IsDBNull(6) ? DateTime.MinValue : reader.GetDateTime(6); temp.personelNote = reader.IsDBNull(7) ? string.Empty : reader.GetString(7); dataList.Add(temp); } reader.Close(); contactDatabase.connectionWizard(); } return(dataList); }
public int addNewContact(string firstName, string lastName, string companyName, string title, string personelNote) { int resultInt = 0; if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName)) { return(0); } contacts newRecord = new contacts(); newRecord.id = Guid.NewGuid(); newRecord.firstName = firstName; newRecord.lastName = lastName; newRecord.company = companyName; newRecord.title = title; newRecord.personelNote = personelNote; newRecord.createDate = DateTime.Now; newRecord.systemUserId = applicationStatics.currentSystemUser.id; using (contactDatabaseLogicLayer contactDatabase = new contactDatabaseLogicLayer()) { resultInt = contactDatabase.addNewContact(newRecord); } return(resultInt); }
public contacts layra1lh(int contact_id) { List <contacts> li = new List <contacts>(); string strSql = " select * from contacts where contact_id=@contact_id"; con.Open(); SqlCommand cmd = new SqlCommand(strSql, con); cmd.Parameters.AddWithValue("contact_id", contact_id); contacts s = null; SqlDataReader rd = cmd.ExecuteReader(); if (rd.Read()) { s = new contacts(); s.contact_id = (int)rd["contact_id"]; s.fullname = (string)rd["fullname"]; s.phone = (string)rd["phone"]; s.email = (string)rd["email"]; s.message = (string)rd["message"]; li.Add(s); } con.Close(); return(s); }
public contacts listContactId(Guid id) { contacts contactListId = new contacts(); try { SqlDataReader reader = dll.listContactId(id); while (reader.Read()) { contactListId = new contacts() { id = reader.IsDBNull(0) ? Guid.Empty : reader.GetGuid(0), cName = reader.IsDBNull(1) ? string.Empty : reader.GetString(1), cSurname = reader.IsDBNull(2) ? string.Empty : reader.GetString(2), numberI = reader.IsDBNull(3) ? string.Empty : reader.GetString(3), numberII = reader.IsDBNull(4) ? string.Empty : reader.GetString(4), numberIII = reader.IsDBNull(5) ? string.Empty : reader.GetString(5), emailAdress = reader.IsDBNull(6) ? string.Empty : reader.GetString(6), webAdress = reader.IsDBNull(7) ? string.Empty : reader.GetString(7), adress = reader.IsDBNull(8) ? string.Empty : reader.GetString(8), info = reader.IsDBNull(9) ? string.Empty : reader.GetString(9) }; } reader.Close(); } catch (Exception ex) { } finally { dll.SetConnection(); } return(contactListId); }
public int addContact(contacts c) { try { //SetConnection(); cmd = new SqlCommand("insert into contacts (id,cName,cSurname,numberI,numberII,numberIII,emailAdress,webAdress,adress,info) values (@ID,@cName,@cSurname,@numberI,@numberII,@numberIII,@emailAdress,@webAdress,@adress,@info)", con); cmd.Parameters.Add("@ID", SqlDbType.UniqueIdentifier).Value = c.id; cmd.Parameters.Add("@cName", SqlDbType.NVarChar).Value = c.cName; cmd.Parameters.Add("@cSurname", SqlDbType.NVarChar).Value = c.cSurname; cmd.Parameters.Add("@numberI", SqlDbType.NVarChar).Value = c.numberI; cmd.Parameters.Add("@numberII", SqlDbType.NVarChar).Value = c.numberII; cmd.Parameters.Add("@numberIII", SqlDbType.NVarChar).Value = c.numberIII; cmd.Parameters.Add("@emailAdress", SqlDbType.NVarChar).Value = c.emailAdress; cmd.Parameters.Add("@webAdress", SqlDbType.NVarChar).Value = c.webAdress; cmd.Parameters.Add("@adress", SqlDbType.NVarChar).Value = c.adress; cmd.Parameters.Add("@info", SqlDbType.NVarChar).Value = c.info; SetConnection(); ReturnValues = cmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { SetConnection(); } return(ReturnValues); }
public ContactViewModel(contacts model) { this.id = model.Id; this.article_id = model.article_id; this.name = model.name; this.message = model.message; this.email = model.email; this.phone = model.phone; }
public ActionResult ViewSingleContact(string id, string id2) { // check for malicious query if (Request.QueryString[id] == null && Request.QueryString[id2] == null) { contacts c = ContactsDatabase.Instance.GetContact(id, id2); return(View(c)); } return(new EmptyResult()); }
void getContactById(Guid recordId) { contactService contactService = new contactService(); data = contactService.getRecordByContactId(recordId); txtFirstname.Text = data.firstName; txtLastname.Text = data.lastName; txtCompany.Text = data.company; txtTitle.Text = data.title; }
void getContactDetail(Guid contactID) { contactService contactService = new contactService(); data = contactService.getRecordByContactId(contactID); txtFirstname.Text = data.firstName; txtLastname.Text = data.lastName; txtTitle.Text = data.title; txtCompany.Text = data.company; }
public void Sua_Click(object sender, CommandEventArgs e) { if (e.CommandName == "sua") { int m = Convert.ToInt16(e.CommandArgument); contacts s = data.layra1lh(m); Session["lh"] = s; Response.Redirect("Sualh.aspx"); } }
public ActionResult Edit([Bind(Include = "contactID,name,lastname,organizationID,position,phone,email,note")] contacts contact) { if (ModelState.IsValid) { db.Entry(contact).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.organizationID = new SelectList(db.organizations, "organizationID", "name", contact.organizationID); return(View(contact)); }
void getContactData(Guid contactId) { contactService contactService = new contactService(); data = contactService.getRecordByContactId(contactId); txtFirstName.Text = data.firstName; txtLastName.Text = data.lastName; txtCompany.Text = data.company; txtTitle.Text = data.title; txtNote.Text = data.personelNote; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { contacts lh = (contacts)Session["lh"]; txtcontact_id.Text = lh.contact_id.ToString(); txtphone.Text = lh.phone; txtfullname.Text = lh.fullname; txtemail.Text = lh.email; txtmessage.Text = lh.message; DataBind(); } }
public void Themlh(contacts s) { con.Open(); string strSql = " insert into contacts values (@fullname,@phone,@email,@massage)"; SqlCommand cmd = new SqlCommand(strSql, con); cmd.Parameters.AddWithValue("fullname", s.fullname); cmd.Parameters.AddWithValue("phone", s.phone); cmd.Parameters.AddWithValue("email", s.email); cmd.Parameters.AddWithValue("massage", s.message); cmd.ExecuteNonQuery(); con.Close(); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } contacts contact = db.contacts.Find(id); if (contact == null) { return(HttpNotFound()); } return(View(contact)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } contacts contact = db.contacts.Find(id); if (contact == null) { return(HttpNotFound()); } ViewBag.organizationID = new SelectList(db.organizations, "organizationID", "name", contact.organizationID); return(View(contact)); }
public void Capnhatlh(contacts s) { con.Open(); string strSql = " update contacts set fullname=@fullname,phone=@phone,email=@email,message=@message where contact_id=@contact_id"; SqlCommand cmd = new SqlCommand(strSql, con); cmd.Parameters.AddWithValue("fullname", s.fullname); cmd.Parameters.AddWithValue("phone", s.phone); cmd.Parameters.AddWithValue("email", s.email); cmd.Parameters.AddWithValue("message", s.message); cmd.Parameters.AddWithValue("contact_id", s.contact_id); cmd.ExecuteNonQuery(); con.Close(); }
public int updateContact(contacts data) { int resultInt = 0; command = new SqlCommand("updateContact", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@id", SqlDbType.UniqueIdentifier).Value = data.id; command.Parameters.Add("@firstName", SqlDbType.NVarChar).Value = data.firstName; command.Parameters.Add("@lastName", SqlDbType.NVarChar).Value = data.lastName; command.Parameters.Add("@company", SqlDbType.NVarChar).Value = data.company; command.Parameters.Add("@title", SqlDbType.NVarChar).Value = data.title; command.Parameters.Add("@personelNote", SqlDbType.NVarChar).Value = data.personelNote; connectionWizard(); resultInt = command.ExecuteNonQuery(); connectionWizard(); return(resultInt); }
/// <summary> /// Metodo void para guardar el contacto en la base de datos /// </summary> /// <param name="obj"></param> /// <param name="rta"></param> public void GuardarContacto(contacts obj, ref Respuesta rta) { using (admin_sigmatestEntities db = new admin_sigmatestEntities()) { try { db.contacts.Add(obj); db.SaveChanges(); rta.respuesta = true; rta.descripcion = "Tu información ha sido recibida satisfactoriamente"; } catch (Exception ex) { rta.respuesta = true; rta.descripcion = "Hubo un problema guardando los datos: " + ex.Message; } } }
protected void btnthem_Click(object sender, EventArgs e) { try { contacts s = new contacts(); s.fullname = txtfullname.Text; s.phone = txtphone.Text; s.email = txtemail.Text; s.message = txtmassage.Text; data.Themlh(s); msg.ForeColor = System.Drawing.Color.Blue; msg.Text = "Them thanh cong"; } catch (Exception ex) { msg.ForeColor = System.Drawing.Color.Red; msg.Text = " khong them duoc, co loi:" + ex.Message; } }
protected void btnsua_Click(object sender, EventArgs e) { try { contacts s = (contacts)Session["lh"]; s.phone = txtphone.Text; s.fullname = txtfullname.Text; s.email = txtemail.Text; s.message = txtmessage.Text; data.Capnhatlh(s); msg.Text = "Ban cap nhat thanh cong"; } catch (Exception ex) { msg.Text = " co loi :" + ex; } }
private void lst_list_DoubleClick(object sender, EventArgs e) { ListBox LST = (ListBox)sender; contacts clickedContact = (contacts)LST.SelectedItem; //MessageBox.Show(clickedContact.cName); if (clickedContact != null) { txt_update_name.Text = clickedContact.cName; txt_update_surname.Text = clickedContact.cSurname; txt_update_number1.Text = clickedContact.numberI; txt_update_number2.Text = clickedContact.numberII; txt_update_number3.Text = clickedContact.numberIII; txt_update_email.Text = clickedContact.emailAdress; txt_update_webadress.Text = clickedContact.webAdress; txt_update_adress.Text = clickedContact.adress; txt_update_info.Text = clickedContact.info; } }
public int addNewContact(contacts data) { command = new System.Data.SqlClient.SqlCommand("addNewContact", connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add("@id", SqlDbType.UniqueIdentifier).Value = data.id; command.Parameters.Add("@firstName", SqlDbType.NVarChar).Value = data.firstName; command.Parameters.Add("@lastName", SqlDbType.NVarChar).Value = data.lastName; command.Parameters.Add("@company", SqlDbType.NVarChar).Value = data.company; command.Parameters.Add("@title", SqlDbType.NVarChar).Value = data.title; command.Parameters.Add("@systemUserId", SqlDbType.UniqueIdentifier).Value = data.systemUserId; command.Parameters.Add("@createDate", SqlDbType.DateTime).Value = data.createDate; command.Parameters.Add("@personelNote", SqlDbType.NVarChar).Value = data.personelNote; connectionWizard(); int resultInt = command.ExecuteNonQuery(); connectionWizard(); return(resultInt); }
protected void btnthem_Click(object sender, EventArgs e) { try { contacts s = new contacts(); s.fullname = txtfullname.Text; s.phone = txtphone.Text; s.email = txtemail.Text; s.message = Message.Text; data.Themlh(s); msg.ForeColor = System.Drawing.Color.Green; msg.Text = "Bạn đã gửi liên hệ thành công!"; Response.Write("<script>alert('Bạn đã gửi liên hệ thành công!')</script>"); } catch (Exception ex) { msg.ForeColor = System.Drawing.Color.Red; msg.Text = " khong them duoc, co loi:" + ex.Message; } }
public int updateContact(Guid id, string firstName, string lastName, string company, string title, string personelNote) { if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName)) { return(0); } contacts updateData = new contacts(); updateData.id = id; updateData.firstName = firstName; updateData.lastName = lastName; updateData.company = company; updateData.title = title; updateData.personelNote = personelNote; using (contactDatabaseLogicLayer contactDatabase = new contactDatabaseLogicLayer()) { return(contactDatabase.updateContact(updateData)); } }
public int updateContact(contacts c) { try { cmd = new SqlCommand(@"update contacts Set cName = @cName, cSurname = @cSurname, numberI = @numberI, numberII = @numberII, numberIII = @numberIII, emailAdress = @emailAdress, webAdress = @webAdress, adress = @adress, info = @info where id= @id ", con); cmd.Parameters.Add("@id", SqlDbType.UniqueIdentifier).Value = c.id; cmd.Parameters.Add("@cName", SqlDbType.NVarChar).Value = c.cName; cmd.Parameters.Add("@cSurname", SqlDbType.NVarChar).Value = c.cSurname; cmd.Parameters.Add("@numberI", SqlDbType.NVarChar).Value = c.numberI; cmd.Parameters.Add("@numberII", SqlDbType.NVarChar).Value = c.numberII; cmd.Parameters.Add("@numberIII", SqlDbType.NVarChar).Value = c.numberIII; cmd.Parameters.Add("@emailAdress", SqlDbType.NVarChar).Value = c.emailAdress; cmd.Parameters.Add("@webAdress", SqlDbType.NVarChar).Value = c.webAdress; cmd.Parameters.Add("@adress", SqlDbType.NVarChar).Value = c.adress; cmd.Parameters.Add("@info", SqlDbType.NVarChar).Value = c.info; SetConnection(); ReturnValues = cmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { SetConnection(); } return(ReturnValues); }
private void btnStart_Click(object sender, RoutedEventArgs e) { using (llblanca_lara1Entities db = new llblanca_lara1Entities()) { contacts contact = new contacts { value = txtContact.Text, user_id = _id, type_id = cmbType.SelectedIndex + 1 }; try { db.contacts.Add(contact); db.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } this.Close(); }
public List <contacts> contacts() { List <contacts> li = new List <contacts>(); string strSql = " select * from contacts ORDER BY contact_id DESC"; con.Open(); SqlCommand cmd = new SqlCommand(strSql, con); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { contacts s = new contacts(); s.contact_id = (int)rd["contact_id"]; s.fullname = (string)rd["fullname"]; s.phone = (string)rd["phone"]; s.email = (string)rd["email"]; s.message = (string)rd["message"]; li.Add(s); } con.Close(); return(li); }
private void btnRemoveContact_Click(object sender, RoutedEventArgs e) { try { string value = lstContacts.SelectedValue.ToString().Split(':')[1].TrimStart(' '); MessageBoxResult result = MessageBox.Show($"Вы точно уверены, что хотите удалить Contact {value}?", "Delete", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { using (llblanca_lara1Entities db = new llblanca_lara1Entities()) { contacts contact = db.contacts.Where(c => c.value == value).FirstOrDefault(); db.contacts.Remove(contact); db.SaveChanges(); MessageBox.Show($"Contact {contact} is delete"); FillingFromDB(); } } } catch (Exception ex) { MessageBox.Show("Contact is not selected"); } }