Exemple #1
0
 public Model.Contact AddContact(Model.Contact contact)
 {
     Validate("firstName", contact.FirstName);
     Validate("lastName", contact.LastName);
     Validate("phoneNumber", contact.PhoneNumber);
     Validate("emailId", contact.EmailId);
     try
     {
         using (BlahEntities entity = new BlahEntities())
         {
             Contact contactToAdd = new Contact()
             {
                 EmailId     = contact.EmailId,
                 FirstName   = contact.FirstName,
                 LastName    = contact.LastName,
                 PhoneNumber = contact.PhoneNumber,
                 Status      = (bool)contact.Status,
             };
             Contact result = entity.Contacts.Add(contactToAdd);
             int     added  = entity.SaveChanges();
             if (added <= 0)
             {
                 throw new ApplicationException("Record Not updated");
             }
         }
     }
     catch (Exception exception)
     {
         throw new ApplicationException(exception.Message);
     }
     return(contact);
 }
        public Model.Contact EditContact(string emailId, Model.Contact contact)
        {
            Validate("emailId", emailId);
            Validate("emailId", contact.EmailId);
            try
            {
                using (BlahEntities entity = new BlahEntities())
                {
                    Contact item = entity.Contacts.FirstOrDefault(x => x.EmailId.Equals(emailId, System.StringComparison.OrdinalIgnoreCase));

                    if (item != null)
                    {
                        item.FirstName   = contact.FirstName;
                        item.LastName    = contact.LastName;
                        item.PhoneNumber = contact.PhoneNumber;
                        item.Status      = (bool)contact.Status;
                    }
                    int k = entity.SaveChanges();
                    if (k <= 0)
                    {
                        throw new ApplicationException("Record Not updated");
                    }
                }
                contact.EmailId = emailId;
            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return(contact);
        }
        public void TenantCreate()
        {
            Boolean test = false;

            Console.WriteLine(test);
            var Contact = new Model.Contact()
            {
                AcceptTermsOfService = true,
                Email     = "*****@*****.**",
                Facebook  = "facebook url",
                FirstName = "John",
                LastName  = "Doe",
                IsActive  = true,
                Language  = "Fr",
                Linkedin  = "LinkedinUrl",
                Phone     = "0707070707",
                Viadeo    = "viadeoUrl",
                Website   = "websiteUrl",
                StatusId  = 3,
                Image     = new Model.Image()
                {
                    CreatedById = 1,
                    CreatedOn   = DateTime.Now,
                    PathUrl     = ""
                }
            };
            var Address = new Model.Address()
            {
                Address1    = "Address 1 - N° et rue",
                Address2    = "Address 2",
                Country     = "France",
                Province    = "Province",
                Zip         = "11111",
                CreatedById = 1
            };
            var Address1 = new Model.Address()
            {
                Address1    = "Address 1 - N° et rue",
                Address2    = "Address 2",
                Country     = "France",
                Province    = "Province",
                Zip         = "11111",
                CreatedById = 1
            };
            Tenant _tenant = new Tenant
            {
                CreatedOn       = DateTime.Now,
                UpdatedOn       = DateTime.Now,
                IsActive        = true,
                StatusId        = 3,
                BillingAddress  = Address,
                ShippingAddress = Address1,
                Contact         = Contact,
                CurrencyId      = 2
            };

            var isCreated = _tenantCore.Create(_tenant).Result;

            Assert.IsTrue(isCreated);
        }
        private void FormContactDetail_Load(object sender, EventArgs e)
        {
            FillGroup();
            txtId.Text = id.ToString();

            BLL.Contact   bll   = new BLL.Contact();
            Model.Contact model = bll.GetModel(id);

            if (model == null)
            {
                MessageBox.Show("数据查询出错");
                return;
            }
            else
            {
                txtName.Text        = model.Name;
                txtPhone.Text       = model.Phone;
                txtEmail.Text       = model.Email;
                txtQQ.Text          = model.QQ;
                txtWorkUnit.Text    = model.WorkUnit;
                txtOfficePhone.Text = model.OfficePhone;
                txtHomeAddress.Text = model.HomeAddress;
                txtHomePhone.Text   = model.HomePhone;
                txtMemo.Text        = model.Memo;

                cboGroup.SelectedValue = model.GroupId;
            }
        }
Exemple #5
0
        public static Dictionary <string, Model.Contact> RetreiveAllContact()
        {
            Dictionary <string, Model.Contact> contacts = new Dictionary <string, Model.Contact>();

            NKTWABLib.NKTWAB NKT        = new NKTWABLib.NKTWAB();
            NKTWABLib.Folder rootFolder = NKT.RootFolder;

            NKTWABLib.ContactContainer contCont = (NKTWABLib.ContactContainer)NKT.get_Item(rootFolder.Folders.get_Item(1).EntryID);
            //ComctlLib.Node tvItem = new ComctlLib.Node();

            for (int i = 1; i <= contCont.Contacts.Count; i++)
            {
                Model.Contact contact = new Model.Contact();

                NKTWABLib.Contact item = contCont.Contacts.get_Item(i);
                contact.FullName = item.Name;

                contact.Address     = item.HomeAddressCity;
                contact.HomePhone   = item.HomeTelephoneNumber;
                contact.MobilePhone = item.MobileTelephoneNumber;
                contact.Email       = item.Email1Address;

                contact.BusinessPhone = item.BusinessTelephoneNumber;
                contact.BusinessFax   = item.BusinessFaxNumber;
                contact.IPPhone       = "";


                if (!contacts.ContainsKey(contact.FullName))
                {
                    contacts.Add(contact.FullName, contact);
                }
            }

            return(contacts);
        }
        public void UpdateUserProfile(Model.Contact contact)
        {
            _DirectorySearcher.Filter      = "(SAMAccountName=" + contact.Username + ")";
            _DirectorySearcher.SearchScope = SearchScope.Subtree;
            SearchResult   result = _DirectorySearcher.FindOne();
            DirectoryEntry d      = new DirectoryEntry();

            d.Path = result.Path;

            d.Properties["telephoneNumber"].Value = contact.BusinessPhone.Equals("")? null : contact.BusinessPhone;
            d.CommitChanges();

            d.Properties["facsimileTelephoneNumber"].Value = contact.BusinessFax.Equals("")? null : contact.BusinessFax;
            d.CommitChanges();

            d.Properties["Mobile"].Value = contact.MobilePhone.Equals("")? null : contact.MobilePhone;
            d.CommitChanges();

            d.Properties["homePostalAddress"].Value = contact.Address.Equals("") ? null : contact.Address;
            d.CommitChanges();

            d.Properties["homePhone"].Value = contact.HomePhone.Equals("")? null : contact.HomePhone;
            d.CommitChanges();

            d.Properties["ipPhone"].Value = contact.IPPhone.Equals("") ? null : contact.IPPhone;
            d.CommitChanges();

            d.Properties["mail"].Value = contact.Email.Equals("") ? null : contact.Email;
            d.CommitChanges();
        }
        public Model.Contact GetVisitorDetails()
        {
            if (!ContactIdentified)
            {
                return(new Model.Contact());
            }

            var visitorDetails = new Model.Contact
            {
                ContactId = CurrentContact.ContactId.ToString(),
                FirstName = PersonalInfo.FirstName,
                LastName  = PersonalInfo.Surname
            };

            var contactEmail = GetContactEmail();

            if (contactEmail != null)
            {
                visitorDetails.EmailAddress = contactEmail.SmtpAddress;
            }

            var contactPhone = GetContactPhone();

            if (contactPhone != null)
            {
                visitorDetails.Phone = contactPhone.Number;
            }

            visitorDetails.OptIn = Interactions.PremiumContent.Unlocked;

            return(visitorDetails);
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            Model.Contact model = new Model.Contact();

            model.Id          = id;
            model.Name        = txtName.Text.Trim();
            model.Phone       = txtPhone.Text.Trim();
            model.Email       = txtEmail.Text.Trim();
            model.QQ          = txtQQ.Text.Trim();
            model.WorkUnit    = txtWorkUnit.Text.Trim();
            model.OfficePhone = txtOfficePhone.Text.Trim();
            model.HomeAddress = txtHomeAddress.Text.Trim();
            model.HomePhone   = txtHomePhone.Text.Trim();
            model.Memo        = txtMemo.Text.Trim();
            model.GroupId     = Convert.ToInt32(cboGroup.SelectedValue);

            BLL.Contact dll = new BLL.Contact();
            string      msg = "";

            if (dll.Update(model, out msg))
            {
                MessageBox.Show("更新成功!");
            }
            else
            {
                MessageBox.Show(msg);
            }
        }
        public Model.Contact GetContact(string emailId)
        {
            Validate("emailId", emailId);
            Model.Contact contact = null;

            using (BlahEntities entity = new BlahEntities())
            {
                Contact item = null;
                try
                {
                    item = entity.Contacts.FirstOrDefault(x => x.EmailId.ToLower() == emailId);
                }
                catch (Exception exception)
                {
                    throw new ApplicationException(exception.Message);
                }
                if (item != null)
                {
                    contact = new Model.Contact()
                    {
                        EmailId     = item.EmailId,
                        FirstName   = item.FirstName,
                        LastName    = item.LastName,
                        PhoneNumber = item.PhoneNumber,
                        Status      = (bool)item.Status
                    };
                }
                else
                {
                    throw new ArgumentException("no data found for" + emailId);
                }
            }

            return(contact);
        }
Exemple #10
0
        public void RetrieveContact_Test_Result()
        {
            var repositoryMoq = new Moq.Mock <IContactRepository>();
            var contact       = new Model.Contact()
            {
                EmailId     = "*****@*****.**",
                FirstName   = "anand",
                LastName    = "lukade",
                PhoneNumber = "8007891986",
                Status      = true
            };

            repositoryMoq.Setup(s => s.GetContact("*****@*****.**")).Returns(contact);
            var controller = new ContactsController(repositoryMoq.Object);

            controller.Request = new HttpRequestMessage
            {
                RequestUri = new Uri(
                    String.Format("http://localhost/contacts?emailId={0}/contact",
                                  "*****@*****.**"))
            };


            IHttpActionResult actionResult = controller.RetrieveContact("*****@*****.**");
            var contentResult = actionResult as OkNegotiatedContentResult <Http.Contact>;

            Assert.AreEqual(contact.EmailId, contentResult.Content.EmailId);
        }
        //修改一条记录
        public bool Modify(Model.Contact model)
        {
            string        str      = "Server=.;database=asset_management_system;Integrated Security=sspi";
            string        Myquery1 = "";
            SqlConnection myconn   = new SqlConnection(str);

            myconn.Open();
            switch (model.Table)
            {
            case "department": Myquery1 = "update " + model.Table + " set id = '" + model.Id + "', department = '" + model.Departments + "', start_time = '" + model.scrap_date + "', end_time = '" + model.End_time + "', recorder = '" + model.Recorder + "', inspecter = '" + model.Inspecter + "', reason  = '" + model.Reason + "' where id = '" + model.Id + "' and department = '" + model.Old_departments + "' and start_time = '" + model.Old_start_time + "' and end_time = '" + model.Old_end_time + "'"; break;

            case "repair": Myquery1 = "update " + model.Table + " set id = '" + model.Id + "', money = '" + model.Money + "', start_time = '" + model.scrap_date + "', end_time = '" + model.End_time + "', recorder = '" + model.Recorder + "', inspecter = '" + model.Inspecter + "', repair_reason  = '" + model.Repair_reason + "', reason  = '" + model.Reason + "' where id = '" + model.Id + "' and money = '" + model.Old_money + "' and start_time = '" + model.Old_start_time + "' and end_time = '" + model.Old_end_time + "'"; break;

            case "accumulated_depreciation": Myquery1 = "update " + model.Table + " set id = '" + model.Id + "', now = '" + model.Now + "', date = '" + model.Date + "', recorder = '" + model.Recorder + "', inspecter = '" + model.Inspecter + "', reason  = '" + model.Reason + "' where id = '" + model.Id + "' and now = '" + model.Old_money + "' and date = '" + model.Old_date + "'"; break;

            case "value_decrease": Myquery1 = "update " + model.Table + " set id = '" + model.Id + "', sum = '" + model.Sum + "', date = '" + model.Date + "', recorder = '" + model.Recorder + "', inspecter = '" + model.Inspecter + "', reason  = '" + model.Reason + "' where id = '" + model.Id + "' and sum = '" + model.Old_money + "' and date = '" + model.Old_date + "'"; break;

            case "scrap": Myquery1 = "update " + model.Table + " set id = '" + model.Id + "', name = '" + model.Name + "', buy_price = '" + model.Buy_price + "', buy_date = '" + model.Buy_date + "', scrap_date = '" + model.Scrap_date + "', recorder = '" + model.Recorder + "', inspecter  = '" + model.Inspecter + "', reason  = '" + model.Reason + "' where id = '" + model.Id + "' and name = '" + model.Old_name + "' and buy_price = '" + model.Old_money + "' and buy_date = '" + model.Old_date + "' and scrap_date = '" + model.Old_start_time + "'"; break;

            case "rent": Myquery1 = "update " + model.Table + " set id = '" + model.Id + "', tenant = '" + model.Tenant + "', start_time = '" + model.scrap_date + "', end_time = '" + model.End_time + "', recorder = '" + model.Recorder + "', inspecter = '" + model.Inspecter + "', reason  = '" + model.Reason + "' where id = '" + model.Id + "' and tenant = '" + model.Old_tenant + "' and start_time = '" + model.Old_start_time + "' and end_time = '" + model.Old_end_time + "'"; break;
            }
            SqlCommand mycmd1 = new SqlCommand(Myquery1, myconn);
            int        result = mycmd1.ExecuteNonQuery();

            if (result == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            Model.Contact model = new Model.Contact();
            model.Id = id;
            model.Name = txtName.Text.Trim();
            model.Phone = txtPhone.Text.Trim();
            model.Email = txtEmail.Text.Trim();
            model.QQ = txtQQ.Text.Trim();
            model.WorkUnit = txtWorkUnit.Text.Trim();
            model.OfficePhone = txtOfficePhone.Text.Trim();
            model.HomeAddress = txtHomeAddress.Text.Trim();
            model.HomePhone = txtHomePhone.Text.Trim();
            model.Memo = txtMemo.Text.Trim();

            model.GroupId = Convert.ToInt32(cboGroup.SelectedValue);
            BLL.Contact bll = new BLL.Contact();
            string msg;
            if (bll.Update(model, out msg))
            {
                MessageBox.Show("修改成功!");
            }
            else
            {
                MessageBox.Show(msg);
            }
        }
        //修改summary表的剩余价值
        public static void change_remain_state(Model.Contact model)
        {
            string        str = "Server=.;database=asset_management_system;Integrated Security=sspi";
            String        Myquery1;
            SqlConnection myconn = new SqlConnection(str);

            myconn.Open();
            Myquery1 = "update summary set surplus_value= surplus_value - " + model.Now + " where id = '" + model.Id + "'";
            SqlCommand mycmd1 = new SqlCommand(Myquery1, myconn);
            int        result = mycmd1.ExecuteNonQuery();

            myconn.Close();
            ///gai
            myconn.Open();
            String Myquery2;

            Myquery2 = "select * from summary where id='" + model.Id + "'and surplus_value=0";
            SqlCommand    mycmd2  = new SqlCommand(Myquery2, myconn);
            SqlDataReader result1 = mycmd2.ExecuteReader();

            if (result1.HasRows)
            {
                myconn.Close();
                String Myquery3;
                Myquery3 = "update summary set situation='" + "报废" + "'" + " where id = '" + model.Id + "'";
                myconn.Open();
                SqlCommand mycmd3 = new SqlCommand(Myquery3, myconn);
                mycmd3.ExecuteNonQuery();
                String     Myquery4 = "update summary set discard_time='" + model.Date + "'" + " where id = '" + model.Id + "'";
                SqlCommand mycmd4   = new SqlCommand(Myquery4, myconn);
                mycmd4.ExecuteNonQuery();
            }
            myconn.Close();
        }
        public Model.Contact GetUserProfile(string username)
        {
            //Dictionary<string, Model.Contact> user=RetrieveAllContact("(sAMAccountName="+username+")",true);

            // return user[username];
            Model.Contact contact = new Model.Contact();

            _DirectorySearcher.Filter      = "(SAMAccountName=" + username + ")";
            _DirectorySearcher.SearchScope = SearchScope.Subtree;
            SearchResult result = _DirectorySearcher.FindOne();

            if (result != null)
            {
                contact.FullName      = result.Properties["displayName"][0].ToString();
                contact.BusinessPhone = result.Properties["telephoneNumber"].Count == 0 ? "" : result.Properties["telephoneNumber"][0].ToString();
                contact.BusinessFax   = result.Properties["facsimileTelephoneNumber"].Count == 0 ? "" : result.Properties["facsimileTelephoneNumber"][0].ToString();
                contact.MobilePhone   = result.Properties["Mobile"].Count == 0 ? "" : result.Properties["Mobile"][0].ToString();
                contact.Address       = result.Properties["homePostalAddress"].Count == 0 ? "" : result.Properties["homePostalAddress"][0].ToString();
                contact.HomePhone     = result.Properties["homePhone"].Count == 0 ? "" : result.Properties["homePhone"][0].ToString();
                contact.Email         = result.Properties["mail"].Count == 0 ? "" : result.Properties["mail"][0].ToString();
                contact.IPPhone       = result.Properties["ipPhone"].Count == 0 ? "" : result.Properties["ipPhone"][0].ToString();
            }

            return(contact);
        }
Exemple #15
0
        public static bool insertCont(Model.Contact contact)
        {
            bool status = false;

            try
            {
                // string sql = "UPDATE tbl_contact SET FirstName=@FirstName, LastName=@LastName, ContactNo=@ContactNo, Address=@Address, Gender=@Gender WHERE ContactID=@ContactID";
                //SqlCommand cmd = new SqlCommand(sql, conn);



                //  SqlCommand command = new SqlCommand("INSERT INTO Contact(FirstName, LastName, MobileNum, Email, Address, Notes, DateOfBirth) VALUES(@FirstName, @LastName, @MobileNum, @Email, @Address, @Notes, @DateOfBirth)", connection);
                //// SqlCommand command = new SqlCommand("INSERT INTO Contact(FirstName, LastName , MobileNum = @MobileNum, Email = @Email, Address = @Address, Notes = @Notes, DateOfBirth = @DateOfBirth)VALUES(@FirstName, @LastName, @MobileNum, @Email, @Address, @Notes, @DateOfBirth)", connection);


                connection.Open();
                builder.Append("Opened Connection to " + connection.ConnectionString);
                // Execute query

                SqlCommand command = new SqlCommand();
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.CommandText = "Insert_Contact";
                command.Connection  = connection;

                command.Parameters.AddWithValue("@FirstName", contact.FirstName);
                command.Parameters.AddWithValue("@LastName", contact.LastName);
                command.Parameters.AddWithValue("@MobileNum", contact.MobileNum);
                command.Parameters.AddWithValue("@Email", contact.Email);
                command.Parameters.AddWithValue("@Address", contact.Address);
                command.Parameters.AddWithValue("@Notes", contact.Notes);
                command.Parameters.AddWithValue("@DateOfBirth", contact.DateOfBirth);
                //  command.Parameters.AddWithValue("@ContactId", contact.ContactId);


                //using (SqlDataReader rdr = cmd.ExecuteReader())
                //{
                //    // iterate through results, printing each to console
                //    while (rdr.Read())
                //    {
                //        Console.WriteLine("Product: {0,-35} Total: {1,2}", rdr["ProductName"], rdr["Total"]);
                //    }
                //}

                command.ExecuteNonQuery();
                builder.Append("\nNew Record inserted into Contact table.");
                status = true;
            }
            catch (Exception e)
            {
                builder.Append("\nCouldn't insert record: " + e.ToString());
            }
            finally
            {
                connection.Close();
                builder.Append("\nConnection closed");
            }
            return(status);
        }
        public AddEditContactsModal(Model.Contact contactToUpdate)
		{
			this.InitializeComponent();

            _contactToUpdate = contactToUpdate;
            _isUpdateContact = contactToUpdate != null;

            if (_isUpdateContact)
            {
                PrepareWindowForUpdates();
            }
		}
        public bool EditContact(Model.Contact con)
        {
            var contact = _contactRepository.Get(c => c.Id == con.Id).FirstOrDefault();

            contact.FirstName = con.FirstName;
            contact.LastName  = con.LastName;
            contact.Email     = con.Email;

            _contactRepository.Update(contact);
            _contactRepository.Save();
            return(true);
        }
Exemple #18
0
        public bool Update(Model.Contact model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Contact set ");
            strSql.Append("Name=@Name,");
            strSql.Append("Phone=@Phone,");
            strSql.Append("Email=@Email,");
            strSql.Append("QQ=@QQ,");
            strSql.Append("WorkUnit=@WorkUnit,");
            strSql.Append("OfficePhone=@OfficePhone,");
            strSql.Append("HomeAddress=@HomeAddress,");
            strSql.Append("HomePhone=@HomePhone,");
            strSql.Append("Memo=@Memo,");
            strSql.Append("GroupId=@GroupId");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",        SqlDbType.NVarChar,  50),
                new SqlParameter("@Phone",       SqlDbType.VarChar,   11),
                new SqlParameter("@Email",       SqlDbType.NVarChar,  50),
                new SqlParameter("@QQ",          SqlDbType.VarChar,   20),
                new SqlParameter("@WorkUnit",    SqlDbType.NVarChar, 200),
                new SqlParameter("@OfficePhone", SqlDbType.VarChar,   20),
                new SqlParameter("@HomeAddress", SqlDbType.NVarChar, 200),
                new SqlParameter("@HomePhone",   SqlDbType.VarChar,   20),
                new SqlParameter("@Memo",        SqlDbType.NVarChar, 200),
                new SqlParameter("@GroupId",     SqlDbType.Int,        4),
                new SqlParameter("@Id",          SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.Name;
            parameters[1].Value  = model.Phone;
            parameters[2].Value  = model.Email;
            parameters[3].Value  = model.QQ;
            parameters[4].Value  = model.WorkUnit;
            parameters[5].Value  = model.OfficePhone;
            parameters[6].Value  = model.HomeAddress;
            parameters[7].Value  = model.HomePhone;
            parameters[8].Value  = model.Memo;
            parameters[9].Value  = model.GroupId;
            parameters[10].Value = model.Id;

            int rows = SqlDbHelper.ExecuteNonQuery(strSql.ToString(), CommandType.Text, parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        //修改summary表的累计折旧金额(当修改累计折旧记录的时候调用,新金额-旧金额)
        public static void change_ad_state_change(Model.Contact model)
        {
            string        str = "Server=.;database=asset_management_system;Integrated Security=sspi";
            String        Myquery1;
            SqlConnection myconn = new SqlConnection(str);

            myconn.Open();
            Myquery1 = "update summary set accumulated_depreciation= accumulated_depreciation - " + model.Old_money + " + " + model.Now + " where id = '" + model.Id + "'";
            SqlCommand mycmd1 = new SqlCommand(Myquery1, myconn);
            int        result = mycmd1.ExecuteNonQuery();

            myconn.Close();
        }
Exemple #20
0
        public Infrastructure.ValidationError[] Save(Model.Contact contact)
        {
            Infrastructure.ValidationError[] validationErrors = contactValidationEngine.Save(contact);

            if (validationErrors.Any())
            {
                return(validationErrors);
            }

            contactResource.Save(contact);

            return(new Infrastructure.ValidationError[0]);
        }
        //修改summary表维修记录
        public static void change_repair_state(Model.Contact model)
        {
            string        str = "Server=.;database=asset_management_system;Integrated Security=sspi";
            String        Myquery1;
            SqlConnection myconn = new SqlConnection(str);

            myconn.Open();
            Myquery1 = "update summary set repair_report = '有' where id = '" + model.Id + "'";
            SqlCommand mycmd1 = new SqlCommand(Myquery1, myconn);
            int        result = mycmd1.ExecuteNonQuery();

            myconn.Close();
        }
        //name in the list selected
        private void listContacts_Click(object sender, EventArgs e)
        {
            Model.Contact c = new Model.Contact();

            string ab       = listContacts.GetItemText(listContacts.SelectedItem.ToString());
            string selected = listContacts.SelectedItem.ToString();

            MessageBox.Show(selected);



            // contacts.Find()
            System.Diagnostics.Debug.WriteLine(ab);
        }
Exemple #23
0
        public HttpResponseMessage Put(Model.Contact con)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(URL);

                var content = new StringContent(new JavaScriptSerializer().Serialize(con), Encoding.UTF8, "application/json");

                //HTTP Get
                var response = client.PutAsync("api/Contacts/", content);

                return(response.Result);
            }
        }
 public void AddContact(Model.Contact con)
 {
     try
     {
         File.AppendAllText("D:\\temp.txt", "Add Contact");
         _contactRepository.Insert(con);
         _contactRepository.Save();
     }
     catch (System.Exception ex)
     {
         File.AppendAllText("D:\\temp.txt", ex.Message);
         throw;
     }
 }
Exemple #25
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Contact = await _context.Contact.SingleOrDefaultAsync(m => m.ContactID == id);

            if (Contact == null)
            {
                return(RedirectToPage("/Contact/Index"));
            }
            return(Page());
        }
        public void AddNewContact(Model.Contact contact)
        {
            Application outlookApp = new Application();
            ContactItem newContact = (ContactItem)outlookApp.CreateItem(OlItemType.olContactItem);


            newContact.FullName                = contact.FullName;
            newContact.Email1Address           = contact.Email;
            newContact.HomeAddress             = contact.Address;
            newContact.HomeTelephoneNumber     = contact.HomePhone;
            newContact.MobileTelephoneNumber   = contact.MobilePhone;
            newContact.BusinessTelephoneNumber = contact.BusinessPhone;
            newContact.BusinessFaxNumber       = contact.BusinessFax;
            newContact.Save();
            //newContact.Display(true);
        }
Exemple #27
0
 protected void btnContact_Click(object sender, EventArgs e)
 {
     Model.Contact contact = new Model.Contact();
     contact.FirstName = txtFirstName.Text;
     contact.LastName = txtLastName.Text;
     contact.Email = txtEmail.Text;
     contact.Comment = txtComments.Text;
     contact.DateCreated = DateTime.Now;
     int i = new ContactRepo().CreateContact(contact);
     txtFirstName.Text = "";
     txtLastName.Text = "";
     txtEmail.Text = "";
     txtComments.Text = "";
     lbMessage.Text = "Sent contact successfully!";
     Response.Redirect("Contact.aspx");
 }
        //根据查询条件,获取列表
        public DataTable GetList(string strWhere, Model.Contact model)
        {
            string        str = "Server=.;database=asset_management_system;Integrated Security=sspi";
            string        Myquery1;
            SqlConnection myconn = new SqlConnection(str);

            Myquery1 = "select * from " + model.Table + " where " + strWhere;
            SqlCommand     mycmd1   = new SqlCommand(Myquery1, myconn);
            SqlDataAdapter Adpclass = new SqlDataAdapter();
            DataSet        myds     = new DataSet();

            Adpclass.SelectCommand = mycmd1;
            Adpclass.Fill(myds, model.Table);
            change_name(myds, model.Table);
            return(myds.Tables[model.Table]);
        }
        public static Dictionary <string, Model.Contact> RetreiveAllContact(bool accessEmal)
        {
            Application outLook   = new Application();
            NameSpace   outLookNS = outLook.GetNamespace("MAPI");
            MAPIFolder  cf        = outLookNS.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
            Items       ctcItems  = cf.Items;

            Dictionary <string, Model.Contact> contacts = new Dictionary <string, Model.Contact>();

            for (int j = 1; j < (ctcItems.Count + 1); j++)
            {
                try
                {
                    if (ctcItems[j] != null)
                    {
                        ContactItem ctc = (ContactItem)ctcItems[j];


                        Model.Contact contact = new Model.Contact();
                        contact.FullName = ctc.FullName.ToString();

                        contact.Address     = ctc.HomeAddress == null ? "" : ctc.HomeAddress.ToString();
                        contact.HomePhone   = ctc.HomeTelephoneNumber == null ? "" : ctc.HomeTelephoneNumber.ToString();
                        contact.MobilePhone = ctc.MobileTelephoneNumber == null ? "" : ctc.MobileTelephoneNumber.ToString();

                        if (accessEmal)
                        {
                            contact.Email = ctc.Email1Address == null ? "" : ctc.Email1Address.ToString();
                        }

                        contact.BusinessPhone = ctc.BusinessTelephoneNumber == null ? "" : ctc.BusinessTelephoneNumber.ToString();
                        contact.BusinessFax   = ctc.BusinessFaxNumber == null ? "" : ctc.BusinessFaxNumber.ToString();
                        contact.IPPhone       = "";

                        if (!contacts.ContainsKey(contact.FullName))
                        {
                            contacts.Add(contact.FullName, contact);
                        }
                    }
                }
                catch (System.Exception ex)
                {
                }
            }

            return(contacts);
        }
Exemple #30
0
        protected void btnContact_Click(object sender, EventArgs e)
        {
            Model.Contact contact = new Model.Contact();
            contact.FirstName   = txtFirstName.Text;
            contact.LastName    = txtLastName.Text;
            contact.Email       = txtEmail.Text;
            contact.Comment     = txtComments.Text;
            contact.DateCreated = DateTime.Now;
            int i = new ContactRepo().CreateContact(contact);

            txtFirstName.Text = "";
            txtLastName.Text  = "";
            txtEmail.Text     = "";
            txtComments.Text  = "";
            lbMessage.Text    = "Sent contact successfully!";
            Response.Redirect("Contact.aspx");
        }
        public async Task <IActionResult> OnPostDeleteAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Contact = await _context.Contact.FindAsync(id);

            if (Contact != null)
            {
                _context.Contact.Remove(Contact);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("/Contact/Index"));
        }
Exemple #32
0
        public ActionResult AddNew([Bind(Include = "Id,FirstName, LastName, EmailAddress1, Telephone1")] Model.Contact contato)
        {
            try
            {
                return(null);
                //if(contato.Id == Guid.Empty)
                //  Dominio.ContacDomain.Instancia.Create(contato);
                //else
                //      Dominio.ContacDomain.Instancia.Atualizar(contato);

                // return RedirectToAction("Index");
            }
            catch
            {
                return(View());
            }
        }
Exemple #33
0
 public frmContactChiTiet(string pathDataFile, Model.Contact contact = null)
 {
     InitializeComponent();
     this.contact      = contact;
     this.pathDataFile = pathDataFile;
     if (contact != null)
     {
         this.Text     = "Chỉnh sửa quá trình học tập";
         txtName.Text  = contact.NameContact;
         txtPhone.Text = contact.Phone;
         txtEmail.Text = contact.Email;
     }
     else
     {
         this.Text = "Thêm quá trình học tập";
     }
 }
        private void btnAddUpdateContact_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            string firstName = txtContactFirstName.Text.Trim();
            string lastName = txtContactLastName.Text.Trim();
            string cellPhone = txtContactCellPhone.Text.Trim();
            string homePhone = txtContactHomePhone.Text.Trim();
            string address = txtContactAddress.Text.Trim();

            if (AreValidFields(firstName, lastName, cellPhone, homePhone, address) == false)
            {
                return;
            }

            if (_isUpdateContact)
            {
                _contactToUpdate.FirstName = firstName;
                _contactToUpdate.LastName = lastName;
                _contactToUpdate.CellPhone = cellPhone;
                _contactToUpdate.HomePhone = homePhone;
                _contactToUpdate.Address = address;

                UpdateContact(_contactToUpdate);
            }
            else
            {
                Model.Contact contactToAdd = new Model.Contact()
                {
                    FirstName = firstName,
                    LastName = lastName,
                    CellPhone = cellPhone,
                    HomePhone = homePhone,
                    Address = address
                };

                AddContact(contactToAdd);
            }
		}
Exemple #35
0
        ///////////根据联系人编号,获取联系人信息
        public Model.Contact GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Id,Name,Phone,Email,QQ,WorkUnit,OfficePhone,HomeAddress,HomePhone,Memo,GroupId ");
            strSql.Append("from Contact where Id=@Id ");
            OleDbParameter[] parameters ={
                           new OleDbParameter ("@Id",OleDbType.Integer,4) };

            parameters[0].Value = Id;
            Model.Contact model = new Model.Contact();
            DataTable dt = OleDbHelper.ExecuteDataTable(strSql.ToString(), parameters);
            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["Id"] != null && dt.Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(dt.Rows[0]["Id"].ToString());
                }
                if (dt.Rows[0]["Name"] != null && dt.Rows[0]["Name"].ToString() != "")
                {
                    model.Name = dt.Rows[0]["Name"].ToString();
                }
                if (dt.Rows[0]["Phone"] != null && dt.Rows[0]["Phone"].ToString() != "")
                {
                    model.Phone = dt.Rows[0]["Phone"].ToString();
                }
                if (dt.Rows[0]["Email"] != null && dt.Rows[0]["Email"].ToString() != "")
                {
                    model.Email = dt.Rows[0]["Email"].ToString();
                }
                if (dt.Rows[0]["QQ"] != null && dt.Rows[0]["QQ"].ToString() != "")
                {
                    model.QQ = dt.Rows[0]["QQ"].ToString();
                }
                if (dt.Rows[0]["WorkUnit"] != null && dt.Rows[0]["WorkUnit"].ToString() != "")
                {
                    model.WorkUnit = dt.Rows[0]["WorkUnit"].ToString();
                }
                if (dt.Rows[0]["OfficePhone"] != null && dt.Rows[0]["OfficePhone"].ToString() != "")
                {
                    model.OfficePhone = dt.Rows[0]["OfficePhone"].ToString();
                }
                if (dt.Rows[0]["HomeAddress"] != null && dt.Rows[0]["HomeAddress"].ToString() != "")
                {
                    model.HomeAddress = dt.Rows[0]["HomeAddress"].ToString();
                }
                if (dt.Rows[0]["HomePhone"] != null && dt.Rows[0]["HomePhone"].ToString() != "")
                {
                    model.HomePhone = dt.Rows[0]["HomePhone"].ToString();
                }

                if (dt.Rows[0]["Memo"] != null && dt.Rows[0]["Memo"].ToString() != "")
                {
                    model.Memo = dt.Rows[0]["Memo"].ToString();
                }
                if (dt.Rows[0]["GroupId"] != null && dt.Rows[0]["GroupId"].ToString() != "")
                {
                    model.GroupId = int.Parse(dt.Rows[0]["GroupId"].ToString());
                }

                return model;

            }
            else
            {
                return null;
            }
        }