/// <summary> /// ��������б� /// </summary> public List<WebProject.Model.BaseData.ZT_COM_LiuYan> DataTableToList(DataTable dt) { List<WebProject.Model.BaseData.ZT_COM_LiuYan> modelList = new List<WebProject.Model.BaseData.ZT_COM_LiuYan>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { WebProject.Model.BaseData.ZT_COM_LiuYan model; for (int n = 0; n < rowsCount; n++) { model = new WebProject.Model.BaseData.ZT_COM_LiuYan(); if(dt.Rows[n]["LiuYanID"].ToString()!="") { model.LiuYanID=int.Parse(dt.Rows[n]["LiuYanID"].ToString()); } model.MainInfo=dt.Rows[n]["MainInfo"].ToString(); model.Body=dt.Rows[n]["Body"].ToString(); model.Name=dt.Rows[n]["Name"].ToString(); model.Sex=dt.Rows[n]["Sex"].ToString(); model.Telephone=dt.Rows[n]["Telephone"].ToString(); model.Mobile=dt.Rows[n]["Mobile"].ToString(); model.Fax=dt.Rows[n]["Fax"].ToString(); model.Email=dt.Rows[n]["Email"].ToString(); model.CompanyName=dt.Rows[n]["CompanyName"].ToString(); model.Address=dt.Rows[n]["Address"].ToString(); model.MailNum=dt.Rows[n]["MailNum"].ToString(); model.IsIndex=dt.Rows[n]["IsIndex"].ToString(); model.Reply=dt.Rows[n]["Reply"].ToString(); if(dt.Rows[n]["ReplyTime"].ToString()!="") { model.ReplyTime=DateTime.Parse(dt.Rows[n]["ReplyTime"].ToString()); } model.CreateBy=dt.Rows[n]["CreateBy"].ToString(); if(dt.Rows[n]["CreateDate"].ToString()!="") { model.CreateDate=DateTime.Parse(dt.Rows[n]["CreateDate"].ToString()); } model.LastUpdateBy=dt.Rows[n]["LastUpdateBy"].ToString(); if(dt.Rows[n]["LastUpdateDate"].ToString()!="") { model.LastUpdateDate=DateTime.Parse(dt.Rows[n]["LastUpdateDate"].ToString()); } model.Remark=dt.Rows[n]["Remark"].ToString(); modelList.Add(model); } } return modelList; }
protected void btnSubmit_Click(object sender, EventArgs e) { if (this.txtMainInfo.Text.Trim() == "") { MessageBox.Show(this, "请填写留言主题"); return; } else { if (this.txtName.Text.Trim() == "") { MessageBox.Show(this, "请填写您的姓名"); return; } else { string sex = "1"; if (this.sex1.Checked == false && this.sex2.Checked == false) { MessageBox.Show(this, "请选择性别"); return; } if (this.sex2.Checked) { sex = "0"; } else { if (this.txtMobile.Text.Trim() == "") { MessageBox.Show(this, "请填写您的手机号码"); return; } else { double u; if (!double.TryParse(this.txtMobile.Text, out u)) { MessageBox.Show(this, "手机号码必须为数字!"); return; } if (u <= 13000000000 || u >= 19000000000) { MessageBox.Show(this, "请填写正确的手机号码!");//判断输入框中的值是否为数字和是否溢出 return; } else { if (this.txtCompanyName.Text.Trim() == "") { MessageBox.Show(this, "请填写您的单位名称"); return; } else { if (this.txtAddress.Text.Trim().ToLower().IndexOf("script") > 0 || this.txtBody.Text.Trim().ToLower().IndexOf("script") > 0 || this.txtCompanyName.Text.Trim().ToLower().IndexOf("script") > 0 || this.txtEmail.Text.Trim().ToLower().IndexOf("script") > 0 || this.txtFax.Text.Trim().ToLower().IndexOf("script") > 0 || this.txtMailNum.Text.Trim().ToLower().IndexOf("script") > 0 || this.txtMainInfo.Text.Trim().ToLower().IndexOf("script") > 0 || this.txtMobile.Text.Trim().ToLower().IndexOf("script") > 0 || this.txtName.Text.Trim().ToLower().IndexOf("script") > 0 || this.txtTelephone.Text.Trim().ToLower().IndexOf("script") > 0) { MessageBox.Show(this, "留言信息内请不要包含非法字符!"); return; } if (CheckString.CheckSqlKeyWord(this.txtAddress.Text)==true || CheckString.CheckSqlKeyWord(this.txtBody.Text)==true || CheckString.CheckSqlKeyWord(this.txtCompanyName.Text)==true || CheckString.CheckSqlKeyWord(this.txtEmail.Text)==true || CheckString.CheckSqlKeyWord(this.txtFax.Text)==true || CheckString.CheckSqlKeyWord(this.txtMailNum.Text)==true || CheckString.CheckSqlKeyWord(this.txtMainInfo.Text)==true || CheckString.CheckSqlKeyWord(this.txtMobile.Text)==true || CheckString.CheckSqlKeyWord(this.txtName.Text)==true || CheckString.CheckSqlKeyWord(this.txtTelephone.Text)==true) { MessageBox.Show(this, "留言信息内请不要包含非法字符!"); return; } WebProject.BLL.BaseData.ZT_COM_LiuYan bll_LiuYan = new WebProject.BLL.BaseData.ZT_COM_LiuYan(); WebProject.Model.BaseData.ZT_COM_LiuYan model_LiuYan = new WebProject.Model.BaseData.ZT_COM_LiuYan(); model_LiuYan.Address = this.txtAddress.Text.Trim(); model_LiuYan.Body = this.txtBody.Text.Trim(); model_LiuYan.CompanyName = this.txtCompanyName.Text.Trim(); model_LiuYan.Email = this.txtEmail.Text.Trim(); model_LiuYan.Fax = this.txtFax.Text.Trim(); model_LiuYan.MailNum = this.txtMailNum.Text.Trim(); model_LiuYan.MainInfo = this.txtMainInfo.Text.Trim(); model_LiuYan.Mobile = this.txtMobile.Text.Trim(); model_LiuYan.Name = this.txtName.Text.Trim(); model_LiuYan.Telephone = this.txtTelephone.Text.Trim(); model_LiuYan.Sex = sex.ToString(); bll_LiuYan.Add(model_LiuYan); MessageBox.ShowAndRedirect(this, "留言填写成功!", "Index.aspx"); } } } } } } }