private void LoadDefault() { var idStr = Request["id"]; if (string.IsNullOrEmpty(idStr)) { return; } if (int.TryParse(Request["id"], out id)) { Row = tbl_sp_api_urlItem.GetRowById(dBase, id); } if (Row == null) { form1.Controls.Clear(); form1.InnerHtml = "<h1>ID无效!</h1>"; return; } if (IsPostBack) { return; } txtvirtual_page.Text = Row.virtual_page; chkphy_file.Checked = Row.phy_file; txtMoCheck.Text = Row.MoCheck; txtMoLink.Text = Row.MoLink; txtMrLink.Text = Row.MrLink; DataToChkbox(Row.MoToMr); DataToTextBox(true, Row.MrFidldMap); DataToTextBox(false, Row.MoFieldMap); //txtMoFieldMap_IMSI.Text = Row.MoFieldMap; //txtMrFidldMap.Text = Row.MrFidldMap; // txtMoStatus.Text = Row.MoStatus; txtMrStatus.Text = Row.MrStatus; txtMsgOutput.Text = Row.MsgOutput; txtMr_price.Text = Row.MrPrice; txtMo_price.Text = Row.MoPrice; txtName.Text = Row.name; txtsp_server_ips.Text = Row.sp_server_ips; this.chkDisable.Checked = Row.Disable; }
private string SaveData() { bool isNew = Row == null; if (isNew) { Row = new tbl_sp_api_urlItem(); Row.sp_id = int.Parse(ddlSp_id.SelectedValue); } Row.virtual_page = txtvirtual_page.Text; Row.phy_file = chkphy_file.Checked; Row.MoCheck = txtMoCheck.Text; Row.MoLink = txtMoLink.Text; Row.MrLink = txtMrLink.Text; Row.MoToMr = chkToData(); Row.MoFieldMap = GetMaps(false); Row.MrFidldMap = GetMaps(true); //Row.MoStatus = txtMoStatus.Text; Row.MrStatus = txtMrStatus.Text; Row.MsgOutput = txtMsgOutput.Text; Row.Disable = chkDisable.Checked; Row.name = txtName.Text; Row.MoPrice = txtMo_price.Text; Row.MrPrice = txtMr_price.Text; Row.sp_server_ips = txtsp_server_ips.Text.Trim(); if (!string.IsNullOrEmpty(Row.MoCheck)) { if (string.IsNullOrEmpty(Row.MoLink)) { return("MoLink不能为空"); } if (string.IsNullOrEmpty(Row.MoFieldMap)) { return("MoFieldMap不能为空"); } Row.MoFieldMap = Row.MoFieldMap.Replace(" ", string.Empty); if (string.IsNullOrEmpty(Row.MoToMr) && string.IsNullOrEmpty(Row.MrFidldMap)) { return("MoToMr 与 MrFidldMap 不能同时为空"); } if (!string.IsNullOrEmpty(Row.MoToMr)) { Row.MoToMr = Row.MoToMr.Replace(" ", string.Empty); } if (string.IsNullOrEmpty(Row.MrFidldMap)) { Row.MrFidldMap = Row.MrFidldMap.Replace(" ", string.Empty); } } else { if (string.IsNullOrEmpty(Row.MrFidldMap)) { return("MrFidldMap不能为空"); } Row.MrFidldMap = Row.MrFidldMap.Replace(" ", string.Empty); } if (Row.phy_file && NameExisted()) { return("virtual_page已经存在,不能重复"); } if (isNew || Row.phy_file) { Row.urlPath = string.Format("/sp/{0}.ashx", Row.virtual_page); } else { Row.urlPath = string.Format("/sp/{0}/{1}.ashx", Row.id, Row.virtual_page); } try { Row.SaveToDatabase(dBase); if (isNew && !Row.phy_file) { Row.urlPath = string.Format("/sp/{0}/{1}.ashx", Row.id, Row.virtual_page); } Row.SaveToDatabase(dBase); } catch (Exception ex) { return("保存出错\n" + ex.Message); } return(null); }