/// <summary> /// バッチ送信 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBatch_Click(object sender, EventArgs e) { ArrayList list = new ArrayList(); NdnPublicFunction func = new NdnPublicFunction(); for (int idx = 0; idx < dgvData.Rows.Count; idx++) { string mail = dgvData.Rows[idx].Cells[12].Value.ToString(); string Subscript = dgvData.Rows[idx].Cells[16].Value.ToString(); if (func.IsMail(mail, false) && Subscript == "Y") { string[] data = new string[18]; for (int i = 0; i < 18; i++) { data[i] = dgvData.Rows[idx].Cells[i].Value.ToString(); } list.Add(data); } } if (list.Count > 0) { FormBatchMail form = new FormBatchMail(list, db); if (form.ShowDialog() == DialogResult.OK) { } } else { MessageBox.Show("No data Selected!"); } }
/// <summary> /// 邮件服务器测试 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnTest_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { String name = txtName.Text; String address = txtAddress.Text; String port = txtPort.Text; String user = txtUser.Text; String password = txtPassword.Text; String from = txtSender.Text; String servertype = cmbType.Text.Trim(); String attachement = cmbAttachment.Text.Trim(); String isHtml = cmbISHtml.Text.Trim(); String to = txtTestTo.Text; NdnPublicFunction function = new NdnPublicFunction(); if (!function.IsMail(to, false)) { string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0066I", db.Language); MessageBox.Show(msg); return; } String subject = "这是测试" + " by " + name; String pdffile = "http://www.chojogakuin.com/weekly/20130907.pdf"; String body = "测试内容\r\n收到邮件说明测试成功\r\nURL=" + pdffile; String htmlbody = "<html><head></head><body>测试内容<br>收到邮件说明测试成功</body></html>"; String picfile = @"c:\test.jpg"; if (isHtml != "Y") { htmlbody = null; } if (attachement != "Y") { picfile = null; } if (NCMail.SendEmail(subject, body, htmlbody, picfile, address, user, password, from, to, servertype)) { string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0067I", db.Language); MessageBox.Show(msg); } else { string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0068I", db.Language); MessageBox.Show(msg); } } else { string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0059I", db.Language); MessageBox.Show(msg); } }
/// <summary> /// 顧問导入 /// </summary> /// <param name="csvFile"></param> private void importConsultantFile(String fileName) { NdnPublicFunction func = new NdnPublicFunction(); using (StreamReader reader = new StreamReader(fileName, Encoding.GetEncoding("UTF-8"))) { String line = reader.ReadLine(); while (line != null) { string[] data = line.Split(','); if (data.Length == 17 && !data[0].StartsWith("会社名")) { //会社名,部署名,役職,氏名,e-mail,郵便番号,住所,TEL会社,TEL部門,TEL直通,FAX,携帯電話,URL,名刺交換日,Eightでつながっている人,再データ化中の名刺,'?'を含んだデータ string Cname = data[0]; //会社名 string depart = data[1] + " " + data[2]; //部門または職位 string manager = data[3]; //管理者名前 string postcode = data[5]; string address = data[6]; //アドレス string Tel = data[7] + "/" + data[8] + "/" + data[9] + "/" + data[10]; //電話・FAX string fax = data[11]; string mail = data[4]; //メール string web = data[12]; //web string date = data[13]; //date string other = data[14]; //other int id = 0; if (!exists(Cname, manager)) { String valueList = "'" + Cname + "','" + manager + "','','" + address + "','" + Tel + "','','','','','" + date + "','" + other + "','" + mail + "','" + web + "','" + depart + "','" + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "','Y','1'"; db.SetConsultant(0, 0, "Cname,name,postcode,address,tel,fax,kind,format,scale,CYMD,other,mail,web,jCNAME,createtime,subscripted,UserID", "", valueList, out id); } else { String valueList = "postcode='" + postcode + "',address='" + address + "',tel='" + Tel + "',fax='" + fax + "',kind='Consultant',format='',scale='',CYMD='" + date + "',other='" + other + "',mail='" + mail + "',web='" + web + "',jCName='" + depart + "',createtime='" + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "',subscripted='Y'"; db.SetConsultant(0, 1, "", "Cname='" + Cname + "',name='" + manager + "'", valueList, out id); } } line = reader.ReadLine(); } } }
/// <summary> /// プロジェクト导入 /// </summary> /// <param name="csvFile"></param> private void importProjectFile(String fileName) { NdnPublicFunction func = new NdnPublicFunction(); using (StreamReader reader = new StreamReader(fileName, Encoding.GetEncoding("UTF-8"))) { String line = reader.ReadLine(); while (line != null) { string[] temp = line.Split(','); string name = temp[0]; //名称 string projectName = temp[1]; //プロジェクト string area = temp[2].Replace("都道府県", ""); //区域 string bunrui = temp[3].Replace("入札形式", ""); //入札形式 string pubdate = temp[4].Replace("公示日", ""); //公示日 string adress = temp[5].Substring(2); //住所 string url = temp[6]; //web int id = 0; String valueList = "'" + projectName + "','" + "" //管理者 + "','" + "" //postcode + "','" + adress //address + "','','','" //tel,fax + bunrui + "','" //kind + area //format + "','" + "" //scale + "','2017/06/15','" //CYMD + "" //other + "','" + "" //mail + "','" + url //web + "','" + name //jCName + "','" + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "','Y','1','" + bunrui + "','" + pubdate + "',''"; db.SetProject(0, 0, "Cname,name,postcode,[address],tel,fax,kind,[format],scale,CYMD,other,mail,web,jCNAME,createtime,subscripted,UserID,入札形式,公示日,入札内容", "", valueList, out id); line = reader.ReadLine(); } } }
/// <summary> /// 機構导入 /// </summary> /// <param name="csvFile"></param> private void importGovementFile(String fileName) { NdnPublicFunction func = new NdnPublicFunction(); using (StreamReader reader = new StreamReader(fileName, Encoding.GetEncoding("UTF-8"))) { String line = reader.ReadLine(); while (line != null) { string[] temp = line.Split(','); string name = temp[0]; //名称 string bunrui = temp[1]; //分類 string area = temp[2]; //区域 string num1 = temp[3].Replace("入札可能案件", ""); //入札可能案件 string num2 = temp[4].Replace("案件登録数", ""); //案件登録数 string num3 = temp[5].Replace("入札結果数", ""); //入札結果数 string url = temp[6]; //web int id = 0; String valueList = "'" + name //名称 + "','" + "" //管理者 + "','','" //postcode + "" //address + "','','','" //tel,fax + bunrui + "','" //kind + area //formart + "','" + "" //scale + "','2017/06/15','" //CYMD + "" //other + "','" + "" //mail + "','" + url //web + "','" + "" //jCName + "','" + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "','Y','1'," + num1 + "," + num2 + "," + num3; db.SetGovement(0, 0, "Cname,name,postcode,[address],tel,fax,kind,[format],scale,CYMD,other,mail,web,jCNAME,createtime,subscripted,UserID,入札可能案件,案件登録数,入札結果数", "", valueList, out id); line = reader.ReadLine(); } } }
/// <summary> /// メールテンプレート /// </summary> /// <param name="csvFile"></param> private void importTemplate(String fileName) { NdnPublicFunction func = new NdnPublicFunction(); using (StreamReader reader = new StreamReader(fileName, Encoding.GetEncoding("UTF-8"))) { String line = reader.ReadLine(); txtTitle.Text = line; txtContent.Text = ""; while (line != null) { line = reader.ReadLine(); txtContent.Text += line + "\r\n"; } } }
/// <summary> /// 個人导入 /// </summary> /// <param name="csvFile"></param> private void importPersonalFile(String fileName) { NdnPublicFunction func = new NdnPublicFunction(); using (StreamReader reader = new StreamReader(fileName, Encoding.GetEncoding("UTF-8"))) { String line = reader.ReadLine(); while (line != null) { string[] temp = line.Split(','); if (temp.Length == 9) { string name = temp[1]; // 氏名 string sex = temp[2]; // 性别 int age = 0; if (temp[3] != "") { age = int.Parse(Strings.StrConv(temp[3].Replace("歳", ""), VbStrConv.Narrow, 0)); } string birthday = System.DateTime.Now.AddYears(0 - age).ToString("yyyy-MM-dd"); //对应 技术者履历书中的 生年月 string BirthAddress = temp[6]; //メール string country = "日本"; //对应 技术者履历书中的 国籍 string nearstation = temp[4]; //对应 技术者履历书中的 自宅・最寄り駅 string skill = temp[8]; //希望職 string fieldlist = "Name,Sex,Birthday,BirthAddress,Country,NearStation,skill,UserID"; //分别对应数据库中雇员表里的字段 string valuelist = "'" + name + "','" + sex + "','" + birthday + "','" + BirthAddress + "','" + country + "','" + nearstation + "','" + skill + "','" + db.db.UserID + "'"; int id = 0; if (db.SetEmp(0, 0, fieldlist, "", valuelist, out id)) { // } } line = reader.ReadLine(); } } }
/// <summary> /// RFID导入 /// </summary> /// <param name="csvFile"></param> private void importRFIDFile(String rfidFile) { using (StreamReader reader = new StreamReader(rfidFile, Encoding.GetEncoding("UTF-8"))) { String line = reader.ReadLine(); NdnPublicFunction func = new NdnPublicFunction(); while ((line = reader.ReadLine()) != null) { if (func.IsNumeric(line.Trim())) { string company = reader.ReadLine().Trim(); string name = reader.ReadLine().Trim(); string mail = reader.ReadLine().Trim().Replace("&", "@"); if (!func.IsMail(mail, false)) { continue; } int id = 0; String valueList = "'" + company + "','" + name + "','','','','','RFID','电子电器','','','" + "" + "','" + mail + "','','','" + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "','Y','" + db.UserID + "'"; if (db.SetRFIDCustomer(0, 0, "Cname,name,postcode,address,tel,fax,kind,format,scale,CYMD,other,mail,web,jCNAME,createtime,subscripted,UserID", "", valueList, out id)) { //string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0001I", db.Language); //MessageBox.Show(msg); } else { //string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0002I", db.Language); //MessageBox.Show(msg); } } } } }
/// <summary> /// 客户数据检查 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPublish_Click(object sender, EventArgs e) { Hashtable ht = getInvalidCustomer(); DataSet ds = new DataSet(); NdnPublicFunction function = new NdnPublicFunction(); int newid = 0; if (db.GetCustomer(0, 0, "*", "", "", ref ds)) { foreach (DataRow row in ds.Tables[0].Rows) { String id = row["id"].ToString(); String mail = row["mail"].ToString(); String subscripted = row["subscripted"].ToString().Trim(); if (!function.IsMail(mail, false) || ht[mail] != null) { db.SetCustomer(0, 1, "", "id=" + id, "subscripted='N'", out newid); } else { if (subscripted != "T") { db.SetCustomer(0, 1, "", "id=" + id, "subscripted='Y'", out newid); } } } string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0007I", db.Language); MessageBox.Show(msg); init("", "", ""); } else { string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0008I", db.Language); MessageBox.Show(msg); } }
/// <summary> /// 会社导入 /// </summary> /// <param name="csvFile"></param> private void importCompanyFile(String fileName) { NdnPublicFunction func = new NdnPublicFunction(); using (StreamReader reader = new StreamReader(fileName, Encoding.GetEncoding("UTF-8"))) { String line = reader.ReadLine(); while (line != null) { string[] data = line.Split(','); string Cname = data[1]; //会社名 string depart = data[2]; //部門または職位 string manager = data[3]; //管理者名前 string address = data[4]; //アドレス string Tel = data[5]; //電話・FAX string mail = data[6]; //メール string web = data[7]; //web string other = data[8]; //other if (data.Length == 9) { int id = 0; String valueList = "'" + Cname + "','" + manager + "','','" + address + "','" + Tel + "','','','','','2017/06/15','" + other + "','','" + web + "','" + depart + "','" + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "','Y','1'"; db.SetCompany(0, 0, "Cname,name,postcode,address,tel,fax,kind,format,scale,CYMD,other,mail,web,jCNAME,createtime,subscripted,UserID", "", valueList, out id); } line = reader.ReadLine(); } } }
/// <summary> /// Personal导入 /// </summary> /// <param name="csvFile"></param> private void importPersonalFile(String fileName) { NdnPublicFunction func = new NdnPublicFunction(); using (StreamReader reader = new StreamReader(fileName, Encoding.GetEncoding("UTF-8"))) { String line = reader.ReadLine(); while (line != null) { string[] data = line.Split(','); if (data.Length == 9) { data[6] = data[6].Replace("mailto:", ""); int id = 0; String valueList = "'" + data[0] + "','" + data[1] + "','','" + data[4] + "','','','個人','" + data[2] + "','" + data[3] + "','2017/06/15','" + data[8] + "','" + data[6] + "','','" + data[3] + "','" + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "','Y','" + db.UserID + "'"; db.SetCustomer(0, 0, "Cname,name,postcode,address,tel,fax,kind,format,scale,CYMD,other,mail,web,jCNAME,createtime,subscripted,UserID", "", valueList, out id); } line = reader.ReadLine(); } } }
/// <summary> /// 顧問导入2 /// </summary> /// <param name="csvFile"></param> private void importConsultantFile2(String fileName) { NdnPublicFunction func = new NdnPublicFunction(); using (StreamReader reader = new StreamReader(fileName, Encoding.GetEncoding("UTF-8"))) { String line = reader.ReadLine(); bool Beginread = false; while (line != null) { if (line.Trim().Equals("交換月順")) { line = reader.ReadLine(); Beginread = true; } if (line.Trim().Equals("お知り合いですか?")) { Beginread = false; line = reader.ReadLine(); continue; } if (line.Trim().Equals("")) { line = reader.ReadLine(); continue; } if (Beginread) { string manager = line; //管理者名前 string other = ""; //other if (line.Length > 5) { manager = line.Substring(0, 4); //管理者名前 other = line.Substring(4); //other } line = reader.ReadLine(); if (line != null && line.Trim() != "") { string Cname = line; //会社名 string depart = ""; //部門または職位 if (line.IndexOf(" ") > -1) { Cname = line.Substring(0, line.IndexOf(" ")); depart = line.Substring(line.IndexOf(" ") + 1); } else if (line.IndexOf(" ") > -1) { Cname = line.Substring(0, line.IndexOf(" ")); depart = line.Substring(line.IndexOf(" ") + 1); } string address = ""; //アドレス string Tel = ""; //電話・FAX string mail = ""; //メール string web = ""; //web string date = System.DateTime.Today.ToString("yyyy/MM/dd"); //date int id = 0; String valueList = "'" + Cname + "','" + manager + "','','" + address + "','" + Tel + "','','','','','" + date + "','" + other + "','" + mail + "','" + web + "','" + depart + "','" + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "','N','1'"; db.SetConsultant(0, 0, "Cname,name,postcode,address,tel,fax,kind,format,scale,CYMD,other,mail,web,jCNAME,createtime,subscripted,UserID", "", valueList, out id); } } line = reader.ReadLine(); } } }