.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

Hello Sir

Posted By: Naim Khan     Posted Date: January 07, 2009    Points:2   Category :Windows Application
Sir i have created Folder but the problem is that when i click the No in Dialogbox while folder not created but the data has been saved in Database i dont know why is doing if u know that plz tell me i m sending code and tell me if i create next year folder then previous file should be moved or copy in next folder plz send me code .......


try
{

con = new SqlConnection(Program.ConStr);
con.Open();
SqlCommand cmd = new SqlCommand("insert YearOfOperation(DefaultYear,AssessmentYear,FromYear,ToYear,TDSChI,TDSChD,BSRCode,Name,Designation,Address#1,Address#2,Address#3,City,PinCode,ChallanType,PrintChallan,EducationCess) values('" + txtDsetup.Text + "','" + txtAsse.Text + "','" + txtFto.Text + "','" + txtTo.Text + "','" + txtTDSIssued.Text + "','" + txtTDSDeposite.Text + "','" + txtBSR.Text + "','" + txtName.Text + "','" + txtDesn.Text + "','" + txtAdd1.Text + "','" + txtAdd2.Text + "','" + txtAdd3.Text + "','" + txtCity.Text + "','" + txtPin.Text + "','" + txtChallan.Text + "','" + comboBox2.Text + "','" + txtEcess.Text + "')", con);
cmd.ExecuteNonQuery();
string activeDir = @"D:\Contax DataBase";
string year = txtDsetup.Text;
string newPath = System.IO.Path.Combine(activeDir, year);
System.IO.Directory.CreateDirectory(newPath);
string newFileName = System.IO.Path.GetRandomFileName();
newPath = System.IO.Path.Combine(newPath, newFileName);
if (!System.IO.File.Exists(newPath))
{
using (FileStream fs = new FileStream(newPath, FileMode.CreateNew))
{
BinaryWriter bw = new BinaryWriter(fs);
string DefaultYear = txtDsetup.Text;
string AssessmentYear = txtAsse.Text;
string FromYear = txtFto.Text;
string ToYear = txtTo.Text;
string TDSChI = txtTDSIssued.Text;
string TDSChD = txtTDSDeposite.Text;
string BSRCode = txtBSR.Text;
string Name = txtName.Text;
string Designation = txtDesn.Text.ToUpper();
string Add1 = txtAdd1.Text.ToUpper();
string Add2 = txtAdd2.Text;
string add3 = txtAdd3.Text;
string City = txtCity.Text;
string PinCode = txtPin.Text;
string challanType = txtChallan.Text;
string PrintChallan = comboBox1.Text;
string EduCess = txtEcess.Text;
bw.Write(DefaultYear);
bw.Write(AssessmentYear);
bw.Write(TDSChI);
bw.Write(TDSChD);
bw.Write(BSRCode);
bw.Write(Name);
bw.Write(Designation);
bw.Write(Add1);
bw.Write(Add2);
bw.Write(add3);
bw.Write(City);
bw.Write(PinCode);
bw.Write(challanType);
bw.Write(PrintChallan);
bw.Flush();
bw.Close();


DialogResult dr = MessageBox.Show("ARE YOU SURE YOU WANT TO CREATE FINANCIAL YEAR ? ", "Information", MessageBoxButtons.OKCancel , MessageBoxIcon.Asterisk);
if (dr == DialogResult.Yes)
{
this.Close();

}
else if (dr == DialogResult.No)
{
this.Close();
}
}
}


}

catch (Exception exc)
{
MessageBox.Show(exc.Message + "Retry Again");
}

Responses
Author: Vuyiswa Maseko             
Posted Date: January 07, 2009     Points: 5   

Firstly please please stop using the Subject "Hello Sir" and the Second thing post us where you get an Error and Show us a Piece of the Code not the whole code. it does not look good its messy. Remember we dont know what you are trying to do butr the way you explain is as if we know.ask the question again.

Author: krishana singh             
Posted Date: December 09, 2010     Points: 5   

Firstly please please stop using the Subject "Hello Sir" and the Second thing post us where you get an Error and Show us a Piece of the Code not the whole code. it does not look good its messy. Remember we dont know what you are trying to do butr the way you explain is as if we know.ask the question again.

Author: Narayanan             
Posted Date: April 09, 2012     Points: 20   

Hi,
Place of Coding(Create Folder) is wrong.As per my under ,user clicks "Yes" button folder will create and store a information in the file.Am i right? If yes means try this code
try
{
con = new SqlConnection(Program.ConStr);
con.Open();
SqlCommand cmd = new SqlCommand("insert YearOfOperation(DefaultYear,AssessmentYear,FromYear,ToYear,TDSChI,TDSChD,BSRCode,Name,Designation,Address#1,Address#2,Address#3,City,PinCode,ChallanType,PrintChallan,EducationCess) values('" + txtDsetup.Text + "','" + txtAsse.Text + "','" + txtFto.Text + "','" + txtTo.Text + "','" + txtTDSIssued.Text + "','" + txtTDSDeposite.Text + "','" + txtBSR.Text + "','" + txtName.Text + "','" + txtDesn.Text + "','" + txtAdd1.Text + "','" + txtAdd2.Text + "','" + txtAdd3.Text + "','" + txtCity.Text + "','" + txtPin.Text + "','" + txtChallan.Text + "','" + comboBox2.Text + "','" + txtEcess.Text + "')", con);
cmd.ExecuteNonQuery();
DialogResult dr = MessageBox.Show("ARE YOU SURE YOU WANT TO CREATE FINANCIAL YEAR ? ", "Information", MessageBoxButtons.OKCancel , MessageBoxIcon.Asterisk);
if (dr == DialogResult.Yes)
{
string activeDir = @"D:\Contax DataBase";
string year = txtDsetup.Text;
string newPath = System.IO.Path.Combine(activeDir, year);
System.IO.Directory.CreateDirectory(newPath);
string newFileName = System.IO.Path.GetRandomFileName();
newPath = System.IO.Path.Combine(newPath, newFileName);
if (!System.IO.File.Exists(newPath))
{
using (FileStream fs = new FileStream(newPath, FileMode.CreateNew))
{
BinaryWriter bw = new BinaryWriter(fs);
string DefaultYear = txtDsetup.Text;
string AssessmentYear = txtAsse.Text;
string FromYear = txtFto.Text;
string ToYear = txtTo.Text;
string TDSChI = txtTDSIssued.Text;
string TDSChD = txtTDSDeposite.Text;
string BSRCode = txtBSR.Text;
string Name = txtName.Text;
string Designation = txtDesn.Text.ToUpper();
string Add1 = txtAdd1.Text.ToUpper();
string Add2 = txtAdd2.Text;
string add3 = txtAdd3.Text;
string City = txtCity.Text;
string PinCode = txtPin.Text;
string challanType = txtChallan.Text;
string PrintChallan = comboBox1.Text;
string EduCess = txtEcess.Text;
bw.Write(DefaultYear);
bw.Write(AssessmentYear);
bw.Write(TDSChI);
bw.Write(TDSChD);
bw.Write(BSRCode);
bw.Write(Name);
bw.Write(Designation);
bw.Write(Add1);
bw.Write(Add2);
bw.Write(add3);
bw.Write(City);
bw.Write(PinCode);
bw.Write(challanType);
bw.Write(PrintChallan);
bw.Flush();
bw.Close();
}
}

}
else if (dr == DialogResult.No)
{
this.Close();
}

}

catch (Exception exc)
{
MessageBox.Show(exc.Message + "Retry Again");
}


Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend