Пример #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            int res = 0;

            if (this.hfContactId.Value == "" || this.hfContactId.Value == null)
            {
                //执行新增
                var model = new Model.Contact
                {
                    Contact_Address  = this.txtAddress.Text,
                    Contact_Phone    = this.txtPhone.Text,
                    Contact_QQ1      = this.txtQQ1.Text,
                    Contact_QQ2      = this.txtQQ2.Text,
                    Contact_QRCode   = upFileName(FileUpload1, "../../upload/contact/"),
                    Contact_Wechat   = this.txtWeiXin.Text,
                    Contact_Weibo    = this.txtWeiBo.Text,
                    Contact_Email    = this.txtEmail.Text,
                    Contact_Fax      = this.txtFax.Text,
                    Contact_WorkTime = this.txtWorkTime.Text
                };

                res = contactSvc.Add(model);
            }
            else
            {
                //修改
                var model = contactSvc.GetAll();
                if (upFileName(FileUpload1, "../../upload/contact/") != "")
                {
                    model.Contact_QRCode = upFileName(FileUpload1, "../../upload/contact/");
                }
                model.Contact_Address  = this.txtAddress.Text;
                model.Contact_Phone    = this.txtPhone.Text;
                model.Contact_QQ1      = this.txtQQ1.Text;
                model.Contact_QQ2      = this.txtQQ2.Text;
                model.Contact_Wechat   = this.txtWeiXin.Text;
                model.Contact_Weibo    = this.txtWeiBo.Text;
                model.Contact_WorkTime = this.txtWorkTime.Text;
                model.Contact_Fax      = this.txtFax.Text;
                model.Contact_Email    = this.txtEmail.Text;


                res = contactSvc.Edit(model);
            }

            var rm = res > 0 ? new ReturnMsg
            {
                Code    = StatusCode.Ok,
                Message = "编辑联系我们成功",
                Data    = null
            } : new ReturnMsg
            {
                Code    = StatusCode.Ok,
                Message = "编辑联系我们失败",
                Data    = null
            };

            Session["Msg"] = rm;
            Response.Redirect("Contact_Info.aspx");
        }
Пример #2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Model.Contact u = new Model.Contact
            {
                Contact_Title1 = this.txtTitle1.Text.Trim(),
                Contact_Phone  = this.txtPhone.Text.Trim(),
                Contact_Fax    = this.txtFax.Text.Trim(),
                Contact_Email  = this.txtEmail.Text.Trim(),
                Contact_Title2 = this.txtTitle2.Text.Trim(),
                Contact_Site   = this.txtSite.Text.Trim(),
                Contact_Image1 = upFileName(this.FileUpload1, "../../upload/Contact/"),
                Contact_Image2 = upFileName(this.FileUpload2, "../../upload/Contact/"),
                Contact_Image3 = upFileName(this.FileUpload3, "../../upload/Contact/")
            };
            var       res = ContactSvc.Add(u);
            ReturnMsg rm  = res > 0
                ? new ReturnMsg()
            {
                Code    = StatusCode.OK,
                Message = "新增用户信息成功",
                Data    = null
            }
                : new ReturnMsg()
            {
                Code    = StatusCode.Error,
                Message = "新增用户信息失败",
                Data    = null
            };

            Session["Msg"] = rm; //用于传递执行信息的
            Response.Redirect("Contact_List.aspx");
        }
Пример #3
0
        public void SendContact(Contact contact)
        {
            var message = new MailMessage(sourceAddress, contactAddress)
            {
                Subject = string.Format("TNO LeTour: Contactformulier ingevuld"),
                IsBodyHtml = true
            };

            if(contact.CopyToSelf)
                message.To.Add(contact.Email);

            message.Body = GetBody("contact",
                                   new Hashtable { { "contact", contact } });

            SendMessage(message);
        }
Пример #4
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 ");
            SqlParameter[] parameters ={
                           new SqlParameter ("@Id",SqlDbType.Int,4) };

            parameters[0].Value = Id;
            Model.Contact model = new Model.Contact();
            DataTable dt = SqlDbHelper.ExecuteDataTable(strSql.ToString(),
                                   CommandType.Text, 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;
            }
        }
Пример #5
0
 public ActionResult Edit(Contact contact)
 {
     Store.Store<Contact>(contact);
     return RedirectToAction("Index");
 }