protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { Maticsoft.Model.Operator oauser = (Maticsoft.Model.Operator)Session["user"]; if (oauser == null) { Response.Write(string.Format("<script>alert('登录超时!');window.top.location.href='login.aspx'</script>")); } else { Model.Staffmember st = sf.GetModel(Convert.ToInt32(oauser.StaffmemberID)); this.Label1.Text = st.Staffname; this.Label2.Text = Convert.ToString(System.DateTime.Now.ToString("yyyy 年 MM 月 dd 日")); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv1();</script>"); } } } catch (Exception) { Response.Write("<script>alert('页面异常')</script>"); } }
static string sql = ""; //主表查询条件 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Maticsoft.Model.Operator oauser = (Maticsoft.Model.Operator)Session["user"]; if (oauser == null) { Response.Write(string.Format("<script>alert('登录超时!');window.top.location.href='../login.aspx'</script>")); } else { if (oauser.name == "admin") { sql = ""; bind(sql); xialakuang1(); } else { DataSet dw = pt.GetList(" Operatorid like '" + oauser.id + "'"); if (dw.Tables[0].Rows[0]["Audit"].Equals(1)) { sql = ""; bind(sql); xialakuang1(); } else { xialakuang1(); } } } } }
static int zzspid = 0; //自制商品ID protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Label1.Text = "BM" + DateTime.Now.ToString("yyyyMMddHHmmss"); bind(); bind1(); Maticsoft.Model.Operator oauser = (Maticsoft.Model.Operator)Session["user"]; czy = oauser.id; } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.Operator model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Operator("); strSql.Append("name,pwd,BranchID,departmentID,StaffmemberID,JurisdictionID,Beizhu,BY1,BY2,BY3,BY4,BY5,BY6,BY7)"); strSql.Append(" values ("); strSql.Append("@name,@pwd,@BranchID,@departmentID,@StaffmemberID,@JurisdictionID,@Beizhu,@BY1,@BY2,@BY3,@BY4,@BY5,@BY6,@BY7)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@name", SqlDbType.VarChar, 100), new SqlParameter("@pwd", SqlDbType.VarChar, 100), new SqlParameter("@BranchID", SqlDbType.Int, 4), new SqlParameter("@departmentID", SqlDbType.Int, 4), new SqlParameter("@StaffmemberID", SqlDbType.Int, 4), new SqlParameter("@JurisdictionID", SqlDbType.Int, 4), new SqlParameter("@Beizhu", SqlDbType.VarChar, 4000), new SqlParameter("@BY1", SqlDbType.Decimal, 9), new SqlParameter("@BY2", SqlDbType.Decimal, 9), new SqlParameter("@BY3", SqlDbType.Decimal, 9), new SqlParameter("@BY4", SqlDbType.VarChar, 4000), new SqlParameter("@BY5", SqlDbType.VarChar, 4000), new SqlParameter("@BY6", SqlDbType.VarChar, 4000), new SqlParameter("@BY7", SqlDbType.VarChar, 4000) }; parameters[0].Value = model.name; parameters[1].Value = model.pwd; parameters[2].Value = model.BranchID; parameters[3].Value = model.departmentID; parameters[4].Value = model.StaffmemberID; parameters[5].Value = model.JurisdictionID; parameters[6].Value = model.Beizhu; parameters[7].Value = model.BY1; parameters[8].Value = model.BY2; parameters[9].Value = model.BY3; parameters[10].Value = model.BY4; parameters[11].Value = model.BY5; parameters[12].Value = model.BY6; parameters[13].Value = model.BY7; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 主表查询功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { sql = ""; if (TextBox3.Text.Trim() != "") { sql = sql + " OrderNumber like '%" + TextBox3.Text + "%' and "; } if (DropDownList1.Text != "0") { sql = sql + " Operator.StaffmemberID like '" + DropDownList1.Text + "' and "; } if (TextBox11.Text.Trim() != "") { sql = sql + " validity>='" + TextBox11.Text + "' and "; } if (TextBox12.Text.Trim() != "") { sql = sql + " validity<='" + TextBox12.Text + "' and "; } if (sql != "") { sql = " and " + sql; sql = sql.Substring(0, sql.Length - 5); } Maticsoft.Model.Operator oauser = (Maticsoft.Model.Operator)Session["user"]; if (oauser == null) { Response.Write(string.Format("<script>alert('登录超时!');window.top.location.href='../login.aspx'</script>")); } else { if (oauser.name == "admin") { bind(sql, quanxian); } else { DataSet dw = pt.GetList(" Operatorid like '" + oauser.id + "'"); if (dw.Tables[0].Rows[0]["look"].Equals(1)) { bind(sql, quanxian); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('你没有权限');</script>"); } } } }
public string entry(string name, string pwd) { string MM = FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "MD5"); Maticsoft.Model.Operator oauser = lBLL.GetModelS("name='" + name + "' and pwd='" + MM + "'"); if (oauser != null) { string qqq = @"{""data"":{""ds"":""1"",""userid"":""" + oauser.id + "\"}}"; return(qqq); } else { return(@"{""data"":{""ds"":""0""}}"); } }
/* * /// <summary> * /// 分页获取数据列表 * /// </summary> * public DataSet GetList(int PageSize,int PageIndex,string strWhere) * { * SqlParameter[] parameters = { * new SqlParameter("@tblName", SqlDbType.VarChar, 255), * new SqlParameter("@fldName", SqlDbType.VarChar, 255), * new SqlParameter("@PageSize", SqlDbType.Int), * new SqlParameter("@PageIndex", SqlDbType.Int), * new SqlParameter("@IsReCount", SqlDbType.Bit), * new SqlParameter("@OrderType", SqlDbType.Bit), * new SqlParameter("@strWhere", SqlDbType.VarChar,1000), * }; * parameters[0].Value = "Operator"; * parameters[1].Value = "id"; * parameters[2].Value = PageSize; * parameters[3].Value = PageIndex; * parameters[4].Value = 0; * parameters[5].Value = 0; * parameters[6].Value = strWhere; * return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds"); * }*/ public Maticsoft.Model.Operator GetModelS(string sre) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,name,pwd,BranchID,departmentID,StaffmemberID,JurisdictionID,Beizhu,BY1,BY2,BY3,BY4,BY5,BY6,BY7 from Operator "); strSql.Append(" where " + sre); SqlParameter[] parameters = { }; Maticsoft.Model.Operator model = new Maticsoft.Model.Operator(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
private void ShowInfo(int id) { Maticsoft.BLL.Operator bll = new Maticsoft.BLL.Operator(); Maticsoft.Model.Operator model = bll.GetModel(id); this.lblid.Text = model.id.ToString(); this.lblname.Text = model.name; this.lblpwd.Text = model.pwd; this.lblBranchID.Text = model.BranchID.ToString(); this.lbldepartmentID.Text = model.departmentID.ToString(); this.lblStaffmemberID.Text = model.StaffmemberID.ToString(); this.lblJurisdictionID.Text = model.JurisdictionID.ToString(); this.lblBeizhu.Text = model.Beizhu; this.lblBY1.Text = model.BY1.ToString(); this.lblBY2.Text = model.BY2.ToString(); this.lblBY3.Text = model.BY3.ToString(); this.lblBY4.Text = model.BY4; this.lblBY5.Text = model.BY5; this.lblBY6.Text = model.BY6; this.lblBY7.Text = model.BY7; }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { if (this.uname.Value.Trim() == "'or'='or'" || this.pwd.Value.Trim() == "'or'='or'") { Response.Write("<script>alert('别开玩笑行不行!')</script>"); } else { string MM = FormsAuthentication.HashPasswordForStoringInConfigFile(this.pwd.Value.Trim(), "MD5"); Maticsoft.Model.Operator oauser = lBLL.GetModelS("name='" + this.uname.Value.Trim() + "' and pwd='" + MM + "'"); if (oauser != null) { Session["user"] = oauser; Response.Redirect("~/index.aspx"); } else { Response.Write(string.Format("<script>alert('用户名或密码错误!');location='login.aspx'</script>")); } } }
/// <summary> /// 修改权限确定按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ImageButton3_Click(object sender, EventArgs e) { try { Maticsoft.Model.Operator oauser = (Maticsoft.Model.Operator)Session["user"]; if (oauser == null) { Response.Write(string.Format("<script>alert('登录超时!');window.top.location.href='../login.aspx'</script>")); } else { if (oauser.name == "admin") { DataSet da = pe.GetList(" Operatorid like '" + Label1.Text + "'"); Model.Permissionstab per = pe.GetModel(Convert.ToInt32(da.Tables[0].Rows[0]["id"])); per.Look = Convert.ToInt32(ListBox1.Text); per.Audit = Convert.ToInt32(ListBox2.Text); bool aa = pe.Update(per); if (aa == true) { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('修改成功!');</script>"); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('修改失败!');</script>"); } } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('没有权限修改!');</script>"); } } } catch (Exception ee) { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('确定异常 " + ee.Message + "');</script>"); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Operator DataRowToModel(DataRow row) { Maticsoft.Model.Operator model = new Maticsoft.Model.Operator(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["name"] != null) { model.name = row["name"].ToString(); } if (row["pwd"] != null) { model.pwd = row["pwd"].ToString(); } if (row["BranchID"] != null && row["BranchID"].ToString() != "") { model.BranchID = int.Parse(row["BranchID"].ToString()); } if (row["departmentID"] != null && row["departmentID"].ToString() != "") { model.departmentID = int.Parse(row["departmentID"].ToString()); } if (row["StaffmemberID"] != null && row["StaffmemberID"].ToString() != "") { model.StaffmemberID = int.Parse(row["StaffmemberID"].ToString()); } if (row["JurisdictionID"] != null && row["JurisdictionID"].ToString() != "") { model.JurisdictionID = int.Parse(row["JurisdictionID"].ToString()); } if (row["Beizhu"] != null) { model.Beizhu = row["Beizhu"].ToString(); } if (row["BY1"] != null && row["BY1"].ToString() != "") { model.BY1 = decimal.Parse(row["BY1"].ToString()); } if (row["BY2"] != null && row["BY2"].ToString() != "") { model.BY2 = decimal.Parse(row["BY2"].ToString()); } if (row["BY3"] != null && row["BY3"].ToString() != "") { model.BY3 = decimal.Parse(row["BY3"].ToString()); } if (row["BY4"] != null) { model.BY4 = row["BY4"].ToString(); } if (row["BY5"] != null) { model.BY5 = row["BY5"].ToString(); } if (row["BY6"] != null) { model.BY6 = row["BY6"].ToString(); } if (row["BY7"] != null) { model.BY7 = row["BY7"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.Operator model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Operator set "); strSql.Append("name=@name,"); strSql.Append("pwd=@pwd,"); strSql.Append("BranchID=@BranchID,"); strSql.Append("departmentID=@departmentID,"); strSql.Append("StaffmemberID=@StaffmemberID,"); strSql.Append("JurisdictionID=@JurisdictionID,"); strSql.Append("Beizhu=@Beizhu,"); strSql.Append("BY1=@BY1,"); strSql.Append("BY2=@BY2,"); strSql.Append("BY3=@BY3,"); strSql.Append("BY4=@BY4,"); strSql.Append("BY5=@BY5,"); strSql.Append("BY6=@BY6,"); strSql.Append("BY7=@BY7"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@name", SqlDbType.VarChar, 100), new SqlParameter("@pwd", SqlDbType.VarChar, 100), new SqlParameter("@BranchID", SqlDbType.Int, 4), new SqlParameter("@departmentID", SqlDbType.Int, 4), new SqlParameter("@StaffmemberID", SqlDbType.Int, 4), new SqlParameter("@JurisdictionID", SqlDbType.Int, 4), new SqlParameter("@Beizhu", SqlDbType.VarChar, 4000), new SqlParameter("@BY1", SqlDbType.Decimal, 9), new SqlParameter("@BY2", SqlDbType.Decimal, 9), new SqlParameter("@BY3", SqlDbType.Decimal, 9), new SqlParameter("@BY4", SqlDbType.VarChar, 4000), new SqlParameter("@BY5", SqlDbType.VarChar, 4000), new SqlParameter("@BY6", SqlDbType.VarChar, 4000), new SqlParameter("@BY7", SqlDbType.VarChar, 4000), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.name; parameters[1].Value = model.pwd; parameters[2].Value = model.BranchID; parameters[3].Value = model.departmentID; parameters[4].Value = model.StaffmemberID; parameters[5].Value = model.JurisdictionID; parameters[6].Value = model.Beizhu; parameters[7].Value = model.BY1; parameters[8].Value = model.BY2; parameters[9].Value = model.BY3; parameters[10].Value = model.BY4; parameters[11].Value = model.BY5; parameters[12].Value = model.BY6; parameters[13].Value = model.BY7; parameters[14].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 修改操作员(确定按钮) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ImageButton2_Click(object sender, EventArgs e) { try { if (TextBox4.Text.Trim() != "") { if (DropDownList2.Text != "0") { Maticsoft.Model.Operator czy = op.GetModel(Convert.ToInt32(Label2.Text)); czy.name = TextBox4.Text; czy.StaffmemberID = Convert.ToInt32(DropDownList2.Text); czy.Beizhu = TextBox5.Text; if (TextBox8.Text.Trim() != "" || TextBox9.Text.Trim() != "" || TextBox10.Text.Trim() != "") { Maticsoft.Model.Operator oauser = (Maticsoft.Model.Operator)Session["user"]; if (oauser == null) { Response.Write(string.Format("<script>alert('登录超时!');window.top.location.href='../login.aspx'</script>")); } else { if (oauser.name == "admin") { if (TextBox9.Text == TextBox10.Text) { czy.pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBox10.Text.Trim(), "MD5"); bool a = op.Update(czy); if (a == true) { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('修改成功!');</script>"); bind(sql); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('修改失败!');</script>"); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv2();</script>"); } } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('2次输入的密码不一致请重新输入!');</script>"); TextBox9.Text = ""; TextBox10.Text = ""; ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv2();</script>"); } } else { if (FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBox8.Text.Trim(), "MD5") == czy.pwd) { if (TextBox9.Text == TextBox10.Text) { czy.pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBox10.Text.Trim(), "MD5"); bool a = op.Update(czy); if (a == true) { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('修改成功!');</script>"); bind(sql); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('修改失败!');</script>"); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv2();</script>"); } } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('2次输入的密码不一致请重新输入!');</script>"); TextBox9.Text = ""; TextBox10.Text = ""; ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv2();</script>"); } } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('原密码输入有误!');</script>"); TextBox8.Text = ""; ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv2();</script>"); } } } } else { //bool a = op.Update(czy); //if (a == true) //{ // ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('修改成功!');</script>"); // bind(sql); //} //else //{ // ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('修改失败!');</script>"); // ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv2();</script>"); //} } } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('没选职员!');</script>"); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv2();</script>"); } } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('职务名称不能为空!');</script>"); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>javascript:showDiv2();</script>"); } } catch (Exception ee) { ClientScript.RegisterClientScriptBlock(this.GetType(), "this", "<script language=javascript>alert('确定异常 " + ee.Message + "');</script>"); } }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtname.Text.Trim().Length == 0) { strErr += "name不能为空!\\n"; } if (this.txtpwd.Text.Trim().Length == 0) { strErr += "pwd不能为空!\\n"; } if (!PageValidate.IsNumber(txtBranchID.Text)) { strErr += "BranchID格式错误!\\n"; } if (!PageValidate.IsNumber(txtdepartmentID.Text)) { strErr += "departmentID格式错误!\\n"; } if (!PageValidate.IsNumber(txtStaffmemberID.Text)) { strErr += "StaffmemberID格式错误!\\n"; } if (!PageValidate.IsNumber(txtJurisdictionID.Text)) { strErr += "JurisdictionID格式错误!\\n"; } if (this.txtBeizhu.Text.Trim().Length == 0) { strErr += "Beizhu不能为空!\\n"; } if (!PageValidate.IsDecimal(txtBY1.Text)) { strErr += "BY1格式错误!\\n"; } if (!PageValidate.IsDecimal(txtBY2.Text)) { strErr += "BY2格式错误!\\n"; } if (!PageValidate.IsDecimal(txtBY3.Text)) { strErr += "BY3格式错误!\\n"; } if (this.txtBY4.Text.Trim().Length == 0) { strErr += "BY4不能为空!\\n"; } if (this.txtBY5.Text.Trim().Length == 0) { strErr += "BY5不能为空!\\n"; } if (this.txtBY6.Text.Trim().Length == 0) { strErr += "BY6不能为空!\\n"; } if (this.txtBY7.Text.Trim().Length == 0) { strErr += "BY7不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string name = this.txtname.Text; string pwd = this.txtpwd.Text; int BranchID = int.Parse(this.txtBranchID.Text); int departmentID = int.Parse(this.txtdepartmentID.Text); int StaffmemberID = int.Parse(this.txtStaffmemberID.Text); int JurisdictionID = int.Parse(this.txtJurisdictionID.Text); string Beizhu = this.txtBeizhu.Text; decimal BY1 = decimal.Parse(this.txtBY1.Text); decimal BY2 = decimal.Parse(this.txtBY2.Text); decimal BY3 = decimal.Parse(this.txtBY3.Text); string BY4 = this.txtBY4.Text; string BY5 = this.txtBY5.Text; string BY6 = this.txtBY6.Text; string BY7 = this.txtBY7.Text; Maticsoft.Model.Operator model = new Maticsoft.Model.Operator(); model.name = name; model.pwd = pwd; model.BranchID = BranchID; model.departmentID = departmentID; model.StaffmemberID = StaffmemberID; model.JurisdictionID = JurisdictionID; model.Beizhu = Beizhu; model.BY1 = BY1; model.BY2 = BY2; model.BY3 = BY3; model.BY4 = BY4; model.BY5 = BY5; model.BY6 = BY6; model.BY7 = BY7; Maticsoft.BLL.Operator bll = new Maticsoft.BLL.Operator(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }