/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.UnitsInfo DataRowToModel(DataRow row) { Maticsoft.Model.UnitsInfo model = new Maticsoft.Model.UnitsInfo(); if (row != null) { if (row["UnitID"] != null) { model.UnitID = row["UnitID"].ToString(); } if (row["UnitName"] != null) { model.UnitName = row["UnitName"].ToString(); } if (row["UnitCode"] != null) { model.UnitCode = row["UnitCode"].ToString(); } if (row["UnitPhone"] != null) { model.UnitPhone = row["UnitPhone"].ToString(); } if (row["Unitprovince"] != null) { model.Unitprovince = row["Unitprovince"].ToString(); } if (row["UnitCity"] != null) { model.UnitCity = row["UnitCity"].ToString(); } if (row["UnitAddress"] != null) { model.UnitAddress = row["UnitAddress"].ToString(); } if (row["UnitUserID"] != null) { model.UnitUserID = row["UnitUserID"].ToString(); } if (row["BBB1"] != null) { model.BBB1 = row["BBB1"].ToString(); } if (row["BBB2"] != null) { model.BBB2 = row["BBB2"].ToString(); } if (row["BBB3"] != null) { model.BBB3 = row["BBB3"].ToString(); } if (row["BBB4"] != null) { model.BBB4 = row["BBB4"].ToString(); } if (row["BBB5"] != null) { model.BBB5 = row["BBB5"].ToString(); } } return(model); }
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.CommandName == "sholi")//点击受理 { DeclarationModel = DeclarationBLL.GetModel(e.CommandArgument.ToString()); if (DeclarationModel.DoorServer == "是") { DeclarationModel.DeclarationState = "待上门"; } else { DeclarationModel.DeclarationState = "装备中心已受理"; } UnitsInfoModel = UnitsInfoBLL.GetModelyyy(DeclarationModel.UnitName); string aa = DeclarationModel.RepairTime.Value.ToString("yyyy-MM-dd"); //定义一个变量为aa,存储为年月日 int a = DeclarationBLL.GetRecordCount("Acceptancetime >= '" + aa + "' and Acceptancetime >= '" + aa + "' and DeclarationState= '装备中心已受理' or DeclarationState= '待上门' ") + 1; string b = ""; //定义一个变量b switch (Convert.ToString(a).Length) //判断变量a的长度 { case 1: b = "00" + a.ToString(); break; //为1 单号加00 case 2: b = "0" + a.ToString(); break; //为2 单号加0 case 3: b = a.ToString(); break; //为3 不变化 } DeclarationModel.ListID = DateTime.Now.ToString("yyyyMMdd") + UnitsInfoModel.UnitCode + b; //添加单号 DeclarationModel.Acceptancetime = DateTime.Now; DeclarationBLL.Update(DeclarationModel); //更新数据 RadGrid1.Rebind(); //刷新 } if (e.CommandName == "fenpei") //点击分配 { Response.Redirect("RepairAcceptanceZB.aspx?id=" + e.CommandArgument.ToString()); //跳转页面并传相对应的ID } if (e.CommandName == "wc") //点击完成 { Response.Redirect("MaintenanceListZB.aspx?id=" + e.CommandArgument.ToString()); } if (e.CommandName == "dy")//点击打印 { Response.Redirect("RepairReport.aspx?ID=" + e.CommandArgument + ""); } if (e.CommandName == "qh")//点击确认取回 { DeclarationModel = DeclarationBLL.GetModel(e.CommandArgument.ToString()); DeclarationModel.DeclarationState = "装备中心已取回"; DeclarationBLL.Update(DeclarationModel); //更新数据 RadGrid1.Rebind(); //刷新 } }
protected void Page_Load(object sender, EventArgs e) { //取值用label显示 if (!IsPostBack) //判断是否是第二次进入 { if (!string.IsNullOrEmpty(Request.QueryString["ID"])) //判断ID是否为空 { company_model = company_bll.GetModel(Request.QueryString["ID"]); //获取相对应ID的值 Label1.Text = company_model.UnitCode; Label2.Text = company_model.UnitName; Label3.Text = company_model.UnitPhone; Label4.Text = company_model.UnitUserID; Label5.Text = company_model.Unitprovince + company_model.UnitCity + company_model.UnitAddress; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!String.IsNullOrEmpty(UsersInfo.UserID)) { RadButton2.Attributes["onclick"] = "OpenAddPro();return false;"; //弹窗 Maticsoft.Model.UsersInfo UsersInfo_Model = UsersInfo_Bll.GetModel(UsersInfo.UserID); //引用id所在行的数据 imgPic.ImageUrl = UsersInfo_Model.HeadPortrait; //添加数据 Label9.Text = UsersInfo_Model.UserName; //添加数据 Label10.Text = UsersInfo_Model.UserRealName; //添加数据 Label11.Text = UsersInfo_Model.UserSex; //添加数据 Label12.Text = UsersInfo_Model.UserPhone; //添加数据 Label13.Text = Convert.ToDateTime(UsersInfo_Model.UserBirthday).ToString("yyyy-MM-dd");; //添加数据 Label16.Text = UsersInfo_Model.UserEmail; //添加数据 Label15.Text = UsersInfo_Model.UserProvince + UsersInfo_Model.UserCity + UsersInfo_Model.UserAddress; //添加数据 if (UsersInfo.UserRole == "报修单位用户") { UnitsInfo_Model = UnitsInfo_Bll.GetModel(UsersInfo_Model.UnitID); Label7.Text = UnitsInfo_Model.UnitName; XB.Visible = false; DH.Visible = false; CSRQ.Visible = false; JTZZ.Visible = false; YX.Visible = false; } if (UsersInfo.UserRole == "指导老师") { DW.Visible = false; } if (UsersInfo.UserRole == "系统管理员") { DW.Visible = false; } if (UsersInfo.UserRole == "装备中心管理员") { DW.Visible = false; } if (UsersInfo.UserRole == "维修中心管理员") { DW.Visible = false; } } } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.UnitsInfo GetModel(string UnitID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" UnitID,UnitName,UnitCode,UnitPhone,Unitprovince,UnitCity,UnitAddress,UnitUserID,BBB1,BBB2,BBB3,BBB4,BBB5 "); strSql.Append(" from UnitsInfo "); strSql.Append(" where UnitID='" + UnitID + "' "); Maticsoft.Model.UnitsInfo model = new Maticsoft.Model.UnitsInfo(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
protected void Page_Load(object sender, EventArgs e) { //将数据库内容传入输入框 if (!IsPostBack) //判断是否为第二次进入 { if (!String.IsNullOrEmpty(Request.QueryString["ID"])) //判断ID是否为空 { company_model = company_bll.GetModel(Request.QueryString["ID"].ToString()); //获取相对应ID的值 Label1.Text = company_model.UnitCode; name = TextBox1.Text = company_model.UnitName; TextBox2.Text = company_model.UnitPhone; TextBox3.Text = company_model.UnitUserID; DropDownList1Load(company_model.Unitprovince); DropDownList2.SelectedValue = company_model.UnitCity; TextBox4.Text = company_model.UnitAddress; DropDownList1.SelectedItem.Text = company_model.Unitprovince; DropDownList2.SelectedItem.Text = company_model.UnitCity; } } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.UnitsInfo model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.UnitID != null) { strSql1.Append("UnitID,"); strSql2.Append("'" + model.UnitID + "',"); } if (model.UnitName != null) { strSql1.Append("UnitName,"); strSql2.Append("'" + model.UnitName + "',"); } if (model.UnitCode != null) { strSql1.Append("UnitCode,"); strSql2.Append("'" + model.UnitCode + "',"); } if (model.UnitPhone != null) { strSql1.Append("UnitPhone,"); strSql2.Append("'" + model.UnitPhone + "',"); } if (model.Unitprovince != null) { strSql1.Append("Unitprovince,"); strSql2.Append("'" + model.Unitprovince + "',"); } if (model.UnitCity != null) { strSql1.Append("UnitCity,"); strSql2.Append("'" + model.UnitCity + "',"); } if (model.UnitAddress != null) { strSql1.Append("UnitAddress,"); strSql2.Append("'" + model.UnitAddress + "',"); } if (model.UnitUserID != null) { strSql1.Append("UnitUserID,"); strSql2.Append("'" + model.UnitUserID + "',"); } if (model.BBB1 != null) { strSql1.Append("BBB1,"); strSql2.Append("'" + model.BBB1 + "',"); } if (model.BBB2 != null) { strSql1.Append("BBB2,"); strSql2.Append("'" + model.BBB2 + "',"); } if (model.BBB3 != null) { strSql1.Append("BBB3,"); strSql2.Append("'" + model.BBB3 + "',"); } if (model.BBB4 != null) { strSql1.Append("BBB4,"); strSql2.Append("'" + model.BBB4 + "',"); } if (model.BBB5 != null) { strSql1.Append("BBB5,"); strSql2.Append("'" + model.BBB5 + "',"); } strSql.Append("insert into UnitsInfo("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); int rows = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.UnitsInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update UnitsInfo set "); if (model.UnitName != null) { strSql.Append("UnitName='" + model.UnitName + "',"); } else { strSql.Append("UnitName= null ,"); } if (model.UnitCode != null) { strSql.Append("UnitCode='" + model.UnitCode + "',"); } else { strSql.Append("UnitCode= null ,"); } if (model.UnitPhone != null) { strSql.Append("UnitPhone='" + model.UnitPhone + "',"); } else { strSql.Append("UnitPhone= null ,"); } if (model.Unitprovince != null) { strSql.Append("Unitprovince='" + model.Unitprovince + "',"); } else { strSql.Append("Unitprovince= null ,"); } if (model.UnitCity != null) { strSql.Append("UnitCity='" + model.UnitCity + "',"); } else { strSql.Append("UnitCity= null ,"); } if (model.UnitAddress != null) { strSql.Append("UnitAddress='" + model.UnitAddress + "',"); } else { strSql.Append("UnitAddress= null ,"); } if (model.UnitUserID != null) { strSql.Append("UnitUserID='" + model.UnitUserID + "',"); } else { strSql.Append("UnitUserID= null ,"); } if (model.BBB1 != null) { strSql.Append("BBB1='" + model.BBB1 + "',"); } else { strSql.Append("BBB1= null ,"); } if (model.BBB2 != null) { strSql.Append("BBB2='" + model.BBB2 + "',"); } else { strSql.Append("BBB2= null ,"); } if (model.BBB3 != null) { strSql.Append("BBB3='" + model.BBB3 + "',"); } else { strSql.Append("BBB3= null ,"); } if (model.BBB4 != null) { strSql.Append("BBB4='" + model.BBB4 + "',"); } else { strSql.Append("BBB4= null ,"); } if (model.BBB5 != null) { strSql.Append("BBB5='" + model.BBB5 + "',"); } else { strSql.Append("BBB5= null ,"); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where UnitID='" + model.UnitID + "' "); int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!String.IsNullOrEmpty(UsersInfo.UserID)) { UsersInfo_Model = UsersInfo_Bll.GetModel(UsersInfo.UserID); //引用id所在行的数据 imgPic.ImageUrl = UsersInfo_Model.HeadPortrait; //添加数据 Label1.Text = UsersInfo_Model.UserName; //添加数据 TextBox2.Text = UsersInfo_Model.UserRealName; //添加数据 TextBox3.Text = UsersInfo_Model.UserPhone; //添加数据 TextBox5.Text = UsersInfo_Model.UserEmail; //添加数据 RadDatePicker1.SelectedDate = Convert.ToDateTime(UsersInfo_Model.UserBirthday); //添加数据 TextBox4.Text = UsersInfo_Model.UserAddress; //添加数据 if (UsersInfo_Model.UserSex == "男") { RadioButton1.Checked = true; } else { RadioButton2.Checked = true; } //添加数据 DropDownList1.Items.Clear(); //清空省下拉框项目 DropDownList2.Items.Clear(); //清空市下拉框项目 DropDownList1.Items.Add(new ListItem("请选择", "")); //给省下拉框添加请选择 //RadDropDownList2.Items.Add(new DropDownListItem("请选择", ""));//给市下拉框添加请选择 DataSet ProvinceDS = new DataSet(); //声明数据库 ProvinceDS.ReadXml(Server.MapPath("~/pc.xml")); //读取pc文件 foreach (DataRow dr in ProvinceDS.Tables[0].Rows) //声明dr,数据库循环 { //逐条向dr添加,文本为dr的name列,值为dr的name列 DropDownList1.Items.Add(new ListItem(dr["name"].ToString(), dr["name"].ToString())); } DropDownList1.SelectedValue = UsersInfo_Model.UserProvince; XmlDataSource xds = new XmlDataSource(); //声明xml数据源 xds.DataFile = Server.MapPath("~/pc.xml"); //读取pc文件 xds.XPath = "//province[@name='" + DropDownList1.SelectedValue + "']/city"; //sql语句 this.DropDownList2.DataSource = xds; //绑定数据源 this.DropDownList2.DataTextField = "cname"; //设置文本字段 this.DropDownList2.DataValueField = "cname"; //设置值字段 this.DropDownList2.DataBind(); //绑定数据源 DropDownList2.Items.Add(new ListItem("请选择", "")); //给市下拉框添加请选择 DropDownList2.SelectedValue = UsersInfo_Model.UserCity; if (UsersInfo.UserRole == "报修单位用户") { UnitsInfo_Model = UnitsInfo_Bll.GetModel(UsersInfo_Model.UnitID); Label7.Text = UnitsInfo_Model.UnitName; XB.Visible = false; LXDH.Visible = false; YX.Visible = false; CSRQ.Visible = false; JTZZ.Visible = false; XXDZ.Visible = false; } if (UsersInfo.UserRole == "指导老师") { DW.Visible = false; } if (UsersInfo.UserRole == "系统管理员") { DW.Visible = false; } if (UsersInfo.UserRole == "装备中心管理员") { DW.Visible = false; } if (UsersInfo.UserRole == "维修中心管理员") { DW.Visible = false; } if (Label7.Text == "") { Label7.Text = "暂无数据"; } } } }
protected void RadButton1_Click(object sender, EventArgs e) { //判断有无特殊字符,是否为空 string yh = "UnitName='" + TextBox1.Text + "'"; string search = TextBox1.Text; string xxdz = TextBox1.Text.Trim(); Regex pattern = new Regex("[%--`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、? ‘’ ']"); if ((pattern.IsMatch(xxdz) == true)) { RadAjaxManager1.Alert("请不要输入特殊字符!"); return; } DataSet ds = company_bll.GetList(yh); string search2 = TextBox2.Text; string xxdz2 = TextBox2.Text.Trim(); Regex pattern2 = new Regex("[%--`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、? ‘’ ' ]"); if ((pattern2.IsMatch(xxdz2) == true)) { RadAjaxManager1.Alert("请不要输入特殊字符!"); return; } string search3 = TextBox3.Text; string xxdz3 = TextBox3.Text.Trim(); Regex pattern3 = new Regex("[%--`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、? ‘’ ']"); if ((pattern2.IsMatch(xxdz3) == true)) { RadAjaxManager1.Alert("请不要输入特殊字符!"); return; } string search4 = TextBox4.Text; string xxdz4 = TextBox4.Text.Trim(); Regex pattern4 = new Regex("[%--`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、? ‘’']"); if ((pattern2.IsMatch(xxdz4) == true)) { RadAjaxManager1.Alert("请不要输入特殊字符!"); return; } string stt = TextBox2.Text;//判断联系方式是否正确 bool isNum1 = System.Text.RegularExpressions.Regex.IsMatch(stt, @"(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$"); if (isNum1) { } else { RadAjaxManager1.Alert("请输入正确的联系方式!"); return; } if (TextBox2.Text.Length != 11) { RadAjaxManager1.Alert("请输入正确的联系方式!"); return; } if (TextBox1.Text == "")//判断是否为空 { RadAjaxManager1.Alert("请输入单位名称!"); return; } else if (TextBox2.Text == "")//判断是否为空 { RadAjaxManager1.Alert("请输入联系方式!"); return; } else if (TextBox3.Text == "")//判断是否为空 { RadAjaxManager1.Alert("请输入单位负责人!"); return; } else if (TextBox4.Text == "")//判断是否为空 { RadAjaxManager1.Alert("请输入详细地址!"); return; } else if (DropDownList1.SelectedItem.Text == "请选择")//判断是否为空 { RadAjaxManager1.Alert("请输入省"); return; } else if (DropDownList2.SelectedItem.Text == "请选择")//判断是否为空 { RadAjaxManager1.Alert("请输入市"); return; } else if (company_bll.GetRecordCount(" UnitName ='" + TextBox1.Text + "' ") != 0 && TextBox1.Text != name)//判断单位名称是否重复 { RadAjaxManager1.Alert("单位名称不能重复添加!"); return; } else { //将输入框的内容传入数据库 company_model = company_bll.GetModel(Request.QueryString["ID"].ToString());//获取ID company_model.UnitName = TextBox1.Text; company_model.AddTime = DateTime.Now; company_model.UnitPhone = TextBox2.Text; company_model.UnitUserID = TextBox3.Text; company_model.Unitprovince = DropDownList1.SelectedItem.Text; company_model.UnitCity = DropDownList2.SelectedItem.Text; company_model.UnitAddress = TextBox4.Text; company_bll.Update(company_model);//更新数据 Response.Write("<script>alert('修改成功!');window.location.href='./Company.aspx'</script>"); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.UnitsInfo DataRowToModel(DataRow row) { Maticsoft.Model.UnitsInfo model = new Maticsoft.Model.UnitsInfo(); if (row != null) { if (row["UnitID"] != null) { model.UnitID = row["UnitID"].ToString(); } if (row["UnitName"] != null) { model.UnitName = row["UnitName"].ToString(); } if (row["UnitCode"] != null) { model.UnitCode = row["UnitCode"].ToString(); } if (row["UnitPhone"] != null) { model.UnitPhone = row["UnitPhone"].ToString(); } if (row["Unitprovince"] != null) { model.Unitprovince = row["Unitprovince"].ToString(); } if (row["UnitCity"] != null) { model.UnitCity = row["UnitCity"].ToString(); } if (row["UnitAddress"] != null) { model.UnitAddress = row["UnitAddress"].ToString(); } if (row["UnitUserID"] != null) { model.UnitUserID = row["UnitUserID"].ToString(); } //if (row["AddTime"] != null) //{ // model.AddTime = row["AddTime"].ToString(); //} if (row["AddTime"] != null && row["AddTime"].ToString() != "") { model.AddTime = DateTime.Parse(row["AddTime"].ToString()); } if (row["BBB2"] != null) { model.BBB2 = row["BBB2"].ToString(); } if (row["BBB3"] != null) { model.BBB3 = row["BBB3"].ToString(); } if (row["BBB4"] != null) { model.BBB4 = row["BBB4"].ToString(); } if (row["BBB5"] != null) { model.BBB5 = row["BBB5"].ToString(); } } return(model); }