📄 repairassignform.aspx.cs
字号:
//文件名:RepairAssignForm.aspx.cs
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 System.Data.SqlClient;
public partial class RepairManage_RepairAssignForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string MyForbidString = Session["MyForbid"].ToString();
if (MyForbidString.IndexOf("C2") > 1)
{
Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
}
}
protected void Button1_Click(object sender, EventArgs e)
{//新增派修信息
this.SqlDataSource3.Insert();
this.SqlDataSource2.DataBind();
this.GridView1.DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{//修改派修信息
this.SqlDataSource3.Update();
}
protected void Button4_Click(object sender, EventArgs e)
{//打印派修工单
Server.Transfer("~/RepairManage/RepairAssignPrint.aspx");
}
public String MyPrintID
{//设置要传递到打印页的数据
get
{
return this.TextBox2.Text;
}
}
public String MyPrintClient
{//设置要传递到打印页的数据
get
{
return this.DropDownList2.SelectedItem.Text.ToString();
}
}
public String MyPrintEmployee
{//设置要传递到打印页的数据
get
{
return this.DropDownList1.SelectedItem.Text.ToString();
}
}
public String MyPrintComment
{//设置要传递到打印页的数据
get
{
return this.TextBox18.Text ;
}
}
public String MyPrintDate
{//设置要传递到打印页的数据
get
{
return DateTime.Parse(this.TextBox9.Text).ToShortDateString();
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{//显示选择的维修登记信息
this.TextBox2.Text = this.GridView1.SelectedRow.Cells[1].Text.ToString();
this.TextBox3.Text = this.GridView1.SelectedRow.Cells[2].Text.ToString();
this.TextBox4.Text = this.GridView1.SelectedRow.Cells[3].Text.ToString();
this.TextBox5.Text = this.GridView1.SelectedRow.Cells[5].Text.ToString();
this.TextBox6.Text = this.GridView1.SelectedRow.Cells[6].Text.ToString();
this.TextBox7.Text = this.GridView1.SelectedRow.Cells[7].Text.ToString();
this.TextBox14.Text = this.GridView1.SelectedRow.Cells[14].Text.ToString();
this.TextBox15.Text = this.GridView1.SelectedRow.Cells[15].Text.ToString();
this.DropDownList4.SelectedValue = this.GridView1.SelectedRow.Cells[17].Text.ToString();
this.DropDownList2.SelectedValue =this.GridView1.SelectedRow.Cells[11].Text.ToString();
this.TextBox10.Text = this.GridView1.SelectedRow.Cells[12].Text.ToString();
}
protected void GridView2_RowCreated(object sender, GridViewRowEventArgs e)
{//弹出删除操作确认对话框
if (e.Row.RowType == DataControlRowType.DataRow)
{
Button MyButton = (Button)e.Row.FindControl("Button1");
MyButton.OnClientClick = "return confirm('是否确认删除当前选择的记录?')";
}
}
protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
{//在控件中显示选择的记录
this.TextBox1.Text = this.GridView2.SelectedRow.Cells[2].Text.ToString();
this.TextBox2.Text = this.GridView2.SelectedRow.Cells[3].Text.ToString();
this.DropDownList1.SelectedValue = this.GridView2.SelectedRow.Cells[4].Text.ToString();
this.TextBox9.Text = this.GridView2.SelectedRow.Cells[5].Text.ToString();
this.TextBox18.Text = this.GridView2.SelectedRow.Cells[6].Text.ToString();
String MyID = this.GridView2.SelectedRow.Cells[3].Text.ToString();
DataTable MyTable = new DataTable();
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyServiceDBConnectionString"].ConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
string MySQL = "SELECT * FROM [维修登记] WHERE ([维修编号]=" + MyID + ")";
MyConnection.Open();
SqlDataAdapter MyAdatper = new SqlDataAdapter(MySQL, MyConnection);
MyAdatper.Fill(MyTable);
this.TextBox3.Text = MyTable.Rows[0]["维修类别"].ToString();
this.TextBox4.Text = MyTable.Rows[0]["维修项目"].ToString();
this.TextBox5.Text = MyTable.Rows[0]["产品品牌"].ToString();
this.TextBox6.Text = MyTable.Rows[0]["产品型号"].ToString();
this.TextBox7.Text = MyTable.Rows[0]["机身号码"].ToString();
this.TextBox14.Text = MyTable.Rows[0]["故障情况"].ToString();
this.TextBox15.Text = MyTable.Rows[0]["附件信息"].ToString();
this.DropDownList4.SelectedValue = MyTable.Rows[0]["维修方式"].ToString();
this.DropDownList2.SelectedValue = MyTable.Rows[0]["客户名称"].ToString();
this.TextBox10.Text = MyTable.Rows[0]["客户电话"].ToString();
}
protected void GridView2_RowDeleted(object sender, GridViewDeletedEventArgs e)
{//重置数据
this.SqlDataSource2.DataBind();
this.GridView1.DataBind();
}
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{//在GridView控件单元格中设置短日期显示格式
if (e.Row.RowType == DataControlRowType.DataRow)
{
DateTime MyDate = DateTime.Parse(e.Row.Cells[5].Text);
e.Row.Cells[5].Text = MyDate.ToShortDateString();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -