?? dispatchmodule.ascx.cs
字號(hào):
namespace KhfwWeb.Modules
{
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/// <summary>
/// DispatchModule 的摘要說(shuō)明。
/// </summary>
public class DispatchModule : ModuleBase
{
protected System.Web.UI.WebControls.Label CreateLabel;
protected System.Web.UI.WebControls.Label RecordIdLabel;
protected System.Web.UI.WebControls.Label NowTimeLabel;
protected System.Web.UI.WebControls.TextBox RDetailsTextBox;
protected System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
protected System.Web.UI.WebControls.Button Submit;
protected System.Web.UI.WebControls.HyperLink Return;
protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator3;
protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator4;
protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator5;
protected System.Web.UI.WebControls.Label ClientNameLabel;
protected System.Web.UI.WebControls.Label CNameLabel;
protected System.Web.UI.WebControls.Label PhoneLabel;
protected System.Web.UI.WebControls.TextBox OpinionTextbox;
protected System.Web.UI.WebControls.TextBox EngineerTextbox;
protected System.Web.UI.WebControls.TextBox DealWithDateTextbox;
protected System.Web.UI.WebControls.TextBox SubmitPersonTextbox;
protected System.Web.UI.WebControls.Label SubmitDateLabel;
protected System.Web.UI.WebControls.Label ShowMsg;
protected System.Web.UI.WebControls.Label TitleLabel;
protected string Type;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
//獲取DispatchManModule傳遞的Type參數(shù),Type=1表示記錄分配,Type=2表示重新分配
Type=Request.QueryString["Type"].ToString();
if(Type=="1")
{
TitleLabel.Text="問(wèn)題記錄分配";
Return.NavigateUrl=PathPrefix+"/ReDispatchMan.aspx?RStatus=1";
}
else if(Type=="2")
{
TitleLabel.Text="重新記錄分配";
Return.NavigateUrl=PathPrefix+"/ReDispatchMan.aspx?RStatus=2";
}
//顯示記錄序號(hào)信息
RecordIdLabel.Text=Request.QueryString ["RecordId"].ToString ();
//顯示提交時(shí)間
SubmitDateLabel.Text=DateTime.Now.ToString();
//從文件Web.config中讀取連接字符串
string sqldb= ConfigurationSettings.AppSettings["ConnectionString"];
//連接JdglSys數(shù)據(jù)庫(kù)
SqlConnection Conn = new SqlConnection (sqldb);
Conn.Open ();
//利用Command對(duì)象調(diào)用存儲(chǔ)過(guò)程
SqlCommand mycommand=new SqlCommand("sp_GetRecordById",Conn);
//將命令類型轉(zhuǎn)為存儲(chǔ)類型
mycommand.CommandType =CommandType.StoredProcedure ;
mycommand.Parameters .Add ("@RecordId",SqlDbType.Int);
mycommand.Parameters ["@RecordID"].Value = int.Parse(RecordIdLabel.Text);
SqlDataReader dr=mycommand.ExecuteReader ();
if(dr.Read ())
{
ClientNameLabel.Text=dr["ClientName"].ToString();
CNameLabel.Text=dr["CPerson"].ToString();
PhoneLabel.Text=dr["CTel"].ToString();
RDetailsTextBox.Text=dr["RDetails"].ToString();
NowTimeLabel.Text=dr["CreateDate"].ToString();
}
//關(guān)閉Conn
Conn.Close();
}
}
#region Web 窗體設(shè)計(jì)器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調(diào)用是 ASP.NET Web 窗體設(shè)計(jì)器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器
/// 修改此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.Submit.Click += new System.EventHandler(this.Submit_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Submit_Click(object sender, System.EventArgs e)
{
if(Page.IsValid )
{
//從文件Web.config中讀取連接字符串
string sqldb = ConfigurationSettings.AppSettings["ConnectionString"];
//連接JdglSys數(shù)據(jù)庫(kù)
SqlConnection Conn = new SqlConnection (sqldb);
Conn.Open ();
//利用Command對(duì)象調(diào)用updatesql
SqlCommand mycommand=new SqlCommand ("sp_InsertDispatch",Conn);
mycommand.CommandType=CommandType.StoredProcedure;
//添加參數(shù)
mycommand.Parameters .Add ("@RecordId",SqlDbType.Int);
mycommand.Parameters .Add ("@Opinion",SqlDbType.NVarChar);
mycommand.Parameters .Add ("@Engineer",SqlDbType.NVarChar);
mycommand.Parameters .Add ("@DwDate",SqlDbType.DateTime);
mycommand.Parameters .Add ("@SPerson",SqlDbType.NVarChar);
mycommand.Parameters .Add ("@SDate",SqlDbType.DateTime );
//給存儲(chǔ)過(guò)程的參數(shù)賦值
mycommand.Parameters ["@RecordId"].Value =RecordIdLabel.Text;
mycommand.Parameters ["@Opinion"].Value =OpinionTextbox.Text.Trim();
mycommand.Parameters ["@Engineer"].Value =EngineerTextbox.Text.Trim();
mycommand.Parameters ["@DwDate"].Value =DealWithDateTextbox.Text.Trim();
mycommand.Parameters ["@SPerson"].Value =SubmitPersonTextbox.Text.Trim();
mycommand.Parameters ["@SDate"].Value =SubmitDateLabel.Text.Trim();
try
{
mycommand.ExecuteNonQuery();
ShowMsg.Text="分配提交成功";
ShowMsg.Style["color"]="green";}
catch(SqlException error)
{
ShowMsg.Text="提交未成功,請(qǐng)稍后再試。原因:"+error.Message;
ShowMsg.Style["color"]="red";
}
//關(guān)閉連接
Conn.Close();
}
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -