日期:2014-05-18 浏览次数:20545 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Odbc;
using System.Data.SqlClient;
using System.IO;
namespace hkmessages
{
public partial class formMonthHk : Form
{
string ConnStr = "Provider=System.Data.Odbc;Dsn=housedbSZ;uid=sa";
//连接数据源
public formMonthHk()
{
InitializeComponent();
}
private void formMonthHk_Load(object sender, EventArgs e)
{
//页面加载时
//string aa = "a b";
//MessageBox.Show(aa.Trim().Replace(" ",""));
}
private void btnOutPut_Click(object sender, EventArgs e)
{
int iyear = Convert.ToDateTime(txtYearMonth.Text.Trim()).Year;
int imonth = Convert.ToDateTime(txtYearMonth.Text.Trim()).Month;
string strWrite;
string hkCause = "";//划款原因
OdbcConnection mycn = new OdbcConnection(ConnStr);
string strSQL = "select hkmx.i_year,hkmx.i_month,hkmx.s_dkgrzh,hkmx.i_hk_flag,hkmx.s_grxm,hkmx.s_po_grxm,hkmx.dc_je,hkmx.dc_po_je,dkxx.s_grzh,dkxx.s_mobile_phone";
strSQL += " from yxwt_hkmx hkmx,nd_grdkxx_ma dkxx where hkmx.s_dkgrzh=dkxx.s_grzh and hkmx.i_year="+iyear+" and hkmx.i_month="+imonth;
try
{
StreamWriter hkInfo = new StreamWriter(txtPath.Text,false,Encoding.Default);
//StreamWriter kkInfo=new StreamWriter(
mycn.Open();
DataSet myds = new DataSet();
OdbcDataAdapter mydap = new OdbcDataAdapter(strSQL, mycn);
mydap.Fill(myds, "test");
DataTable mytb = myds.Tables[0];
if (myds.Tables.Count > 0 && mytb.Rows.Count>1)
{
for (int i = 0; i < mytb.Rows.Count; i++)
{
short hk_flag = Convert.ToInt16(mytb.Rows[i][3]);
string grxm = mytb.Rows[i][4].ToString();
string poxm = mytb.Rows[i][5].ToString();
decimal dc_je = Convert.ToDecimal(mytb.Rows[i][6]);
decimal dc_po_je = Convert.ToDecimal(mytb.Rows[i][7]);
string handtelephone = mytb.Rows[i][9].ToString();
if (hk_flag == 100 || hk_flag == 99 || hk_flag == 50)
{
hkCause = "尊敬的" + grxm.Trim().Replace(" ", "") + ",您的住房公积金帐户于" + iyear + "年" + imonth + "月的按月划转" + dc_je + "元,您的配偶" + poxm.Trim().Replace(" ", "") + "按月划转" + dc_po_je + "元!";
}
switch (hk_flag)
{
case 10:
hkCause = "尊敬的" + grxm.Trim().Replace(" ","") + ",您的住房公积金帐户余额不足,本月的按月划转不成功!";
break;
case 11:
hkCause = "尊敬的" + grxm.Trim().Replace(" ", "") + ",您上月未及时还款,本月的按月划转不成功!";
break;
case 12:
hkCause = "尊敬的" + grxm.Trim().Replace(" ", "") + ",您已经还清贷款而自动停止本月的按月划转!";
break;