📄 deletesalechance.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using MisResource.Components;
using System.Data.SqlClient;
namespace MisResource.DesktopModules.SaleChance
{
/// <summary>
/// DeleteSaleChance 的摘要说明。
/// </summary>
public class DeleteSaleChance : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.DropDownList CustomerList;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.DropDownList ContactList;
protected System.Web.UI.WebControls.Label lblLReceiver;
protected System.Web.UI.WebControls.TextBox ProName;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.DropDownList ProTypeList;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.DropDownList EmployeeList;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.TextBox SignDate;
protected System.Web.UI.WebControls.Label lblAdditionalNo;
protected System.Web.UI.WebControls.TextBox SignSum;
protected System.Web.UI.WebControls.Label Label7;
protected System.Web.UI.WebControls.DropDownList StatusList;
protected System.Web.UI.WebControls.Label Label18;
protected System.Web.UI.WebControls.TextBox PubName;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.TextBox Remark;
protected System.Web.UI.WebControls.Button DeleteBtn;
protected System.Web.UI.WebControls.Button ReturnBtn;
private int nSaleChanceID = -1;
private void Page_Load(object sender, System.EventArgs e)
{
///判断用户是否登陆
if(Session["UserID"] == null)
{
Response.Redirect("~/Default.aspx");
}
///判断用户是否是超级管理员
if(Components.User.IsAuthorityAdmin(Session["UserID"].ToString()) >= Components.User.USERTYPENORMAL)
{
Response.Write("<script>alert(\"你没有权限,请与管理员联系!\")</script>");
Response.Write("<script>history.back();</script>");
}
if(Request.Params["SaleChanceID"] != null)
{
nSaleChanceID = Int32.Parse(Request.Params["SaleChanceID"].ToString());
}
if(!Page.IsPostBack)
{
///绑定控件的数据
BindEmployeeData();
BindCustomerData();
if(CustomerList.Items.Count > 0)
{
BindContactData(Int32.Parse(CustomerList.Items[0].Value));
}
if(nSaleChanceID > -1)
{
///显示销售机会的信息
BindSaleChanceData(nSaleChanceID);
}
}
///设置添加按钮的可用性
DeleteBtn.Enabled = (EmployeeList.Items.Count <= 0
|| ContactList.Items.Count <= 0
|| CustomerList.Items.Count <= 0
|| nSaleChanceID <= -1) ? false : true;
///添加删除确认对话框
DeleteBtn.Attributes.Add("onclick","return confirm('" + MisSystem.OPERATIONDELETEMESSAGE + "');");
}
private void BindCustomerData()
{
///定义获取数据的类
MisResource.Components.Customer customer = new MisResource.Components.Customer();
SqlDataReader recc = customer.GetCustomers();
///设定控件的数据源
CustomerList.DataSource = recc;
///设定控件的Text属性和Value属性
CustomerList.DataTextField = "DepartName";
CustomerList.DataValueField = "CustomerID";
///绑定控件的数据
CustomerList.DataBind();
///关闭数据读取器和数据库的连接
recc.Close();
}
private void BindContactData(int nCustomerID)
{
///定义获取数据的类
MisResource.Components.Contact contact = new MisResource.Components.Contact();
SqlDataReader recc = contact.GetContactByCustomer(nCustomerID);
///设定控件的数据源
ContactList.DataSource = recc;
///设定控件的Text属性和Value属性
ContactList.DataTextField = "Name";
ContactList.DataValueField = "ContactID";
///绑定控件的数据
ContactList.DataBind();
///关闭数据读取器和数据库的连接
recc.Close();
}
private void BindEmployeeData()
{
///定义获取数据的类
MisResource.Components.Employee employ = new Employee();
SqlDataReader rece = employ.GetEmployees();
///设定控件的数据源
EmployeeList.DataSource = rece;
///设定控件的Text属性和Value属性
EmployeeList.DataTextField = "EmployName";
EmployeeList.DataValueField = "EmployeeID";
///绑定控件的数据
EmployeeList.DataBind();
///关闭数据读取器和数据库的连接
rece.Close();
}
private void BindSaleChanceData(int nSaleChanceID)
{
///定义获取数据的类
MisResource.Components.SaleChance sale = new MisResource.Components.SaleChance();
SqlDataReader recs = sale.GetSingleSaleChance(nSaleChanceID);
///从获取的数据中读取数据
if(recs.Read())
{
ProName.Text = recs["ProName"].ToString();
SignDate.Text = recs["SignDate"].ToString();
SignSum.Text = recs["SignSum"].ToString();
PubName.Text = recs["PubName"].ToString();
Remark.Text = recs["Remark"].ToString();
///设置列表控件的数据
MisSystem.SetListBoxItem(CustomerList,recs["CustomerID"].ToString());
MisSystem.SetListBoxItem(ContactList,recs["ContactID"].ToString());
MisSystem.SetListBoxItem(ProTypeList,recs["ProType"].ToString());
MisSystem.SetListBoxItem(EmployeeList,recs["EmployeeID"].ToString());
MisSystem.SetListBoxItem(StatusList,recs["Status"].ToString());
}
///关闭数据读取器和数据库的连接
recs.Close();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.DeleteBtn.Click += new System.EventHandler(this.DeleteBtn_Click);
this.ReturnBtn.Click += new System.EventHandler(this.ReturnBtn_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void ReturnBtn_Click(object sender, System.EventArgs e)
{
///跳转到管理页面
Response.Redirect("~/DesktopModules/SaleChance/SaleChanceManage.aspx");
}
private void DeleteBtn_Click(object sender, System.EventArgs e)
{
///定义类
MisResource.Components.SaleChance sale = new MisResource.Components.SaleChance();
try
{
///删除操作
sale.DeleteSaleChance(nSaleChanceID);
///显示操作结果信息
Response.Write ("<script>window.alert('" + MisSystem.OPERATIONDELETESUCCESSMESSAGE + "')</script>");
}
catch(Exception ex)
{
///显示删除操作中的失败、错误信息
Response.Redirect("~/DesktopModules/ErrorPage.aspx?ErrorUrl="
+ MisSystem.RedirectErrorUrl(Request.RawUrl)
+ "&ErrorMessage=" + ex.Message.Replace("\n"," "));
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -