Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I am having a form1 with some textboxes and 3 buttons namely Save cancel and AddEntry.

On clicking save i will check for a condition if it is false i will raise an error. Now if i click on AddEntry Button Form1 data will be as it is and i will show form2 for the user on that form2 i will have some textboxes and 2 buittons. If user enter some data and click on save i will show form1 now if the user clicks on save of form1 i would like to save the data in to the required path i specified

The sample code form Form1 is

public bool saveBatchHeader(string m_strPath)<br />
        {<br />
            StringBuilder sb = new StringBuilder();<br />
            sb.AppendLine();<br />
            sb.Append(m_strRecordTypeCode.PadLeft(1, '0'));<br />
            sb.Append(m_strServiceClassCode.PadLeft(3, '0'));<br />
            sb.Append(m_strCompanyName.PadRight(16, ' '));<br />
            sb.Append(m_strCompanyDiscretionaryData.PadRight(20, ' '));<br />
            sb.Append(m_strCompanyIdentification.PadRight(10, ' '));<br />
            sb.Append(m_strStandardEntryClassCode.PadRight(3, ' '));<br />
            sb.Append(m_strCompanyEntryDescription.PadRight(10, ' '));<br />
            string m_strCompanyDescripDate = m_strCompanyDescriptiveDate.Replace("/", "");<br />
            sb.Append(m_strCompanyDescripDate.PadLeft(6, '0'));<br />
            string m_strEffDate = m_strEffectiveEntryDate.Replace("/", "");<br />
            sb.Append(m_strEffDate.PadLeft(6, '0'));<br />
            sb.Append(m_strJulianDate.PadRight(3, ' '));<br />
            sb.Append(m_strOriginatorStatusCode.PadRight(1, ' '));<br />
            sb.Append(m_strOriginationDFIIdentification.PadLeft(8, '0'));<br />
            sb.Append(m_strBatchNumber.PadLeft(7, '0'));<br />
            sb.Replace("\r\n", String.Empty);<br />
            int len = sb.Length;<br />
            if (len < 95)<br />
            {<br />
                m_flag = false;<br />
            }<br />
            else<br />
            {<br />
                StreamWriter sw = File.AppendText(m_strPath);<br />
                sw.Write(sb);<br />
                sw.Close();<br />
            }<br />
            return m_flag;<br />
        }


For form the class file is as follows

C#
public bool saveEntry(string strPath)
    {
        m_flag = true;
        string FileName = strPath;
        string m_strDate = DateTime.Now.ToString("MM/dd/yyyy");
        m_strDate = m_strDate.Replace("/", "");
        strPath += "/CCD_EntryDetailRecord_" + m_strDate + ".txt";

        using (TextWriter tw = new StreamWriter(strPath))
        {
            tw.Write(m_strRecordTypeCode.PadLeft(1, '0'));
            tw.Write(m_strTransactionCode.PadLeft(2, '0'));
            tw.Write(m_strRecievingDFIIdentification.PadLeft(9, '0'));
            tw.Write(m_strDFIAccountNumber.PadRight(17, ' '));
            tw.Write(m_strAmount.PadLeft(10, '0'));
            tw.Write(m_strIdentificationNumber.PadRight(15, ' '));
            tw.Write(m_strRecievingcompanyName.PadRight(22, ' '));
            tw.Write(m_strDiscretionaryData.PadRight(2, ' '));
            tw.Write(m_strAddendaRecordIndicator.PadLeft(1, '0'));
            tw.Write("TTTTBBBBZZZZZZZ");
            tw.WriteLine();
            tw.Flush();
            tw.Close();
    }

So can any one tell how to get this data appended after

sb.Append(m_strBatchNumber.PadLeft(7, '0'));

in the first form code.
Posted

Hi,

I have posted answer for similar kind of question. Check it out

http://www.codeproject.com/Answers/102018/desktop-application.aspx#answer1[^]

Hope this will help you

Regards,
Suresh
 
Share this answer
 
Comments
demouser743 7-Sep-10 4:06am    
Reason for my vote of 5
Thanks i got the solution
use a static class and declare static variables in it..
the static variables can access using
classname.variable name
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900