新人该如何"生存"的问题 新到公司报到,被要求看以前产品的内部代码,不看不知道,一看吓一跳!好深奥啊,代码实现完全跟学校里自己鼓捣的东西天上地下,直接晕了,而且很久恢复不过来,这样的状态正常么?该怎么去适应呢?求各位看官指点迷津啊!这样的状态太难受了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 应楼上的要求贴一下!<页面的代码><%@ Page Language="C#" MasterPageFile="~/master/MasterPageFelix.master" AutoEventWireup="true" CodeFile="viewSupplierQuestionaire.aspx.cs" Inherits="viewSupplierQuestionaire_viewSupplierQuestionaire" %><%@ Register Namespace="com.dcpi.questionaire.view.gui" TagPrefix="dcpi" Assembly="DCPiQuestionaire" %><%@ Register Namespace="com.felix.gui.controls" TagPrefix="felix" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderSideNavigation" Runat="Server"> <asp:Label runat="server" ID="LabelQuestionaireInstanceID" Visible="false" /> <asp:Panel runat="server" ID="PanelPlaceHolderTree" /> <asp:LinkButton runat="server" Text="Documents" OnClick="ShowDocuments" /> </asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderMain" Runat="Server"> <asp:Label runat="server" ID="LabelSupplierID" Visible="false" /> <asp:SqlDataSource runat="server" ID="SqlDataSourceDocumentTypes" ConnectionString="<%$ConnectionStrings:ConnectionStringFelix %>" SelectCommand=" select ObjectID, Name from dbo.Felix_DocumentCategory where Valid = 1 and RoleID = @RoleSupplier" > <SelectParameters> <asp:Parameter Name="RoleSupplier" /> </SelectParameters> </asp:SqlDataSource> <asp:SqlDataSource runat="server" ID="SqlDataSourceDocuments" ConnectionString="<%$ConnectionStrings:ConnectionStringFelix %>" SelectCommand=" select * from dbo.Felix_SupplierDocument where SupplierID = @SupplierID and DocumentCategoryID = @DocumentCategoryID and Valid = 1 and ExpirationNotificationSent = 0" > <SelectParameters> <asp:ControlParameter Name="DocumentCategoryID" ControlID="DropDownListDocumentCategories" /> <asp:ControlParameter Name="SupplierID" ControlID="LabelSupplierID"/> </SelectParameters> </asp:SqlDataSource> <dcpi:Questionaire runat="server" ID="QuestionaireSupplierProfile" TreeViewContainer="PanelPlaceHolderTree" QuestionsContainer="PanelPlaceHolderQuestions" ButtonsContainer="PanelPlaceHolderButtons" OnQuestionaireCategoryChangedEvent="OnQuestionaireCategoryChangedEvent" /> <asp:MultiView runat="server" ID="MultiViewSupplierProfile"> <asp:View runat="server" ID="ViewQuestionaire"> <asp:LoginView runat="server" ID="LoginViewTop"> <RoleGroups> <asp:RoleGroup Roles="admin"> <ContentTemplate> <div> <felix:FelixButton runat="server" ID="LinkButtonToggleModeTop" OnClick="ToggleMode" Text="Edit" OnClientClick="return CheckForChanges();" /> </div> <br /> </ContentTemplate> </asp:RoleGroup> </RoleGroups> </asp:LoginView> <asp:Panel runat="server" ID="PanelPlaceHolderQuestions" /> <asp:Panel runat="server" ID="PanelPlaceHolderButtons" /> <asp:LoginView runat="server" ID="LoginViewBottom"> <RoleGroups> <asp:RoleGroup Roles="admin"> <ContentTemplate> <div align="right" Style="padding :20px;"> <felix:FelixButton runat="server" ID="LinkButtonToggleModeBottom" OnClick="ToggleMode" Text="Edit" OnClientClick="return CheckForChanges();"/> </div> </ContentTemplate> </asp:RoleGroup> </RoleGroups> </asp:LoginView> <hr /> <felix:FelixButton ID="FelixButton1" runat="server" Text="Download" OnClick="Export" /> </asp:View> <asp:View runat="server" ID="ViewDocuments"> <asp:Table runat="server" CssClass="wraptable" Width="100%"> <asp:TableRow> <asp:TableCell> Supplier Documents </asp:TableCell> </asp:TableRow> </asp:Table> <asp:DropDownList runat="server" ID="DropDownListDocumentCategories" DataSourceID="SqlDataSourceDocumentTypes" DataValueField="ObjectID" DataTextField="Name" AutoPostBack="true" OnSelectedIndexChanged="DropDownListDocumentCategories_OnSelectedIndexChanged" OnDataBound="DropDownListDocumentCategories_OnDataBound" /> <asp:GridView runat="server" ID="GridViewDocuments" DataSourceID="SqlDataSourceDocuments" AutoGenerateColumns="false" > <EmptyDataTemplate> No documents in this category found </EmptyDataTemplate> <Columns> <asp:TemplateField> <HeaderTemplate> Document </HeaderTemplate> <ItemTemplate> <%--<asp:HyperLink runat="server" Text='<%#Eval("OrgFileName") %>' NavigateUrl=<%#Eval("Filename") %> OnPreRender="Hyperlink_OnPreRender" Target="_blank"/>--%> <asp:LinkButton runat="server" Text='<%#Eval("OrgFileName") %>' CommandArgument='<%#Eval("ObjectID") %>' OnClick="Download"/> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <HeaderTemplate> Upload Date </HeaderTemplate> <ItemTemplate> <asp:Label runat="server" Text='<%#Eval("UploadDate", "{0:d}") %>' /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <HeaderTemplate> Expiration Date </HeaderTemplate> <ItemTemplate> <asp:Label runat="server" Text='<%#Eval("ExpirationDate", "{0:d}") %>' /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </asp:View> </asp:MultiView> </asp:Content><asp:Content runat="server" ContentPlaceHolderID="ContentPlaceholderTitle"> <table> <tr> <th> Supplier Profile for <asp:Label runat="server" ID="LabelSupplierName" /> </th> <td> <asp:Image ID="Image1" runat="server" ImageUrl="~/styleImages/folder.gif" /> </td> </tr> </table> <asp:Label runat="server" ID="LabelSupplierStatus" SkinID="LabelStatusTitle"/></asp:Content> <CLASS 代码>using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using com.felix.gui.pages;using com.dcpi.questionaire.view.gui;using com.felix.util;using System.Data.SqlClient;using com.felix.gui.controls;using com.dcpi.questionaire.view;public partial class viewSupplierQuestionaire_viewSupplierQuestionaire : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { this.SqlDataSourceDocumentTypes.SelectParameters["RoleSupplier"].DefaultValue = Finals.SUPPLIER.ToString(); if (!this.IsPostBack) { this.LabelQuestionaireInstanceID.Text = HttpContext.Current.Items[Finals.SELECTED_SUPPLIER].ToString(); SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionStringFelix"].ConnectionString); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "select sup.ObjectID, sup.Name, st.DisplayText as RegistrationStatus from dbo.Felix_Supplier sup, Felix_RegistrationStatus st where QuestionaireInstanceID = " + this.LabelQuestionaireInstanceID.Text + " and sup.RegistrationStatusID = st.ObjectID "; con.Open(); SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); this.LabelSupplierID.Text = reader["ObjectID"].ToString(); this.LabelSupplierName.Text = reader["Name"].ToString(); this.LabelSupplierStatus.Text = reader["RegistrationStatus"].ToString(); con.Close(); this.InsertBuyerViewedSupplier(); this.QuestionaireSupplierProfile.Mode = Questionaire.READONLY_MODE; this.QuestionaireSupplierProfile.LanguageID = Finals.ENGLISH; this.QuestionaireSupplierProfile.QuestionaireID = int.Parse(this.LabelQuestionaireInstanceID.Text); this.MultiViewSupplierProfile.SetActiveView(this.ViewQuestionaire); } int questionaireCategoryInstanceID = (new ViewImpl()).retreiveQuestionaireCategoryInstance(int.Parse(this.LabelQuestionaireInstanceID.Text), Finals.QUESTIONAIRE_CATEGORY_GENERAL_INFORMATION, -1).ID; this.QuestionaireSupplierProfile.DefaultCategory = questionaireCategoryInstanceID; } private void InsertBuyerViewedSupplier() { string userID = Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString(); SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionStringFelix"].ConnectionString); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "select ObjectID from dbo.Felix_Supplier where QuestionaireInstanceID = " + this.LabelQuestionaireInstanceID.Text + " and Valid = 1"; con.Open(); object res = cmd.ExecuteScalar(); if(res != DBNull.Value){ cmd.CommandText = "insert into dbo.Felix_BuyerViewedSupplier(UserID, SupplierID) values ('" + userID + "', " + res +")"; cmd.ExecuteNonQuery(); } con.Close(); } public void Export(object sender, EventArgs e) { HttpContext.Current.Items.Add("QuestionaireInstanceID", this.QuestionaireSupplierProfile.QuestionaireID); HttpContext.Current.Server.Transfer("~/SupplierQuestionareReport/SupplierQuestionareReport.aspx"); } public void ShowDocuments(object sender, EventArgs e) { this.MultiViewSupplierProfile.SetActiveView(this.ViewDocuments); } public void DropDownListDocumentCategories_OnSelectedIndexChanged(object sender, EventArgs e) { this.GridViewDocuments.DataBind(); this.ShowDocuments(sender, e); } public void ToggleMode(object sender, EventArgs e) { if(this.QuestionaireSupplierProfile.Mode== Questionaire.READONLY_MODE) { this.QuestionaireSupplierProfile.Mode = Questionaire.EDIT_MODE; ((FelixButton)this.LoginViewBottom.FindControl("LinkButtonToggleModeBottom")).Text = "End Edit"; ((FelixButton)this.LoginViewTop.FindControl("LinkButtonToggleModeTop")).Text = "End Edit"; } else { this.QuestionaireSupplierProfile.Mode = Questionaire.READONLY_MODE; ((FelixButton)this.LoginViewBottom.FindControl("LinkButtonToggleModeBottom")).Text = "Edit"; ((FelixButton)this.LoginViewTop.FindControl("LinkButtonToggleModeTop")).Text = "Edit"; } } public void OnQuestionaireCategoryChangedEvent(object sender, EventArgs e) { this.ShowQuestionaire(sender, e); } private void ShowQuestionaire(object sender, EventArgs e) { this.MultiViewSupplierProfile.SetActiveView(this.ViewQuestionaire); } public void Download(object sender, EventArgs e) { string orgFileName; string serverFileName; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionStringFelix"].ConnectionString); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "select OrgFilename, Filename from dbo.Felix_SupplierDocument where ObjectID = " + ((IButtonControl)sender).CommandArgument; con.Open(); SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); orgFileName = (string)reader["OrgFilename"]; serverFileName = ConfigurationManager.AppSettings["UploadPath"] + reader["Filename"]; con.Close(); Response.ContentType = "APPLICATION/OCTET-STREAM"; System.String disHeader = "Attachment; Filename=\"" + orgFileName + "\""; Response.AppendHeader("Content-Disposition", disHeader); System.IO.FileInfo fileToDownload = new System.IO.FileInfo(serverFileName); Response.Flush(); Response.WriteFile(fileToDownload.FullName); } public void DropDownListDocumentCategories_OnDataBound(object sender, EventArgs e) { this.GridViewDocuments.DataBind(); }} 这代码有什么特别的 ?除了一股脑的写在aspx.cs 再没看到什么 一个一个 复制到MSDN的搜索框中搜索一下 都是基本示例不清楚的 也可以直接问同事 这么大一堆代码网上怎么解释哦。 <dcpi:Questionaire runat="server" ID="QuestionaireSupplierProfile" TreeViewContainer="PanelPlaceHolderTree" QuestionsContainer="PanelPlaceHolderQuestions" ButtonsContainer="PanelPlaceHolderButtons" OnQuestionaireCategoryChangedEvent="OnQuestionaireCategoryChangedEvent" />这个没有见过 应该是自己写的控件 就是这个Questionaire 没有看明白 原来是公司自己写的控件 其他的都没有什么了啊 很平常的代码啊就是少了注释了 不规范 我们以后开发要注意咯!!! 只看这段:public void Download(object sender, EventArgs e) { string orgFileName; string serverFileName; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionStringFelix"].ConnectionString); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "select OrgFilename, Filename from dbo.Felix_SupplierDocument where ObjectID = " + ((IButtonControl)sender).CommandArgument; con.Open(); SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); orgFileName = (string)reader["OrgFilename"]; serverFileName = ConfigurationManager.AppSettings["UploadPath"] + reader["Filename"]; con.Close(); Response.ContentType = "APPLICATION/OCTET-STREAM"; System.String disHeader = "Attachment; Filename=\"" + orgFileName + "\""; Response.AppendHeader("Content-Disposition", disHeader); System.IO.FileInfo fileToDownload = new System.IO.FileInfo(serverFileName); Response.Flush(); Response.WriteFile(fileToDownload.FullName); }就觉得你写这些代码的那位同事还需要好好提升面向对象设计能力和分析能力,不过楼主不要怕,静下心来,平时多看看一些大师的书,比如重构,敏捷开发,.net大局观,thin in java,多看看优秀的开源代码,比如NHibernate,Enterprise library。不到三个月你就可以超过你这位同事了,真的。所以你不要气馁和退却哦 谢谢所有在这里发言,给予意见建议指正批评的所有朋友,谢谢你们,我开始喜欢CSDN的氛围了,真好! To:楼主一个小小的建议:你也可以自己试着编写类似的程序或UserControls,一点要去写,看是看不懂的,只有这样才能尽快上手。祝你好运! 内存中有一dataset,如何与数据库的表判断哪个记录重复了 VB6中DES加密调用问题 如何在代码中修改网页的标题 如何制作这样的calender控件? 求一正则表达式 ASP Web应用程序为何在VS2003中调试不了? Asp.net使用MySQLDriverCS组件总是隔断出现错误?求助! 请问如何判断页面上的Textbox获得焦点. 紧急求助 请教关于使用C#进行微信开发的XML的接收问题 SetAuthCookie 的安全性? string类型的范围~~~~很简单的问题
<%@ Page Language="C#" MasterPageFile="~/master/MasterPageFelix.master" AutoEventWireup="true" CodeFile="viewSupplierQuestionaire.aspx.cs" Inherits="viewSupplierQuestionaire_viewSupplierQuestionaire" %>
<%@ Register Namespace="com.dcpi.questionaire.view.gui" TagPrefix="dcpi" Assembly="DCPiQuestionaire" %>
<%@ Register Namespace="com.felix.gui.controls" TagPrefix="felix" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderSideNavigation" Runat="Server">
<asp:Label runat="server" ID="LabelQuestionaireInstanceID" Visible="false" />
<asp:Panel runat="server" ID="PanelPlaceHolderTree" />
<asp:LinkButton runat="server" Text="Documents" OnClick="ShowDocuments" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderMain" Runat="Server"> <asp:Label runat="server" ID="LabelSupplierID" Visible="false" />
<asp:SqlDataSource
runat="server"
ID="SqlDataSourceDocumentTypes"
ConnectionString="<%$ConnectionStrings:ConnectionStringFelix %>"
SelectCommand=" select
ObjectID, Name
from
dbo.Felix_DocumentCategory
where
Valid = 1 and
RoleID = @RoleSupplier"
>
<SelectParameters>
<asp:Parameter Name="RoleSupplier" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource
runat="server"
ID="SqlDataSourceDocuments"
ConnectionString="<%$ConnectionStrings:ConnectionStringFelix %>"
SelectCommand=" select
*
from
dbo.Felix_SupplierDocument
where
SupplierID = @SupplierID and
DocumentCategoryID = @DocumentCategoryID and
Valid = 1 and
ExpirationNotificationSent = 0"
>
<SelectParameters>
<asp:ControlParameter Name="DocumentCategoryID" ControlID="DropDownListDocumentCategories" />
<asp:ControlParameter Name="SupplierID" ControlID="LabelSupplierID"/>
</SelectParameters>
</asp:SqlDataSource>
<dcpi:Questionaire
runat="server"
ID="QuestionaireSupplierProfile"
TreeViewContainer="PanelPlaceHolderTree"
QuestionsContainer="PanelPlaceHolderQuestions"
ButtonsContainer="PanelPlaceHolderButtons"
OnQuestionaireCategoryChangedEvent="OnQuestionaireCategoryChangedEvent"
/> <asp:MultiView runat="server" ID="MultiViewSupplierProfile">
<asp:View runat="server" ID="ViewQuestionaire">
<asp:LoginView runat="server" ID="LoginViewTop">
<RoleGroups>
<asp:RoleGroup Roles="admin">
<ContentTemplate>
<div>
<felix:FelixButton runat="server" ID="LinkButtonToggleModeTop" OnClick="ToggleMode" Text="Edit" OnClientClick="return CheckForChanges();" />
</div>
<br />
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>
<asp:Panel runat="server" ID="PanelPlaceHolderQuestions" />
<asp:Panel runat="server" ID="PanelPlaceHolderButtons" />
<asp:LoginView runat="server" ID="LoginViewBottom">
<RoleGroups>
<asp:RoleGroup Roles="admin">
<ContentTemplate>
<div align="right" Style="padding :20px;">
<felix:FelixButton runat="server" ID="LinkButtonToggleModeBottom" OnClick="ToggleMode" Text="Edit" OnClientClick="return CheckForChanges();"/>
</div>
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>
<hr />
<felix:FelixButton ID="FelixButton1" runat="server" Text="Download" OnClick="Export" />
</asp:View>
<asp:View runat="server" ID="ViewDocuments">
<asp:Table runat="server" CssClass="wraptable" Width="100%">
<asp:TableRow>
<asp:TableCell>
Supplier Documents
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:DropDownList
runat="server"
ID="DropDownListDocumentCategories"
DataSourceID="SqlDataSourceDocumentTypes"
DataValueField="ObjectID"
DataTextField="Name"
AutoPostBack="true"
OnSelectedIndexChanged="DropDownListDocumentCategories_OnSelectedIndexChanged"
OnDataBound="DropDownListDocumentCategories_OnDataBound"
/>
<asp:GridView
runat="server"
ID="GridViewDocuments"
DataSourceID="SqlDataSourceDocuments"
AutoGenerateColumns="false"
>
<EmptyDataTemplate>
No documents in this category found
</EmptyDataTemplate>
<Columns>
<asp:TemplateField>
<HeaderTemplate>
Document
</HeaderTemplate>
<ItemTemplate>
<%--<asp:HyperLink runat="server" Text='<%#Eval("OrgFileName") %>' NavigateUrl=<%#Eval("Filename") %> OnPreRender="Hyperlink_OnPreRender" Target="_blank"/>--%>
<asp:LinkButton runat="server" Text='<%#Eval("OrgFileName") %>' CommandArgument='<%#Eval("ObjectID") %>' OnClick="Download"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Upload Date
</HeaderTemplate>
<ItemTemplate>
<asp:Label runat="server" Text='<%#Eval("UploadDate", "{0:d}") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Expiration Date
</HeaderTemplate>
<ItemTemplate>
<asp:Label runat="server" Text='<%#Eval("ExpirationDate", "{0:d}") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:View>
</asp:MultiView>
</asp:Content><asp:Content runat="server" ContentPlaceHolderID="ContentPlaceholderTitle">
<table>
<tr>
<th>
Supplier Profile for <asp:Label runat="server" ID="LabelSupplierName" />
</th>
<td>
<asp:Image ID="Image1" runat="server" ImageUrl="~/styleImages/folder.gif" />
</td>
</tr>
</table>
<asp:Label runat="server" ID="LabelSupplierStatus" SkinID="LabelStatusTitle"/>
</asp:Content>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using com.felix.gui.pages;
using com.dcpi.questionaire.view.gui;
using com.felix.util;
using System.Data.SqlClient;
using com.felix.gui.controls;
using com.dcpi.questionaire.view;public partial class viewSupplierQuestionaire_viewSupplierQuestionaire : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.SqlDataSourceDocumentTypes.SelectParameters["RoleSupplier"].DefaultValue = Finals.SUPPLIER.ToString();
if (!this.IsPostBack)
{
this.LabelQuestionaireInstanceID.Text = HttpContext.Current.Items[Finals.SELECTED_SUPPLIER].ToString();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionStringFelix"].ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select sup.ObjectID, sup.Name, st.DisplayText as RegistrationStatus from dbo.Felix_Supplier sup, Felix_RegistrationStatus st where QuestionaireInstanceID = " + this.LabelQuestionaireInstanceID.Text + " and sup.RegistrationStatusID = st.ObjectID ";
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
this.LabelSupplierID.Text = reader["ObjectID"].ToString();
this.LabelSupplierName.Text = reader["Name"].ToString();
this.LabelSupplierStatus.Text = reader["RegistrationStatus"].ToString();
con.Close();
this.InsertBuyerViewedSupplier();
this.QuestionaireSupplierProfile.Mode = Questionaire.READONLY_MODE;
this.QuestionaireSupplierProfile.LanguageID = Finals.ENGLISH;
this.QuestionaireSupplierProfile.QuestionaireID = int.Parse(this.LabelQuestionaireInstanceID.Text);
this.MultiViewSupplierProfile.SetActiveView(this.ViewQuestionaire); } int questionaireCategoryInstanceID = (new ViewImpl()).retreiveQuestionaireCategoryInstance(int.Parse(this.LabelQuestionaireInstanceID.Text), Finals.QUESTIONAIRE_CATEGORY_GENERAL_INFORMATION, -1).ID;
this.QuestionaireSupplierProfile.DefaultCategory = questionaireCategoryInstanceID;
} private void InsertBuyerViewedSupplier()
{
string userID = Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionStringFelix"].ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select ObjectID from dbo.Felix_Supplier where QuestionaireInstanceID = " + this.LabelQuestionaireInstanceID.Text + " and Valid = 1";
con.Open();
object res = cmd.ExecuteScalar();
if(res != DBNull.Value){
cmd.CommandText = "insert into dbo.Felix_BuyerViewedSupplier(UserID, SupplierID) values ('" + userID + "', " + res +")";
cmd.ExecuteNonQuery();
}
con.Close();
} public void Export(object sender, EventArgs e)
{
HttpContext.Current.Items.Add("QuestionaireInstanceID", this.QuestionaireSupplierProfile.QuestionaireID);
HttpContext.Current.Server.Transfer("~/SupplierQuestionareReport/SupplierQuestionareReport.aspx");
} public void ShowDocuments(object sender, EventArgs e)
{
this.MultiViewSupplierProfile.SetActiveView(this.ViewDocuments);
} public void DropDownListDocumentCategories_OnSelectedIndexChanged(object sender, EventArgs e)
{
this.GridViewDocuments.DataBind();
this.ShowDocuments(sender, e);
} public void ToggleMode(object sender, EventArgs e)
{
if(this.QuestionaireSupplierProfile.Mode== Questionaire.READONLY_MODE)
{
this.QuestionaireSupplierProfile.Mode = Questionaire.EDIT_MODE;
((FelixButton)this.LoginViewBottom.FindControl("LinkButtonToggleModeBottom")).Text = "End Edit";
((FelixButton)this.LoginViewTop.FindControl("LinkButtonToggleModeTop")).Text = "End Edit";
}
else
{
this.QuestionaireSupplierProfile.Mode = Questionaire.READONLY_MODE;
((FelixButton)this.LoginViewBottom.FindControl("LinkButtonToggleModeBottom")).Text = "Edit";
((FelixButton)this.LoginViewTop.FindControl("LinkButtonToggleModeTop")).Text = "Edit";
}
}
public void OnQuestionaireCategoryChangedEvent(object sender, EventArgs e)
{
this.ShowQuestionaire(sender, e);
} private void ShowQuestionaire(object sender, EventArgs e)
{
this.MultiViewSupplierProfile.SetActiveView(this.ViewQuestionaire);
} public void Download(object sender, EventArgs e)
{
string orgFileName;
string serverFileName; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionStringFelix"].ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select OrgFilename, Filename from dbo.Felix_SupplierDocument where ObjectID = " + ((IButtonControl)sender).CommandArgument;
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
orgFileName = (string)reader["OrgFilename"];
serverFileName =
ConfigurationManager.AppSettings["UploadPath"]
+ reader["Filename"];
con.Close();
Response.ContentType = "APPLICATION/OCTET-STREAM";
System.String disHeader = "Attachment; Filename=\"" + orgFileName + "\"";
Response.AppendHeader("Content-Disposition", disHeader);
System.IO.FileInfo fileToDownload = new System.IO.FileInfo(serverFileName);
Response.Flush();
Response.WriteFile(fileToDownload.FullName);
} public void DropDownListDocumentCategories_OnDataBound(object sender, EventArgs e)
{
this.GridViewDocuments.DataBind();
}
}
不清楚的 也可以直接问同事 这么大一堆代码网上怎么解释哦。
runat="server"
ID="QuestionaireSupplierProfile"
TreeViewContainer="PanelPlaceHolderTree"
QuestionsContainer="PanelPlaceHolderQuestions"
ButtonsContainer="PanelPlaceHolderButtons"
OnQuestionaireCategoryChangedEvent="OnQuestionaireCategoryChangedEvent"
/>这个没有见过 应该是自己写的控件
其他的都没有什么了啊
很平常的代码啊就是少了注释了 不规范 我们以后开发要注意咯!!!
{
string orgFileName;
string serverFileName; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionStringFelix"].ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select OrgFilename, Filename from dbo.Felix_SupplierDocument where ObjectID = " + ((IButtonControl)sender).CommandArgument;
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
orgFileName = (string)reader["OrgFilename"];
serverFileName =
ConfigurationManager.AppSettings["UploadPath"]
+ reader["Filename"];
con.Close();
Response.ContentType = "APPLICATION/OCTET-STREAM";
System.String disHeader = "Attachment; Filename=\"" + orgFileName + "\"";
Response.AppendHeader("Content-Disposition", disHeader);
System.IO.FileInfo fileToDownload = new System.IO.FileInfo(serverFileName);
Response.Flush();
Response.WriteFile(fileToDownload.FullName);
}
就觉得你写这些代码的那位同事还需要好好提升面向对象设计能力和分析能力,不过楼主不要怕,静下心来,平时多看看一些大师的书,比如重构,敏捷开发,.net大局观,thin in java,多看看优秀的开源代码,比如NHibernate,Enterprise library。不到三个月你就可以超过你这位同事了,真的。所以你不要气馁和退却哦