using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Net.Mail;
using System.Net;
public partial class jphrorder : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
saveOrder();
sendmail();
}
//保存数据
protected void saveOrder()
{
SqlConnection conData;
// conData = new SqlConnection("Server=121.14.3.78;uid=web71760;pwd=c0k9a4l7;database=www_bluenet_com_cn");
conData = new SqlConnection("Data Source=CZJ//SQLEXPRESS;Initial Catalog=test;User ID=sa;Password=sa");
string sqlstring = "insert into jphrorder(ortime,orcompany,oraddress,orpostal,ortelephone,orfax,orurl,orcount," +
"orcompanycountry,orconnect,orconnectjob,orcellphone,oremail,orcontent,orjob,orstatus,orcountry,"+
"orold,orsex,orplace,oreducational,orPcable,orbForeignlanguage,orSalary,orsubsidy,orworktime,orinsurance,orsalarytimes,orholidays,orworkContent,orCondition,other)"
+"values (@ortime,@orcompany,@oraddress,@orpostal,@ortelephone,@orfax,@orurl,@orcount," +
"@orcompanycountry,@orconnect,@orconnectjob,@orcellphone,@oremail,@orcontent,@orjob,@orstatus,@orcountry,"+
"@orold,@orsex,@orplace,@oreducational,@orPcable,@orbForeignlanguage,@orSalary,@orsubsidy,@orworktime,@orinsurance,@orsalarytimes,@orholidays,@orworkContent,@orCondition,@other)";
SqlCommand insertCmd = new SqlCommand(sqlstring, conData);
insertCmd.Parameters.Add("@ortime", SqlDbType.SmallDateTime);
insertCmd.Parameters.Add("@orcompany",SqlDbType.VarChar,50);
insertCmd.Parameters.Add("@oraddress", SqlDbType.VarChar,50);
insertCmd.Parameters.Add("@orpostal", SqlDbType.VarChar, 20);
insertCmd.Parameters.Add("@ortelephone", SqlDbType.VarChar, 30);
insertCmd.Parameters.Add("@orfax", SqlDbType.VarChar, 30);
insertCmd.Parameters.Add("@orurl", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orcount", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orcompanycountry", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orconnect", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orconnectjob", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orcellphone", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@oremail", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orcontent", SqlDbType.VarChar, 300);
insertCmd.Parameters.Add("@orjob", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orstatus", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orcountry", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orold", SqlDbType.Int);
insertCmd.Parameters.Add("@orsex", SqlDbType.VarChar,20);
insertCmd.Parameters.Add("@orplace", SqlDbType.VarChar, 50);
//后一部分字段
insertCmd.Parameters.Add("@oreducational", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orPcable", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orbForeignlanguage", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orSalary", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orsubsidy", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orworktime", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orinsurance", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orsalarytimes", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orholidays", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orworkContent", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@orCondition", SqlDbType.VarChar, 50);
insertCmd.Parameters.Add("@other", SqlDbType.VarChar, 50);
//输入数据
insertCmd.Parameters["@ortime"].Value = DateTime.Now;
insertCmd.Parameters["@orcompany"].Value = txtCompany.Text;
insertCmd.Parameters["@oraddress"].Value = txtaddress.Text;
insertCmd.Parameters["@orpostal"].Value = txtorpostal.Text;
insertCmd.Parameters["@ortelephone"].Value = txttelephone.Text;
insertCmd.Parameters["@orfax"].Value = txtfax.Text;
insertCmd.Parameters["@orurl"].Value = txturl.Text;
insertCmd.Parameters["@orcount"].Value = txtcount.Text;
//选择企业国籍
string selectCountry = "";
for (int i = 0; i <= this.cobcountry.Items.Count - 1; i++)
{
if (this.cobcountry.Items[i].Selected)
{
//Response.Write(this.chkcity.Items[i].Value.ToString() + "-" + this.chkcity.Items[i].Text + "<br>");
selectCountry += this.cobcountry.Items[i].ToString();
}
}
insertCmd.Parameters["@orcompanycountry"].Value = selectCountry;
insertCmd.Parameters["@orconnect"].Value = txtconnect.Text;
insertCmd.Parameters["@orconnectjob"].Value = txtconnectjob.Text;
insertCmd.Parameters["@orcellphone"].Value = txtcellphone.Text;
insertCmd.Parameters["@oremail"].Value = txtemail.Text;
insertCmd.Parameters["@orcontent"].Value = txtContent.Text;
insertCmd.Parameters["@orjob"].Value = txtjob.Text;
//就业状态
string selectStatus = "";
for (int i = 0; i <= this.cobstatus.Items.Count - 1; i++)
{
if (this.cobstatus.Items[i].Selected)
{
//Response.Write(this.chkcity.Items[i].Value.ToString() + "-" + this.chkcity.Items[i].Text + "<br>");
selectStatus += this.cobstatus.Items[i].ToString();
}
}
insertCmd.Parameters["@orstatus"].Value = selectStatus;
//人才国籍要求
string selecthrCountry = "";
for (int i = 0; i <= this.cobcountry.Items.Count - 1; i++)
{
if (this.cobcountry.Items[i].Selected)
{
//Response.Write(this.chkcity.Items[i].Value.ToString() + "-" + this.chkcity.Items[i].Text + "<br>");
selecthrCountry += this.cobcountry.Items[i].ToString();
}
}
insertCmd.Parameters["@orcountry"].Value = selecthrCountry;
//insertCmd.Parameters["@orcountry"].Value = cobcountry.SelectedValue.ToString();
insertCmd.Parameters["@orold"].Value = int.Parse(txtold.Text);
//姓别
//string selecthrSex = "";
//for (int i = 0; i <= this.cobsex.Items.Count - 1; i++)
//{
// if (this.cobsex.Items[i].Selected)
// {
// //Response.Write(this.chkcity.Items[i].Value.ToString() + "-" + this.chkcity.Items[i].Text + "<br>");
// selecthrSex += this.cobsex.Items[i].ToString();
// }
//}
//insertCmd.Parameters["@orsex"].Value = selecthrSex.ToString();
insertCmd.Parameters["@orsex"].Value = cobsex.SelectedValue.ToString();
insertCmd.Parameters["@orplace"].Value = txtplace.Text;
//选择学历
//string selectEducation = "";
//for (int i = 0; i <= this.cobEducational.Items.Count - 1; i++)
//{
// if (this.cobEducational.Items[i].Selected)
// {
// //Response.Write(this.chkcity.Items[i].Value.ToString() + "-" + this.chkcity.Items[i].Text + "<br>");
// selectEducation += this.cobEducational.Items[i].ToString();
// }
//}
//insertCmd.Parameters["@oreducational"].Value = cobEducational.SelectedValue.ToString();
insertCmd.Parameters["@oreducational"].Value = cobEducational.SelectedValue.ToString();
insertCmd.Parameters["@orPcable"].Value = txtPcable.Text;
insertCmd.Parameters["@orbForeignlanguage"].Value = cobForeignlanguage.SelectedValue.ToString();
insertCmd.Parameters["@orSalary"].Value = txtSalary.Text;
insertCmd.Parameters["@orsubsidy"].Value = txtsubsidy.Text;
insertCmd.Parameters["@orworktime"].Value = txtworktime.Text;
insertCmd.Parameters["@orinsurance"].Value = cobinsurance.SelectedValue.ToString();
insertCmd.Parameters["@orsalarytimes"].Value = cobsalarytimes.SelectedValue.ToString();
insertCmd.Parameters["@orholidays"].Value = txtholidays.Text;
insertCmd.Parameters["@orworkContent"].Value = txtworkContent.Text;
insertCmd.Parameters["@orCondition"].Value = txtCondition.Text;
insertCmd.Parameters["@other"].Value = txtother.Text;
// insertCmd.Parameters["@orcontent"].Value = txtContent.Text;
// string selectCountry = "";
// for (int i = 0; i <= this.txtcompanycountry.Items.Count - 1; i++)
// {
// if (this.txtcompanycountry.Items[i].Selected)
// {
// //Response.Write(this.chkcity.Items[i].Value.ToString() + "-" + this.chkcity.Items[i].Text + "<br>");
// selectCountry += this.txtcompanycountry.Items[i].ToString() ;
// }
// }
// insertCmd.Parameters["@orcountry"].Value = selectCountry;
try
{
conData.Open();
int flag = insertCmd.ExecuteNonQuery();
if (flag > 0)
{
Response.Write("<script language=javascript>alert('保存成功')</script>");
}
else
{
Response.Write("<script language=javascript>alert('保存失败')</script>");
}
}
catch(System.Exception ee)
{
Response.Write("<script language=javascript>alert('"+ee.Message.ToString()+"')</script>");
}
finally
{
conData.Close();
}
}
//sendEmail()
protected void sendmail()
{
//MailMessage mm = new MailMessage(emailfrom.Text, emailto.Text);
MailMessage mm = new MailMessage("czj-wj@163.com", "czj_wj@hotmail.com");
mm.Subject = "日本人才求职";
string body = "发信时间: " + DateTime.Now.ToString() + "/n" +
"会社名: " + txtCompany.Text + "/n" +
"会社住所: " + txtaddress.Text + "/n" +
"郵便番号: " + txtorpostal.Text + "/n" +
"Fax: " + txtfax.Text + "/n" +
"会社URL:" + txturl.Text + "/n" +
"社員数: " + txtcount.Text + "/n" +
"企業国籍: " + txtcompanycountry.SelectedValue.ToString() + "/n" +
"ご担当者: " + txtconnect.Text + "/n" +
"部署/職位: " + txtconnectjob.Text + "/n" +
"携帯電話: " + txtcellphone.Text + "/n" +
"Email: " + txtemail.Text + "/n" +
"経営内容: " + txtContent.Text + "/n" +
"職位: " + txtjob.Text + "/n" +
"職位現状: " + cobstatus.SelectedValue.ToString() + "/n" +
"国籍: " + cobcountry.SelectedValue.ToString() + "/n" +
"年齢: " + txtold.Text + "/n" +
"性別: " + cobsex.SelectedValue.ToString() + "/n" +
"勤務地: " + txtplace.Text + "/n" +
"学歴: " + cobEducational.SelectedValue.ToString() + "/n" +
"PCレベル: " + txtPcable.Text + "/n" +
"外国語: " + cobForeignlanguage.SelectedValue.ToString() + "/n" +
"月給: " + txtSalary.Text + "/n" +
"手当て: " + txtsubsidy.Text + "/n" +
"勤務時間: " + txtworktime.Text + "/n" +
"海外保険: " + cobinsurance.SelectedValue.ToString() + "/n" +
"年次報酬: " + cobsalarytimes.SelectedValue.ToString() + "/n" +
"有給休暇: " + txtholidays.Text + "/n" +
"職務内容: " + txtworkContent.Text + "/n" +
"条件: " + txtCondition.Text + "/n" +
"その他: " + txtother.Text + "/n" ;
mm.Body = body;
SmtpClient sc = new SmtpClient();
sc.Host = "smtp.163.com";
sc.Port = 25;
sc.Credentials = new NetworkCredential("czj-wj@163.com", "密码");
try
{
sc.Send(mm);
Response.Write(" ");
}
catch (Exception ex)
{
// 与smtp相关的错误
if (ex is SmtpException)
{
// ex.ToString();
Response.Write("smtp发信失败");
}
else
{
Response.Write(ex.ToString());
}
}
}
}