?? phone.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 _Default : System.Web.UI.Page
{
private static int vv = 0;
private static string strSelSql = "";
protected void Page_Load(object sender, EventArgs e)
{
////this.province.SelectedValue ="天津";
Session["user"] = "jx_xu";
//if (this.Request.Form["User"] != null)
//{
// Session["user"] = this.Request.Form["User"];
//}
//else if (Session["user"] == null)
//{
// Response.Write("<script>alert('非法登錄!');</script>");
// Response.Write("<script>window.open('../index.asp');</script>");
// return;
//}
if(strSelSql=="")
strSelSql = "SELECT Id, UserEName, UserCName, Office, OrderNum, UserKinds, DocAdmin, SysAdmin, CompanyId, SignName, MobilePhone, OnlyKey, ChangeDateTime, ChangeTimes, Duty, Post, PassWord, Disabled, TelePhone, (SELECT Company FROM Company WHERE (CompanyId = v_account.CompanyId)) AS Company FROM v_account WHERE (TelePhone <> '' and TelePhone is not null)";
SqlDataSource1.SelectCommand = strSelSql;
if (!this.IsPostBack)
{
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings.Get("den"));
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 = "全部機構";
SqlDataAdapter da1 = new SqlDataAdapter("SELECT * FROM PravinceCity where len(pcid)=2", conn);
DataSet ds1 = new DataSet();
da1.Fill(ds1);
this.province.DataSource = ds1;
this.province.DataTextField = "PCName";
this.province.DataValueField = "PCID";
this.province.DataBind();
this.province.Items.Insert(0, "--請選擇--");
foreach (ListItem li in province.Items)
{
if (li.Value.ToString() == "26")
{
li.Selected = true;
SqlDataAdapter daa = new SqlDataAdapter("SELECT PCName,PCID FROM PravinceCity WHERE PCID ='26'", conn);
DataSet dss = new DataSet();
daa.Fill(dss);
this.City.DataSource = dss;
this.City.DataTextField = "PCName";
this.City.DataValueField = "PCID";
this.City.DataBind();
//this.City.Items.Insert(0, "--請選擇--");
}
}
}
}
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;
Selbtn_Click(null, null);
}
protected void Selbtn_Click(object sender, EventArgs e)
{
string _ds = this.ddlSchool.SelectedValue;
string _dd = this.ddlDeperment.SelectedValue;
string _dp = this.ddlPerson.SelectedValue;
string _dpname = this.ddlPerson.SelectedItem.Text;
string _strds = _ds.Substring(0, 2);
strSelSql="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 TelePhone IS not null and TelePhone<>''";
//SqlDataSource1.SelectCommand = "SELECT cauc_oa.dbo.Account.Id, cauc_oa.dbo.Account.UserEName, cauc_oa.dbo.Account.UserCName, cauc_oa.dbo.Account.Office,cauc_oa.dbo.Account.OrderNum, cauc_oa.dbo.Account.UserKinds, cauc_oa.dbo.Account.DocAdmin, cauc_oa.dbo.Account.SysAdmin, cauc_oa.dbo.Account.CompanyId, cauc_oa.dbo.Account.SignName, cauc_oa.dbo.Account.MobilePhone, cauc_oa.dbo.Account.OnlyKey, cauc_oa.dbo.Account.ChangeDateTime, cauc_oa.dbo.Account.ChangeTimes, cauc_oa.dbo.Account.Duty, cauc_oa.dbo.Account.Post,cauc_oa.dbo.Account.PassWord, cauc_oa.dbo.Account.Disabled, cauc_oa.dbo.Account.TelePhone, cauc_oa.dbo.Company.Company FROM cauc_oa.dbo.Account CROSS JOIN cauc_oa.dbo.Company WHERE 1 = 1";
//GridView1.DataBind();
if (_ds != "--請選擇--")
{
if (_dd != "--請選擇--")
{
strSelSql += " and CompanyId = '" + _dd + "'";
this.Label5.Text = this.ddlSchool.SelectedItem.Text + "---" + this.ddlDeperment.SelectedItem.Text;
}
else
{
strSelSql += " and CompanyId Like '" + _strds + "____'";
this.Label5.Text = this.ddlSchool.SelectedItem.Text;
}
}
else
this.Label5.Text = "全部機構";
SqlDataSource1.SelectCommand = strSelSql;
GridView1.DataBind();
}
protected void Addbtn_Click(object sender, EventArgs e)
{
string _dsname = this.ddlSchool.SelectedItem.Text; ; //校機構選擇的字段
string _ddname = this.ddlDeperment.SelectedItem.Text; //本部門選擇的字段
string _dpname = this.ddlPerson.SelectedItem.Text; //聯系人選擇的字段
string _ddd = this.ddlDeperment.SelectedValue;
string phtxt = this.txtPhone.Text;
if (this.ddlSchool.SelectedItem.Text == "--請選擇--")
{
Response.Write("<script>alert(\"請選擇校機構!\")</script>");
this.ddlSchool.Focus();
}
else
{
if (this.ddlDeperment.SelectedItem.Text == "--請選擇--")
{
Response.Write("<script>alert(\"請選擇本部門!\")</script>");
this.ddlDeperment.Focus();
}
else
{
if (this.ddlPerson.SelectedItem.Text == "--請選擇--")
{
Response.Write("<script>alert(\"請選擇聯系人!\")</script>");
this.ddlPerson.Focus();
}
else
{
if (txtPhone.Text == "")
{
Response.Write("<script>alert(\"請輸入電話!\")</script>");
this.txtPhone.Focus();
}
else
{
//if (this.Page.IsValid == false)
//{
// Response.Write("<script>alert(\"'" + this.RegularExpressionValidator1.ErrorMessage + "'\")</script>");
//}
SqlDataSource1.UpdateCommand = "UPDATE v_account set TelePhone ='" + phtxt + "' where UserCName = '" + _dpname + "' and CompanyId = '" + _ddd + "'";
SqlDataSource1.Update();
}
}
}
}
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
string ss = GridView1.Rows[e.NewEditIndex].Cells[2].Text;//Session["school"] =
}
protected void Button2_Click(object sender, EventArgs e)
{
Button eee = (Button)sender;
DataControlFieldCell dv = (DataControlFieldCell)eee.Parent;
GridViewRow gvr = (GridViewRow)dv.Parent;
int index = gvr.RowIndex;
string userN = GridView1.Rows[index].Cells[2].Text;
string office = GridView1.Rows[index].Cells[3].Text;
string Phone = GridView1.Rows[index].Cells[4].Text;
Session["userN"] = userN;
Session["office"] = office;
Session["phone"] = Phone;
Response.Redirect("Add.aspx");
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Add.aspx");
}
protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header || e.Row.RowType == DataControlRowType.DataRow)
{
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -