protected void OnSubmit(object sender, EventArgs e) { ESMonitor.Model.Stats model = new ESMonitor.Model.Stats(); string stateCode = txtNo.Text.Trim(); model.Id = Convert.ToInt32(HiddenId.Value); model.StatName = txtName.Text.Trim(); model.StatCode = stateCode; model.Address = txtAddr.Text.Trim(); model.ChargeMan = txtChargeMan.Text.Trim(); model.Telepone = txtMobile.Text.Trim(); model.Department = txtDept.Text.Trim(); model.Country = ddlCountry.SelectedValue; model.Street = txtStreet.Text.Trim(); model.Square = decimal.Parse(txtSquare.Text.Trim()); model.Stage = int.Parse(ddlStage.SelectedValue); model.ProStartTime = Convert.ToDateTime(txtStartTime.Text); string[] location = txtLocation.Text.Trim().Split(';'); model.Longitude = decimal.Parse(location[0]); model.Latitude = decimal.Parse(location[1]); if (_bll.Update(model)) { Response.Redirect("Stats.aspx"); } else { ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"更新失败\");</script>"); } }
private void GetModel(HttpContext context) { int numOfRecords = 0; int statId = 0; if (context.Request.Params["sid"] != null) { statId = int.Parse(context.Request.Params["sid"]); } ESMonitor.Model.Stats model = _bll.GetModel(statId); if (model != null) { _json.AddItem("Id", model.Id.ToString()); _json.AddItem("Man", model.ChargeMan); _json.AddItem("Mobile", model.Telepone); _json.AddItem("Name", model.StatName); _json.AddItem("Addr", model.Address); _json.AddItem("Depart", model.Department); _json.AddItem("Square", model.Square.ToString(CultureInfo.InvariantCulture)); _json.AddItem("Country", Country.GetName(model.Country)); _json.AddItem("Stage", Stage.GetStage(model.Stage.ToString())); _json.AddItem("Long", model.Longitude.ToString(CultureInfo.InvariantCulture)); _json.AddItem("Lant", model.Latitude.ToString(CultureInfo.InvariantCulture)); _json.AddItem("StartTime", model.ProStartTime.ToString("yyyy-MM-dd")); _json.AddItem("Street", model.Street); _json.ItemOk(); numOfRecords++; } _json.success = true; _json.totalCount = numOfRecords; }
private void ShowInfo(int Id) { ESMonitor.BLL.Stats bll = new ESMonitor.BLL.Stats(); ESMonitor.Model.Stats model = bll.GetModel(Id); this.lblId.Text = model.Id.ToString(); this.lblStatCode.Text = model.StatCode; this.lblStatName.Text = model.StatName; this.lblChargeMan.Text = model.ChargeMan; this.lblTelepone.Text = model.Telepone; this.lblLongitude.Text = model.Longitude.ToString(); this.lblDepartment.Text = model.Department; this.lblAdress.Text = model.Adress; this.lblCountry.Text = model.Country; this.lblStreet.Text = model.Street; this.lblSquare.Text = model.Square.ToString(); this.lblProStartTime.Text = model.ProStartTime.ToString(); this.lblStage.Text = model.Stage.ToString(); }
private void GetStat(int statId) { ESMonitor.Model.Stats model = _bll.GetModel(statId); txtNo.Text = model.StatCode; txtName.Text = model.StatName; txtAddr.Text = model.Address; txtChargeMan.Text = model.ChargeMan; txtMobile.Text = model.Telepone; txtDept.Text = model.Department; foreach (ListItem item in ddlCountry.Items) { if (item.Value == model.Country) { item.Selected = true; break; } } txtStreet.Text = model.Street; txtSquare.Text = string.Format("{0:F}", model.Square); string stage = model.Stage.ToString(); foreach (ListItem item in ddlStage.Items) { if (item.Value == stage) { item.Selected = true; break; } } txtStartTime.Text = model.ProStartTime.ToString("yyyy-MM-dd"); txtLocation.Text = model.Longitude + ";" + model.Latitude; }
protected void OnSubmit() { ESMonitor.Model.Stats model = new ESMonitor.Model.Stats(); string stateCode = txtStatNo.Text.Trim(); if (!_bll.Exists(stateCode)) { model.StatName = txtStatName.Text.Trim(); model.StatCode = stateCode; model.Address = txtAddr.Text.Trim(); model.ChargeMan = txtChargeMan.Text.Trim(); model.Telepone = txtPhone.Text.Trim(); model.Department = txtDept.Text.Trim(); model.Country = ddlCountry.SelectedValue; model.Street = txtStreet.Text.Trim(); model.Square = decimal.Parse(txtSquare.Text.Trim()); model.Stage = int.Parse(ddlStage.SelectedValue); model.ProStartTime = Convert.ToDateTime(txtStartTime.Text); string[] location = txtLocation.Text.Trim().Split(';'); model.Longitude = decimal.Parse(location[0]); model.Latitude = decimal.Parse(location[1]); model.AlarmType = int.Parse(ddlAlarmType.SelectedValue); int ledCtrlId = _bll.Add(model); if (ledCtrlId > 0) { Response.Redirect("Stats.aspx"); } } else { const string tip = "已录入该记录"; ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"" + tip + "\");</script>"); } }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtStatCode.Text.Trim().Length == 0) { strErr += "StatCode不能为空!\\n"; } if (this.txtStatName.Text.Trim().Length == 0) { strErr += "StatName不能为空!\\n"; } if (this.txtChargeMan.Text.Trim().Length == 0) { strErr += "ChargeMan不能为空!\\n"; } if (this.txtTelepone.Text.Trim().Length == 0) { strErr += "Telepone不能为空!\\n"; } if (!PageValidate.IsDecimal(txtLongitude.Text)) { strErr += "Longitude格式错误!\\n"; } if (this.txtDepartment.Text.Trim().Length == 0) { strErr += "Department不能为空!\\n"; } if (this.txtAdress.Text.Trim().Length == 0) { strErr += "Adress不能为空!\\n"; } if (this.txtCountry.Text.Trim().Length == 0) { strErr += "Country不能为空!\\n"; } if (this.txtStreet.Text.Trim().Length == 0) { strErr += "Street不能为空!\\n"; } if (!PageValidate.IsDecimal(txtSquare.Text)) { strErr += "Square格式错误!\\n"; } if (!PageValidate.IsDateTime(txtProStartTime.Text)) { strErr += "ProStartTime格式错误!\\n"; } if (!PageValidate.IsNumber(txtStage.Text)) { strErr += "Stage格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int Id = int.Parse(this.lblId.Text); string StatCode = this.txtStatCode.Text; string StatName = this.txtStatName.Text; string ChargeMan = this.txtChargeMan.Text; string Telepone = this.txtTelepone.Text; decimal Longitude = decimal.Parse(this.txtLongitude.Text); string Department = this.txtDepartment.Text; string Adress = this.txtAdress.Text; string Country = this.txtCountry.Text; string Street = this.txtStreet.Text; decimal Square = decimal.Parse(this.txtSquare.Text); DateTime ProStartTime = DateTime.Parse(this.txtProStartTime.Text); int Stage = int.Parse(this.txtStage.Text); ESMonitor.Model.Stats model = new ESMonitor.Model.Stats(); model.Id = Id; model.StatCode = StatCode; model.StatName = StatName; model.ChargeMan = ChargeMan; model.Telepone = Telepone; model.Longitude = Longitude; model.Department = Department; model.Adress = Adress; model.Country = Country; model.Street = Street; model.Square = Square; model.ProStartTime = ProStartTime; model.Stage = Stage; ESMonitor.BLL.Stats bll = new ESMonitor.BLL.Stats(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }