📄 add.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;
namespace phone
{
public partial class Add : System.Web.UI.Page
{
string dds;
string ddd;
string ddp;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings.Get("dsn"));
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Company WHERE RIGHT(CompanyId,4)='0000' AND DISABLED=0 order by OrderNum", con);
DataSet ds = new DataSet();
da.Fill(ds);
this.ddlSchool.DataSource = ds;
this.ddlSchool.DataTextField = "Company";
this.ddlSchool.DataValueField = "CompanyID";
this.ddlSchool.DataBind();
this.ddlSchool.Items.Insert(0, "--请选择--");
this.ddlDeperment.Items.Insert(0, "--请选择--");
this.ddlPerson.Items.Insert(0, "--请选择--");
this.Label5.Text = "全部机构";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
dds = ddlSchool.SelectedItem.Text;
ddd = ddlDeperment.SelectedItem.Text;
ddp = ddlPerson.SelectedItem.Text;
string _dp = this.ddlPerson.SelectedValue;
string t = this.txtPhone.Text;
SqlDataSource2.UpdateCommand = "UPDATE v_account set TelePhone = '" + t + "' where UserCName = '" + ddp + "' and CompanyId = '" + _dp + "'";
SqlDataSource2.Update();
Response.Redirect("phone.aspx");
}
protected void ddlSchool_SelectedIndexChanged(object sender, EventArgs e)
{
string ddlS = this.ddlSchool.SelectedValue;
//string strcompany = ddlS.Substring(0, 2);
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings.Get("dsn"));
SqlDataAdapter daa = new SqlDataAdapter("SELECT * FROM Company WHERE LEFT(CompanyId,2)=LEFT('" + ddlS + "',2) and RIGHT(CompanyId,4)!='0000' AND DISABLED=0 ORDER BY OrderNum", conn);
DataSet dss = new DataSet();
daa.Fill(dss);
this.ddlDeperment.DataSource = dss;
this.ddlDeperment.DataTextField = "Company";
this.ddlDeperment.DataValueField = "CompanyID";
this.ddlDeperment.DataBind();
this.ddlDeperment.Items.Insert(0, "--请选择--");
this.ddlDeperment.SelectedIndex = 1;
string ddlp = this.ddlDeperment.SelectedValue;
//string strusercname = ddlp.Substring(0, 2);
SqlConnection conm = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings.Get("den"));
//SqlDataAdapter daP = new SqlDataAdapter("select UserCName,CompanyID from Account where CompanyID Like '" + strusercname + "____'", con);
//SqlDataAdapter daP = new SqlDataAdapter("SELECT *,Company=(SELECT Company FROM Company WHERE CompanyId=v_Account.CompanyId) FROM v_Account WHERE LEFT(CompanyId,4)=LEFT('" + ddlp + "',4)", conm);
SqlDataAdapter daP = new SqlDataAdapter("SELECT Id, UserEName, UserCName, Office, OrderNum, UserKinds, DocAdmin, SysAdmin, CompanyId, SignName, MobilePhone, OnlyKey, ChangeDateTime, ChangeTimes, Duty, Post, PassWord, Disabled, TelePhone,(SELECT Company FROM dbo.Company WHERE (CompanyId = v_account.CompanyId)) AS Company FROM v_account WHERE 1=1 and TelePhone IS null and CompanyId = '" + this.ddlDeperment.SelectedValue + "'", conm);
DataSet dse = new DataSet();
daP.Fill(dse);
this.ddlPerson.DataSource = dse;
this.ddlPerson.DataTextField = "UserCName";
this.ddlPerson.DataValueField = "CompanyId";
this.ddlPerson.DataBind();
this.ddlPerson.Items.Insert(0, "--请选择--");
//this.ddlPerson.SelectedIndex = 1;
if (this.ddlSchool.SelectedItem.Text == "--请选择--")
{
this.ddlDeperment.SelectedItem.Text = "--请选择--";
this.ddlPerson.SelectedItem.Text = "--请选择--";
}
}
protected void ddlPerson_SelectedIndexChanged(object sender, EventArgs e)
{
//SqlDataSource2.SelectCommand = "SELECT Id, UserEName, UserCName, Office, OrderNum, UserKinds, DocAdmin, SysAdmin, CompanyId, SignName, MobilePhone, OnlyKey, ChangeDateTime, ChangeTimes, Duty, Post, PassWord, Disabled, TelePhone,(SELECT Company FROM dbo.Company WHERE (CompanyId = v_account.CompanyId)) AS Company FROM v_account WHERE 1=1 and TelePhone IS null and UserCName = '" + ddp + "'";
//GridView1.DataBind();
}
protected void GridView1_DataBound(object sender, EventArgs e)
{
GridView1.Columns[0].Visible = false;
GridView1.Columns[1].Visible = false;
GridView1.Columns[4].Visible = false;
GridView1.Columns[6].Visible = false;
GridView1.ShowHeader = false;
}
protected void Button2_Click(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
Button eee = (Button)sender;
DataControlFieldCell dv = (DataControlFieldCell)eee.Parent;
GridViewRow gvr = (GridViewRow)dv.Parent;
int index = gvr.RowIndex;
string st = GridView1.Rows[index].Cells[2].Text;
string _st = GridView1.Rows[index].Cells[3].Text;
SqlDataSource2.DeleteCommand = "UPDATE v_account set TelePhone = '' where UserCName ='"+st+"'and Office = '"+_st+"'";
SqlDataSource2.Delete();
//string ss = GridView1.Rows[index].Cells[1].Text;
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -