void GridViewBind() { try { /* * dt.Columns.Add("NewsID", typeof(string));//消息ID * dt.Columns.Add("NewsCreateDate", typeof(DateTime));//消息发布时间 * dt.Columns.Add("NewsTitle", typeof(string));//消息标题 * dt.Columns.Add("NewsContent", typeof(string));//消息内容 * dt.Columns.Add("EditorID", typeof(string));//消息发布人ID * dt.Columns.Add("EditorName", typeof(string));//消息发布人姓名 * */ //lblGridViewMsg.Text = ""; DataTable dt = ConvertDataTableXML.ReadSaleCargoNews(); if (dt != null && dt.Columns.Contains("NewsCreateDate")) { dt.DefaultView.Sort = "NewsCreateDate desc"; dt = dt.DefaultView.ToTable(); } gv_CargoList.PageSize = WebConfigHelper.Instance.GetDefaultPageSize(); gv_CargoList.DataSource = dt; gv_CargoList.DataBind(); } catch (Exception ex) { lblGridViewMsg.Text = "加载历史数据出现异常!" + Utility.LogHelper.GetExceptionMsg(ex); } finally { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), Guid.NewGuid().ToString(), "hiddenWaitDiv('divWait');", true);//js提示 } }
protected void btnSave_Click(object sender, EventArgs e) { lblGridViewMsg.Text = ""; try { if (tbxTitle.Text.Trim() == "" || tbxContent.Text.Trim() == "") { DAL.CommonConvert.ShowMessageBox(this.Page, "信息标题和内容不能为空!请填写!"); return; } DataTable dt = ConvertDataTableXML.ReadSaleCargoNews(); if (dt == null || dt.Rows.Count == 0) { dt = ConvertDataTableXML.GetSaleCargoNewsTableSchema(); } /* * dt.Columns.Add("NewsID", typeof(string));//消息ID * dt.Columns.Add("NewsCreateDate", typeof(DateTime));//消息发布时间 * dt.Columns.Add("NewsTitle", typeof(string));//消息标题 * dt.Columns.Add("NewsContent", typeof(string));//消息内容 * dt.Columns.Add("EditorID", typeof(string));//消息发布人ID * dt.Columns.Add("EditorName", typeof(string));//消息发布人姓名 * */ DataRow drNew = dt.NewRow(); drNew["NewsID"] = Guid.NewGuid().ToString(); drNew["NewsCreateDate"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string title = tbxTitle.Text; string content = tbxContent.Text; drNew["NewsTitle"] = tbxTitle.Text; drNew["NewsContent"] = Server.HtmlEncode(tbxContent.Text); if (Session["UserInfo"] != null) { Users userInfo = Session["UserInfo"] as Users; drNew["EditorID"] = userInfo == null ? "" : userInfo.UserId; } drNew["EditorName"] = tbxEditor.Text; dt.Rows.Add(drNew); bool ret = ConvertDataTableXML.SaveSaleCargoNewsToXml(dt); string msg = ret == true ? "保存成功!" : "保存失败!详细原因请查看系统日志!"; DAL.CommonConvert.ShowMessageBox(this.Page, msg); lblGridViewMsg.Text = msg; GridViewBind();//保存成功后重新绑定 } catch (Exception ex) { DAL.CommonConvert.ShowMessageBox(this.Page, "保存失败!"); lblGridViewMsg.Text = "保存失败![" + Utility.LogHelper.GetExceptionMsg(ex) + "]"; } }
private void ShowNews() { DataTable dt = ConvertDataTableXML.ReadSaleCargoNews(); if (dt != null && dt.Columns.Contains("NewsCreateDate") && dt.Rows.Count > 0) { dt.DefaultView.Sort = "NewsCreateDate desc"; dt = dt.DefaultView.ToTable(); /* * dt.Columns.Add("NewsID", typeof(string));//消息ID * dt.Columns.Add("NewsCreateDate", typeof(DateTime));//消息发布时间 * dt.Columns.Add("NewsTitle", typeof(string));//消息标题 * dt.Columns.Add("NewsContent", typeof(string));//消息内容 * dt.Columns.Add("EditorID", typeof(string));//消息发布人ID * dt.Columns.Add("EditorName", typeof(string));//消息发布人姓名 * */ string title = dt.Rows[0]["NewsTitle"].ToString(); string content = dt.Rows[0]["NewsContent"].ToString(); string datetime = dt.Rows[0]["NewsCreateDate"].ToString(); string editorName = dt.Rows[0]["EditorName"].ToString(); StringBuilder strNews = new StringBuilder("标题:"); strNews.Append(title); strNews.Append("<br /><br />内容:"); strNews.Append(Server.HtmlDecode(content).Replace("\r\n", "<br />")); strNews.Append("<br /><br />发布人:"); strNews.Append(editorName); strNews.Append("<br />发布时间:"); strNews.Append(datetime); divNews.InnerHtml = strNews.ToString(); //tbxNews.Text = strNews.ToString(); } else { //tbxNews.Text = "暂无信息!"; divNews.InnerText = "暂无信息!"; } }
/// <summary> /// 销售订单明细 /// </summary> /// <param name="dt">xml字符串转换成的DataTable</param> /// <param name="msg">信息提示</param> /// <returns>true成功,false失败</returns> public override bool GetNCDataDetail(out DataTable dt, out string msg, string billCode) { dt = null; msg = ""; try { //调用WebService的基础资料查询方法 NCWebServiceForRFID.IBillXMLExportService NCWSClient = new IBillXMLExportService(); string xmlOld = NCWSClient.BillDetailQuery(base.Warehouse, base.BillType, billCode); //按系统设置的编码格式进行xml数据解码 string xml = XmlHelper.GetStringByDefaultEncodingType(xmlOld); //记录日志 StringBuilder strLog = new StringBuilder("调用BillDetailQuery 参数:"); strLog.Append(base.BillType); strLog.Append(","); strLog.Append(base.Warehouse); strLog.Append(billCode); strLog.Append(" xml数据:"); strLog.Append(xml); LogHelper.WriteLog(LogHelper.LogLevel.Info, strLog.ToString()); //获取用友返回的xml字符串中的Total和Error字段信息 string NCTotal = "", NCError = ""; if (XmlHelper.GetXmlStringTotalAndErrorMsg(xml, out NCTotal, out NCError)) { if (NCTotal.Trim() == "0") { msg = "用友系统未能提供有效数据!用友系统返回信息:" + NCError; return(false); } } //将XML字符串中的数据转换成DataTable DataSet ds = ConvertDataTableXML.ConvertXmlStrToDataSet(xml); if (ds != null) { foreach (DataTable dtTemp in ds.Tables) { if (dtTemp.TableName == "Data") { dt = dtTemp; break; } } } return(true); } catch (Exception ex) { StringBuilder strLog = new StringBuilder("调用BillDetailQuery失败! 参数:"); strLog.Append(base.BillType); strLog.Append(","); strLog.Append(base.Warehouse); strLog.Append(base.StartTime); strLog.Append(base.EndTime); strLog.Append(" 异常信息:"); strLog.Append(LogHelper.GetExceptionMsg(ex)); msg = strLog.ToString(); LogHelper.WriteLog(LogHelper.LogLevel.Error, strLog.ToString(), ex); return(false); } }