积极答复者
求大神指点迷津!

问题
-
我是学习机械专业的学生,但导师让我们自己编程序,现在学习C#也有1个月的时间了,但是以前师兄编的程序还是看不懂,师兄现在已经毕业了,我没的问人,忘哪位高手帮我看看这个程序,顺便再帮我分析分析还应该看些什么书才能看懂这些程序(我已经看完了C#的基本语法和数据库的基本语句),我现在很迷茫。。感激不尽!
protected void report_drop_SelectedIndexChanged(object sender, EventArgs e)
{
string userpath = Server.MapPath(".") + "//User//";
if (report_drop.SelectedValue == "Word报告")
{
int PlanNum;string ResultFilePath = userpath + "\\Report\\SingleWellWordReports";
deletedir(ResultFilePath);
StreamReader sr = new StreamReader(userpath + "//Temp//Simu_ComputePlan.tmp");
PlanNum = Int32.Parse(sr.ReadLine());
sr.Close();
if (PlanNum == 1)
{
SinglePlanWordReport();}
else
{
MultiPlanWordReport();}
}if (report_drop.SelectedValue == "网页报告")
{
string ResultFilePath = userpath + "\\Report\\SingleWellWebReports";deletedir(ResultFilePath);
StreamReader tempsr = new StreamReader(userpath + "\\Temp\\Simu_ComputePlan.tmp", System.Text.Encoding.Default);
int temp = int.Parse(tempsr.ReadLine());
tempsr.Close();
if (temp == 1)
{
SingleWellSRePort();
}
else
{
SingleWellMRePort();}
}}
答案
-
小弟弟,这是ASP.NET,需要的不止是C#语法。你可能还得熟悉BS编程模式。
你给的代码估计是一个下拉框切换选项时的操作。然后生成文件。
.NET,我看行- 已标记为答案 Lie YouModerator 2011年11月17日 3:00
-
我把这段代码加上点注释吧,希望你能看懂:
//在下拉列表index 改变时执行的方法,详情参考:http://msdn.microsoft.com/zh-cn/library/system.windows.forms.combobox.selectedindexchanged.aspx protected void report_drop_SelectedIndexChanged(object sender, EventArgs e) { string userpath = Server.MapPath(".") + "//User//";//取得路径 if (report_drop.SelectedValue == "Word报告") { int PlanNum; string ResultFilePath = userpath + "\\Report\\SingleWellWordReports";//取得SingleWellWordReports路径 deletedir(ResultFilePath);//这个估计执行删除操作,删除的东西应该在deletedir方法有体现 StreamReader sr = new StreamReader(userpath + "//Temp//Simu_ComputePlan.tmp");//用StreamReader 读取Simu_ComputePlan.tmp文件 PlanNum = Int32.Parse(sr.ReadLine());//读取文件的行数 sr.Close();//关闭文件流 if (PlanNum == 1)//判断, { SinglePlanWordReport();//如果文件只有一行,执行该方法 } else { MultiPlanWordReport();//如果不是一行,执行该方法 } } if (report_drop.SelectedValue == "网页报告")//另一个选项 { string ResultFilePath = userpath + "\\Report\\SingleWellWebReports";//取得路径 deletedir(ResultFilePath);//deletedir方法执行 StreamReader tempsr = new StreamReader(userpath + "\\Temp\\Simu_ComputePlan.tmp", System.Text.Encoding.Default);//用Default编码方式读取Simu_ComputePlan.tmp文件 int temp = int.Parse(tempsr.ReadLine());//读取文件的行数 tempsr.Close();//关闭文件流 if (temp == 1)//判断 { SingleWellSRePort();//如果是一行,执行该方法 } else { SingleWellMRePort();//如果多于1行,执行这个方法(估计这里写错方法了吧。 } } }
希望对您有所帮助。
Best Regards,
Rocky Yue[MSFT]
MSDN Community Support | Feedback to us
- 已编辑 Lie YouModerator 2011年11月14日 7:22
- 已标记为答案 Lie YouModerator 2011年11月17日 2:59
全部回复
-
小弟弟,这是ASP.NET,需要的不止是C#语法。你可能还得熟悉BS编程模式。
你给的代码估计是一个下拉框切换选项时的操作。然后生成文件。
.NET,我看行- 已标记为答案 Lie YouModerator 2011年11月17日 3:00
-
我把这段代码加上点注释吧,希望你能看懂:
//在下拉列表index 改变时执行的方法,详情参考:http://msdn.microsoft.com/zh-cn/library/system.windows.forms.combobox.selectedindexchanged.aspx protected void report_drop_SelectedIndexChanged(object sender, EventArgs e) { string userpath = Server.MapPath(".") + "//User//";//取得路径 if (report_drop.SelectedValue == "Word报告") { int PlanNum; string ResultFilePath = userpath + "\\Report\\SingleWellWordReports";//取得SingleWellWordReports路径 deletedir(ResultFilePath);//这个估计执行删除操作,删除的东西应该在deletedir方法有体现 StreamReader sr = new StreamReader(userpath + "//Temp//Simu_ComputePlan.tmp");//用StreamReader 读取Simu_ComputePlan.tmp文件 PlanNum = Int32.Parse(sr.ReadLine());//读取文件的行数 sr.Close();//关闭文件流 if (PlanNum == 1)//判断, { SinglePlanWordReport();//如果文件只有一行,执行该方法 } else { MultiPlanWordReport();//如果不是一行,执行该方法 } } if (report_drop.SelectedValue == "网页报告")//另一个选项 { string ResultFilePath = userpath + "\\Report\\SingleWellWebReports";//取得路径 deletedir(ResultFilePath);//deletedir方法执行 StreamReader tempsr = new StreamReader(userpath + "\\Temp\\Simu_ComputePlan.tmp", System.Text.Encoding.Default);//用Default编码方式读取Simu_ComputePlan.tmp文件 int temp = int.Parse(tempsr.ReadLine());//读取文件的行数 tempsr.Close();//关闭文件流 if (temp == 1)//判断 { SingleWellSRePort();//如果是一行,执行该方法 } else { SingleWellMRePort();//如果多于1行,执行这个方法(估计这里写错方法了吧。 } } }
希望对您有所帮助。
Best Regards,
Rocky Yue[MSFT]
MSDN Community Support | Feedback to us
- 已编辑 Lie YouModerator 2011年11月14日 7:22
- 已标记为答案 Lie YouModerator 2011年11月17日 2:59