public IHttpActionResult PostContactsInfo(ContactsInfo contactsInfo) { logger.Info("This is the POST Request to API to update Contact"); if (!ModelState.IsValid) { logger.Error(BadRequest(ModelState)); return(BadRequest(ModelState)); } db.ContactsInfos.Add(contactsInfo); try { db.SaveChanges(); logger.Info("Database changes committed successfully"); } catch (Exception e) { var ex = e.InnerException.InnerException.Message; if (ex.Contains(hardCodedObjects.datetimeConflict)) { logger.Fatal(BadRequest("DOB Value Out of Range.")); return(BadRequest("DOB Value Out of Range.")); } else { logger.Fatal(BadRequest(ex.ToString())); return(BadRequest(ex.ToString())); } } logger.Info("POST request for contacts executed successfully"); return(Ok()); }
public IHttpActionResult PutContactsInfo(int id, ContactsInfo contactsInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != contactsInfo.ID) { return(BadRequest()); } db.Entry(contactsInfo).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ContactsInfoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create(ContactInfo Add) { if (Session["Username"] == null && Session["Password"] == null) { return(RedirectToAction("Index", "Admin", new { area = "" })); } else { if (ModelState.IsValid) { ContactsInfo AddContactInfo = new ContactsInfo(); AddContactInfo.Title = Add.Title; AddContactInfo.Contact_Cell = Add.Contact_Cell; AddContactInfo.Contact_Phone = Add.Contact_Phone; AddContactInfo.Contact_Email = Add.Contact_Email; AddContactInfo.Contact_Website = Add.Contact_Website; AddContactInfo.Contact_Location = Add.Contact_Location; AddContactInfo.Contact_Address = Add.Contact_Address; AddContactInfo.Date = DateTime.Today.ToString("dd-MM-yyyy"); AddContactInfo.Month = DateTime.Today.ToString("MMM"); AddContactInfo.Year = DateTime.Today.ToString("yyyy"); AddContactInfo.Time = DateTime.Now.ToString("HH:mm:ss"); new Cateloge().AddContactInfo(AddContactInfo); TempData["Msg"] = "New Contact Info Have Added Successfully"; return(RedirectToAction("Index")); } return(View(Add)); } }
public ActionResult Publish(ContactInfo pci, int id) { if (Session["Username"] == null && Session["Password"] == null) { return(RedirectToAction("Index", "Admin", new { area = "" })); } else { if (ModelState.IsValid) { ContactsInfo PublishContactInfo = new ContactsInfo(); PublishContactInfo.Publish = pci.Publish; new Cateloge().PublishContactInfo(PublishContactInfo, id); if (pci.Publish == "2") { TempData["Msg"] = "This Contact Have Published Successfully"; } else { TempData["Msg"] = "This Contact Have Blocked Successfully"; } return(RedirectToAction("View", new { id = id })); } return(RedirectToAction("Index")); } }
public ActionResult Edit(ContactInfo Update, int id) { if (Session["Username"] == null && Session["Password"] == null) { return(RedirectToAction("Index", "Admin", new { area = "" })); } else { if (ModelState.IsValid) { ContactsInfo UpdateContactInfo = new ContactsInfo(); UpdateContactInfo.Title = Update.Title; UpdateContactInfo.Contact_Cell = Update.Contact_Cell; UpdateContactInfo.Contact_Phone = Update.Contact_Phone; UpdateContactInfo.Contact_Email = Update.Contact_Email; UpdateContactInfo.Contact_Website = Update.Contact_Website; UpdateContactInfo.Contact_Location = Update.Contact_Location; UpdateContactInfo.Contact_Address = Update.Contact_Address; new Cateloge().UpdateContactInfo(UpdateContactInfo, id); TempData["Msg"] = "Contact Have Updated Successfully"; return(RedirectToAction("Index")); } return(View(Update)); } }
public bool IsEquals(ContactsInfo ci) { bool have = false; con.Open(); string sql = String.Format("select name from Contacts where name='{0}'", ci.Contacts); MySqlCommand cmd = new MySqlCommand(sql, con); MySqlDataReader msrd; msrd = cmd.ExecuteReader(); string result = null; while (msrd.Read()) { for (int ct = 0; ct < msrd.FieldCount; ct++) { result = msrd[ct].ToString(); } } if (result == null) { } else { have = true; } con.Close(); return(have); }
private void AddProducts(int index, int count) { Random r = new Random(); Assembly assembly = typeof(MainPage).GetTypeInfo().Assembly; for (int i = index; i < index + count; i++) { if (i % 2 == 0) { var contact = new Contacts(CustomerNames[r.Next(1, 120)], r.Next(720, 799).ToString() + " - " + r.Next(3010, 3999).ToString()); contact.ContactImage = ImageSource.FromResource("ListViewPrism.Images.Image" + r.Next(0, 28) + ".png", assembly); contact.ContactColor = Color.FromRgb(r.Next(40, 255), r.Next(40, 255), r.Next(40, 255)); contact.TemplateType = TemplateType.TemplateOne; ContactsInfo.Add(contact); } else { var contact = new Contacts(CustomerNames[r.Next(1, 120)], r.Next(720, 799).ToString() + " - " + r.Next(3010, 3999).ToString()); contact.ContactImage = ImageSource.FromResource("ListViewPrism.Images.Image" + r.Next(0, 28) + ".png", assembly); contact.ContactColor = Color.FromRgb(r.Next(40, 255), r.Next(40, 255), r.Next(40, 255)); contact.TemplateType = TemplateType.TemplateTwo; ContactsInfo.Add(contact); } } }
private List <ContactsInfo> fetchContactsInfo(SqlCommand cmd) { SqlConnection con = cmd.Connection; List <ContactsInfo> contactsinfo = null; con.Open(); using (con) { SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { contactsinfo = new List <ContactsInfo>(); while (dr.Read()) { ContactsInfo ci = new ContactsInfo(); ci.db_Id = Convert.ToString(dr["id"]); ci.Title = Convert.ToString(dr["title"]); ci.Contact_Cell = Convert.ToString(dr["contact_c"]); ci.Contact_Phone = Convert.ToString(dr["contact_p"]); ci.Contact_Email = Convert.ToString(dr["contact_e"]); ci.Contact_Website = Convert.ToString(dr["contact_w"]); ci.Contact_Location = Convert.ToString(dr["contact_l"]); ci.Contact_Address = Convert.ToString(dr["contact_a"]); ci.Publish = Convert.ToString(dr["publish"]); contactsinfo.Add(ci); } contactsinfo.TrimExcess(); } } return(contactsinfo); }
public void PublishContactInfo(ContactsInfo pci, int id) { SqlCommand cmd = new SqlCommand("Update contact_info Set publish=@Publish Where id = @Id", DALUtil.getConnection()); cmd.Parameters.AddWithValue("@Id", id); cmd.Parameters.AddWithValue("@Publish", (pci.Publish == null) ? Convert.DBNull : pci.Publish); contactInfo(cmd); }
public ActionResult Edit([Bind(Include = "Id,CompanyName,Phone,Address,YandexMapUrl")] ContactsInfo contactsInfo) { if (ModelState.IsValid) { db.Entry(contactsInfo).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Edit")); } return(View(contactsInfo)); }
public int AddCt(ContactsInfo ci) { con.Open(); string sql = String.Format("INSERT INTO Contacts VALUES ('{0}', '{1}', '{2}','{3}','{4}','{5}','{6}','{7}')", null, ci.Contacts, ci.English_name, ci.Job, ci.Phone, ci.Mophone, ci.Email, ci.Fax); MySqlCommand cmd = new MySqlCommand(sql, con); int iRet = cmd.ExecuteNonQuery();//这里返回的是受影响的行数,为int值。可以根据返回的值进行判断是否插入成功。 con.Close(); return(iRet); }
public IHttpActionResult GetContactsInfo(int id) { ContactsInfo contactsInfo = db.ContactsInfos.Find(id); if (contactsInfo == null) { return(NotFound()); } return(Ok(contactsInfo)); }
public void GenerateInfo() { Random r = new Random(); for (int i = 0; i < 30; i++) { var contact = new Contacts(CustomerNames[i], r.Next(720, 799).ToString() + " - " + r.Next(3010, 3999).ToString()); contact.ContactImage = ImageSource.FromResource("ListViewXamarin.Images.Image" + r.Next(0, 28) + ".png"); ContactsInfo.Add(contact); } }
public IHttpActionResult GetContactsInfo(int id) { ContactsInfo contactsInfo = db.ContactsInfos.Find(id); if (contactsInfo == null) { logger.Error(NotFound()); return(NotFound()); } logger.Info("Fetched the records for Contact ID: " + id); return(Ok(contactsInfo)); }
public IHttpActionResult PostContactsInfo(ContactsInfo contactsInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ContactsInfos.Add(contactsInfo); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = contactsInfo.ID }, contactsInfo)); }
private void GeneratePersonalContacts() { contactsInfo = new ObservableCollection <Contacts>(); Random r = new Random(); for (int i = 0; i < CustomerNames.Count(); i++) { var contact1 = new Contacts(CustomerNames[i], i.ToString()); contact1.ContactImage = ImageSource.FromResource("Scrolling.Images.Image" + r.Next(0, 28) + ".png"); contact1.ContactType = "Personal"; ContactsInfo.Add(contact1); } }
private void OnChangeItemsSource(object obj) { if (IsVisible) { IsVisible = false; GenerateSource(); } else { ContactsInfo.Clear(); IsVisible = true; } }
public IHttpActionResult DeleteContactsInfo(int id) { ContactsInfo contactsInfo = db.ContactsInfos.Find(id); if (contactsInfo == null) { return(NotFound()); } db.ContactsInfos.Remove(contactsInfo); db.SaveChanges(); return(Ok(contactsInfo)); }
public void UpdateContactInfo(ContactsInfo uci, int id) { SqlCommand cmd = new SqlCommand("Update contact_info Set title=@Title , contact_c=@Contact_C , contact_p=@Contact_P , contact_e=@Contact_E , contact_w=@Contact_W , contact_l=@Contact_L , contact_a=@Contact_A Where id = @Id", DALUtil.getConnection()); cmd.Parameters.AddWithValue("@Id", id); cmd.Parameters.AddWithValue("@Title", (uci.Title == null) ? Convert.DBNull : uci.Title); cmd.Parameters.AddWithValue("@Contact_C", (uci.Contact_Cell == null) ? Convert.DBNull : uci.Contact_Cell); cmd.Parameters.AddWithValue("@Contact_P", (uci.Contact_Phone == null) ? Convert.DBNull : uci.Contact_Phone); cmd.Parameters.AddWithValue("@Contact_E", (uci.Contact_Email == null) ? Convert.DBNull : uci.Contact_Email); cmd.Parameters.AddWithValue("@Contact_W", (uci.Contact_Website == null) ? Convert.DBNull : uci.Contact_Website); cmd.Parameters.AddWithValue("@Contact_L", (uci.Contact_Location == null) ? Convert.DBNull : uci.Contact_Location); cmd.Parameters.AddWithValue("@Contact_A", (uci.Contact_Address == null) ? Convert.DBNull : uci.Contact_Address); contactInfo(cmd); }
public IHttpActionResult DeleteContactsInfo(int id) { logger.Info("This is the DELETE Request to API to delete contact"); ContactsInfo contactsInfo = db.ContactsInfos.Find(id); if (contactsInfo == null) { logger.Error(NotFound()); return(NotFound()); } db.ContactsInfos.Remove(contactsInfo); db.SaveChanges(); logger.Info("Database changes committed successfully"); logger.Info("DELETE request for contacts executed successfully for " + Ok(contactsInfo)); return(Ok(contactsInfo)); }
public void GenerateSource() { Random random = new Random(); Assembly assembly = typeof(MainPage).GetTypeInfo().Assembly; for (int i = 0; i < CustomerNames.Count(); i++) { var details = new ListViewContactsInfo() { ContactType = contactType[random.Next(0, 5)], ContactNumber = random.Next(100, 400).ToString() + "-" + random.Next(500, 800).ToString() + "-" + random.Next(1000, 2000).ToString(), ContactName = CustomerNames[i], ContactImage = ImageSource.FromResource("SfListViewSample.Images.Image" + random.Next(0, 28) + ".png", assembly), }; ContactsInfo.Add(details); } }
public void AddContactInfo(ContactsInfo ci) { SqlCommand cmd = new SqlCommand("INSERT into contact_info (title,contact_c,contact_p,contact_e,contact_w,contact_l,contact_a,date,month,year,time) VALUES (@Title,@Contact_C,@Contact_P,@Contact_E,@Contact_W,@Contact_L,@Contact_A,@Date,@Month,@Year,@Time)", DALUtil.getConnection()); cmd.Parameters.AddWithValue("@Title", (ci.Title == null) ? Convert.DBNull : ci.Title); cmd.Parameters.AddWithValue("@Contact_C", (ci.Contact_Cell == null) ? Convert.DBNull : ci.Contact_Cell); cmd.Parameters.AddWithValue("@Contact_P", (ci.Contact_Phone == null) ? Convert.DBNull : ci.Contact_Phone); cmd.Parameters.AddWithValue("@Contact_E", (ci.Contact_Email == null) ? Convert.DBNull : ci.Contact_Email); cmd.Parameters.AddWithValue("@Contact_W", (ci.Contact_Website == null) ? Convert.DBNull : ci.Contact_Website); cmd.Parameters.AddWithValue("@Contact_L", (ci.Contact_Location == null) ? Convert.DBNull : ci.Contact_Location); cmd.Parameters.AddWithValue("@Contact_A", (ci.Contact_Address == null) ? Convert.DBNull : ci.Contact_Address); cmd.Parameters.AddWithValue("@Date", (ci.Date == null) ? Convert.DBNull : ci.Date); cmd.Parameters.AddWithValue("@Month", (ci.Month == null) ? Convert.DBNull : ci.Month); cmd.Parameters.AddWithValue("@Year", (ci.Year == null) ? Convert.DBNull : ci.Year); cmd.Parameters.AddWithValue("@Time", (ci.Time == null) ? Convert.DBNull : ci.Time); contactInfo(cmd); }
public void UpdateContact() { var controller = new ContactsController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); //IQueryable<ContactsInfo> response = controller.GetContactsInfosBasedOnUser(1, null); //var id = response.Select(i => i.ID).ToList(); ContactsInfo Update = new ContactsInfo { fullName = "test01", nickName = "test", emailID = "*****@*****.**", dob = Convert.ToDateTime("09/03/1989"), address = "Canada", //ID = id[0] }; var update = controller.PutContactsInfo(1, Update); Assert.AreEqual(HttpStatusCode.BadRequest, update.ExecuteAsync(CancellationToken.None).Result.StatusCode); }
public IHttpActionResult PutContactsInfo(int id, ContactsInfo contactsInfo) { logger.Info("This is the PUT Request to API to update the contact information"); if (!ModelState.IsValid) { logger.Error(BadRequest(ModelState)); return(BadRequest(ModelState)); } if (id != contactsInfo.ID) { logger.Error(BadRequest()); return(BadRequest()); } db.Entry(contactsInfo).State = EntityState.Modified; try { db.SaveChanges(); logger.Info("Database changes committed successfully"); } catch (DbUpdateConcurrencyException) { if (!ContactsInfoExists(id)) { logger.Error(NotFound()); return(NotFound()); } else { logger.Fatal("Error occured while committing DB changes"); throw; } } logger.Info("PUT request for contact executed successfully"); return(StatusCode(HttpStatusCode.NoContent)); }
public bool Add(ContactsInfo ci, out string msg) { msg = null; bool isSuccess = false; if (ci.Contacts.Trim().Length != 0 || ci.Email.Trim().Length != 0 || ci.English_name.Trim().Length != 0 || ci.Fax.Trim().Length != 0 || ci.Job.Trim().Length != 0 || ci.Mophone.Trim().Length != 0 || ci.Phone.Trim().Length != 0) //判断从传递来的username是否为空 { if (!cd.IsEquals(ci)) //传给DALl操作判断数据库中是否有重复值 { cd.AddCt(ci); //传给DAL操作增加一个新用户 isSuccess = true; } else { msg = "有相同的值"; } } else { msg = "不能为空"; } return(isSuccess);//返回界面层是否添加成功 }
private void button1_Click(object sender, EventArgs e) { ci = new ContactsInfo() { Contacts = name.Text, English_name = engname.Text, Job = job.Text, Phone = phone.Text, Mophone = mophone.Text, Email = email.Text, Fax = fax.Text }; string messageStr = null; if (cm.Add(ci, out messageStr)) { MessageBox.Show("添加联系人成功"); this.Hide(); } else { MessageBox.Show(messageStr); } }
public int EditSup([FromForm] SupplierInfo supplier, [FromForm] ContactsInfo contacts) { return(_bll.EditSupplier(supplier, contacts)); }
//修改 public int EditSupplier(SupplierInfo supplier, ContactsInfo contacts) { string Gysid = supplier.GysId.ToString(); string Lxrid = contacts.LxrId.ToString(); //存储过程名称 string proc = "SP_Sup_Con_Edit"; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter { ParameterName = "@GysBianHao", Value = supplier.GID, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@LaiYuan", Value = supplier.GLaiYuan, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@FuZeRen", Value = supplier.YJfzr, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@DanWei", Value = supplier.DwName, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@PinPai", Value = supplier.PinPai, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@GDesc", Value = supplier.GDesc, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@FanWei", Value = supplier.JYRange, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@GysId", Value = Gysid, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@LxrName", Value = contacts.LxrName, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@LxrId", Value = Lxrid, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@LJob", Value = contacts.LJob, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@Phone", Value = contacts.Phone, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@Email", Value = contacts.Email, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@GDphone", Value = contacts.GDphone, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@ChuanZhen", Value = contacts.ChuanZhen, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@QQ", Value = contacts.QQ, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@WeiXin", Value = contacts.WeiXin, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@Addresss", Value = contacts.Addresss, DbType = DbType.String, Direction = ParameterDirection.Input }, new SqlParameter { ParameterName = "@Url", Value = contacts.Url, DbType = DbType.String, Direction = ParameterDirection.Input }, }; return(_db.ExecuteNonQueryProc(proc, parameters)); }
public static IEnumerable <OpenXmlElement> GetSection(ContactsInfo Contacts) { List <OpenXmlElement> sectionParts = new List <OpenXmlElement>(); if (Contacts?.Contacts.Count > 0) { sectionParts.Add(ParagraphHelper.Paragraph("Contacts", LSSDDocumentStyles.SectionTitle)); foreach (Contact contact in Contacts.Contacts) { sectionParts.Add( TableHelper.StyledTableBordered( TableHelper.StickyTableRow( TableHelper.LabelCell("Name:"), TableHelper.ValueCell(contact.GetDisplayName(), JustificationValues.Left).WithColspan(5) ), TableHelper.StickyTableRow( TableHelper.LabelCell("Relation:", JustificationValues.Left).WithWidth(15), TableHelper.ValueCell(contact.RelationshipToStudent), TableHelper.LabelCell("Email:"), TableHelper.ValueCell(contact.EmailAddress), TableHelper.LabelCell("Lives With:"), TableHelper.ValueCell(contact.LivesWithStudent) ), TableHelper.StickyTableRow( TableHelper.LabelCell("Priority:"), TableHelper.ValueCell(contact.ContactPriority.ToString()), TableHelper.LabelCell("Employer:"), TableHelper.ValueCell(contact.Employer), TableHelper.LabelCell("Rcv. Mail:"), TableHelper.ValueCell(contact.ShouldRecieveMailAboutStudent) ), TableHelper.StickyTableRow( TableHelper.LabelCell("Notes:"), TableHelper.ValueCell(contact.Note, JustificationValues.Left).WithColspan(5) ), TableHelper.StickyTableRow( TableHelper.LabelCell("Contact:", JustificationValues.Left).WithColspan(2).WithWidth(33.3), TableHelper.LabelCell("Primary Addr:", JustificationValues.Left).WithColspan(2).WithWidth(33.3), TableHelper.LabelCell("Mailing Addr:", JustificationValues.Left).WithColspan(2).WithWidth(33.3) ), TableHelper.StickyTableRow( TableHelper.ValueCell(phoneNumberBlob(contact.HomePhone, contact.WorkPhone, contact.CellPhone, contact.AlternateContactInfo)).WithColspan(2), TableHelper.ValueCell(ParagraphHelper.ConvertMultiLineString(contact.PrimaryAddress.ToFormattedAddress()), JustificationValues.Left).WithColspan(2), TableHelper.ValueCell(ParagraphHelper.ConvertMultiLineString(contact.MailingAddress.ToFormattedAddress()), JustificationValues.Left).WithColspan(2) ) ) ); sectionParts.Add( ParagraphHelper.WhiteSpace() ); } } else { sectionParts.Add( ParagraphHelper.Paragraph("No contact information entered", LSSDDocumentStyles.FieldValue) ); } sectionParts.Add(ParagraphHelper.WhiteSpace()); return(sectionParts); }
public void InsertContact(ContactsInfo contact) { _databasehelper.InsertContact(contact); }