예제 #1
0
        private void btnChonFile_Click(object sender, EventArgs e)
        {
            grdT140ReconReport.Rows.Clear();
            openDlgChonFileT140.Filter = "Report Files(TT140*.001)|TT140*.001|All Files(*.*)|*.*";
            int n = 0;

            string filename       = "";
            string filenameresult = "";

            if (openDlgChonFileT140.ShowDialog() == DialogResult.OK)
            {
                MC_T140 t140_data = new MC_T140();
                n = openDlgChonFileT140.FileNames.Length;
                txtNumOfFile.Text = n.ToString();
                for (int i = 0; i < n; i++)
                {
                    if (openDlgChonFileT140.FileNames[i].IndexOf("TT140") != -1)
                    {
                        filename       = openDlgChonFileT140.FileNames[i];
                        t140_data      = XuLyFileT140(filename);
                        filenameresult = LuuFileVoiTenMoi(t140_data);
                        HienThiLenManHinh(filenameresult, t140_data);
                    }
                }
            }
            txtUSDTotal1.Text = String.Format("{0:#,##0.##}", TinhTongSoTien(grdT140ReconReport, 6, 7));
            txtVNDTotal1.Text = String.Format("{0:#,##0.##}", TinhTongSoTien(grdT140ReconReport, 6, 8));
        }
예제 #2
0
        public int GhiT140XuongDB(MC_T140 data)
        {
            DateTime runDate       = DateTime.ParseExact(data.runDate, "dd'/'MM'/'yy", null);
            DateTime clearingDate  = DateTime.ParseExact(data.clearingDate, "dd'/'MM'/'yyyy", null);
            int      numofinserted = -1;

            string sqlConnStr = System.Configuration.ConfigurationManager.AppSettings["SQLServerMasterCard"];

            sqlConnStr = EnCode.DeCodeToString(sqlConnStr, _key);
            SqlConnection sqlConn = new SqlConnection(sqlConnStr);

            sqlConn.Open();
            SqlCommand sqlCmd = new SqlCommand("INSERT_T140_GCMS_REPORT", sqlConn);

            sqlCmd.CommandType = CommandType.StoredProcedure;
            sqlCmd.Parameters.Add(new SqlParameter("@FILENAME", data.filename));
            sqlCmd.Parameters.Add(new SqlParameter("@NEWFILENAME", data.newfilename));
            sqlCmd.Parameters.Add(new SqlParameter("@RUNDATE", runDate));
            sqlCmd.Parameters.Add(new SqlParameter("@CLEARINGDATE", clearingDate));
            sqlCmd.Parameters.Add(new SqlParameter("@CYCLE", data.clearingCycle));
            //sqlCmd.Parameters.Add(new SqlParameter("@CURRENCYCODE", data.currencyCode));
            sqlCmd.Parameters.Add(new SqlParameter("@USDAMOUNT", data.USDAmount));
            sqlCmd.Parameters.Add(new SqlParameter("@VNDAMOUNT", data.VNDAmount));

            try{
                numofinserted = sqlCmd.ExecuteNonQuery();
            }
            catch {}

            sqlConn.Close();
            //dtIPC = ICMSDataWithOrderIdx(ipcData);
            //return dtIPC;
            return(numofinserted);
        }
예제 #3
0
 private string LuuFileVoiTenMoi(MC_T140 t140_data)
 {
     try
     {
         File.Copy(t140_data.filename, t140_data.newfilename, checkOverrideNewFileName.Checked);
     }
     catch
     {
         t140_data.newfilename = existed_str;
     }
     return(t140_data.newfilename);
 }
예제 #4
0
        private void HienThiLenManHinh(string filenameresult, MC_T140 data)
        {
            string stt        = "" + (grdT140ReconReport.Rows.Count + 1);
            string usd_amount = String.Format("{0:#,##0.##}", data.USDAmount);
            string vnd_amount = String.Format("{0:#,##0.##}", data.VNDAmount);

            if (filenameresult != existed_str)
            {
                int index = filenameresult.LastIndexOf('\\');
                filenameresult = filenameresult.Substring(index + 1, filenameresult.Length - (index + 1));
            }
            string[] row = new string[] { stt, data.filename, "", filenameresult, data.runDate, data.clearingDate, data.clearingCycle, usd_amount, vnd_amount };
            grdT140ReconReport.Rows.Add(row);
            grdT140ReconReport.Rows[grdT140ReconReport.Rows.Count - 1].Cells[1].Style.ForeColor = Color.Blue;//set color for field 'filepath' to mark this field is the link
        }
예제 #5
0
        private void btnGhiThongTinXuongDB_Click(object sender, EventArgs e)
        {
            int     n    = grdT140ReconReport.Rows.Count;
            MC_T140 data = new MC_T140();

            String[] temp     = new String[1];
            int      index    = 0;
            string   filename = "";
            int      count    = 0;
            string   newname  = "";

            for (int i = 0; i < n; i++)
            {
                newname = grdT140ReconReport.Rows[i].Cells[3].Value.ToString();
                if (newname != existed_str)
                {
                    filename           = grdT140ReconReport.Rows[i].Cells[1].Value.ToString();
                    index              = filename.LastIndexOf('\\');
                    filename           = filename.Substring(index + 1, filename.Length - (index + 1));
                    data.filename      = filename;
                    data.newfilename   = newname;
                    data.runDate       = grdT140ReconReport.Rows[i].Cells[4].Value.ToString();
                    data.clearingDate  = grdT140ReconReport.Rows[i].Cells[5].Value.ToString();
                    data.clearingCycle = grdT140ReconReport.Rows[i].Cells[6].Value.ToString();
                    //data.currencyCode = grdT140ReconReport.Rows[i].Cells[7].Value.ToString();
                    data.USDAmount = Double.Parse(grdT140ReconReport.Rows[i].Cells[7].Value.ToString(), System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowDecimalPoint);
                    data.VNDAmount = Double.Parse(grdT140ReconReport.Rows[i].Cells[8].Value.ToString(), System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowDecimalPoint);
                    if (xl.GhiT140XuongDB(data) == 1)
                    {
                        count++;
                        grdT140ReconReport.Rows[i].Cells[2].Value = "OK";
                    }
                    else
                    {
                        grdT140ReconReport.Rows[i].Cells[2].Value = "Exsited";
                    }
                }
                else
                {
                    grdT140ReconReport.Rows[i].Cells[2].Value = "Fail";
                }
            }

            MessageBox.Show("Information of " + count + " files be inserted to database!");
        }
예제 #6
0
        private MC_T140 XuLyFileT140(string filename)
        {
            MC_T140      t140_data = new MC_T140();
            FileStream   fs        = new FileStream(filename, FileMode.Open);
            StreamReader r         = new StreamReader(fs, Encoding.UTF8);

            String[] temp = new String[1];

            String str = r.ReadLine().Trim();

            if (str.Contains("RUN DATE:"))
            {
                temp = str.Split(charSeparators_space, StringSplitOptions.RemoveEmptyEntries);
                string rundate = temp[temp.Length - 1];
                t140_data.runDate = rundate.Substring(3, 2) + "/" + rundate.Substring(0, 2) + "/" + rundate.Substring(6, 2);
            }
            str = r.ReadLine().Trim();
            if (str.Contains("CLEARING CYCLE"))
            {
                temp = str.Split(charSeparators_space, StringSplitOptions.RemoveEmptyEntries);
                t140_data.clearingCycle = temp[2];
            }
            str = r.ReadLine().Trim();
            if (str.Length == 10)
            {
                string clearingtime = str.Substring(8, 2) + "/" + str.Substring(5, 2) + "/" + str.Substring(0, 4);
                t140_data.clearingDate = clearingtime;
            }
            while (str != null)
            {
                if (str.Contains("CLEARING DAY TOTAL"))
                {
                    for (int j = 0; j < 8; j++)
                    {
                        str = r.ReadLine();
                    }
                    temp = str.Split(charSeparators_space, StringSplitOptions.RemoveEmptyEntries);
                    if (temp[0] == "704-VND")
                    {
                        t140_data.VNDAmount = Double.Parse(temp[1], System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowDecimalPoint);
                    }
                    else
                    if (temp[0] == "840-USD")
                    {
                        t140_data.USDAmount = Double.Parse(temp[1], System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowDecimalPoint);
                    }
                    str  = r.ReadLine();
                    temp = str.Split(charSeparators_space, StringSplitOptions.RemoveEmptyEntries);
                    if (temp[0] == "704-VND")
                    {
                        t140_data.VNDAmount = Double.Parse(temp[1], System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowDecimalPoint);
                    }
                    else
                    if (temp[0] == "840-USD")
                    {
                        t140_data.USDAmount = Double.Parse(temp[1], System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowDecimalPoint);
                    }
                    //t140_data.currencyCode = temp[0];
                    //t140_data.currencyAmount = Double.Parse(temp[1], System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowDecimalPoint);
                    break;
                }
                str = r.ReadLine();
            }
            int index = filename.LastIndexOf('\\');

            temp = t140_data.clearingDate.Split(charSeparators_flash);
            string clearingdate = temp[1] + temp[0] + temp[2];
            string newname      = filename.Substring(0, index) + "\\T140_" + clearingdate + "_" + t140_data.clearingCycle + ".report";

            t140_data.filename    = filename;
            t140_data.newfilename = newname;

            r.Close();
            fs.Close();
            return(t140_data);
        }