Camstar客制化开发查询数据库数据并显示在JQDataGrid表中(SQL语句编写在代码中)

设计vp界面

查询数据库显示数据

  1 using System;
  2 using System.Collections.Generic;
  3 using System.Linq;
  4 using System.Web;
  5 using Camstar.WebPortal.FormsFramework.WebGridControls;
  6 using CWC = Camstar.WebPortal.FormsFramework.WebControls;
  7 using OM = Camstar.WCF.ObjectStack;
  8 using Camstar.WCF.ObjectStack;
  9 using Camstar.WebPortal.FormsFramework.Utilities;
 10 using Camstar.WebPortal.Utilities;
 11 using Camstar.WebPortal.Personalization;
 12 using Camstar.WebPortal.FormsFramework;
 13 using Camstar.WebPortal.PortalFramework;
 14 using Camstar.WebPortal.FormsFramework.WebControls;
 15 
 16 /// <summary>
 17 /// TestRemove 的摘要说明
 18 /// </summary>
 19 namespace Camstar.WebPortal.WebPortlets.Shopfloor
 20 {
 21     public class TestRemove : MatrixWebPart
 22     {
 23         public TestRemove()
 24         {
 25             //
 26             // TODO: 在此处添加构造函数逻辑
 27             //
 28         }
 29         #region   捕获控件
 30         protected virtual ContainerListGrid _Container
 31         {
 32             get { return Page.FindCamstarControl("TestRemove_Container") as ContainerListGrid; }
 33         }
 34 
 35         protected virtual JQDataGrid _Testdetails
 36         {
 37             get
 38             {
 39                 return Page.FindCamstarControl("TestRemove_TestDetails") as JQDataGrid;
 40             }
 41         }
 42         protected virtual Button Submit_bt
 43         {
 44             get
 45             {
 46                 return Page.FindCamstarControl("Submit_bt") as Button;
 47             }
 48         }
 49         #endregion
 50 
 51         #region   Load
 52 
 53         protected override void OnLoad(EventArgs e)
 54         {
 55             base.OnLoad(e);
 56 
 57             Submit_bt.Click += _Container_DataChanged;//前提是设置vp界面属性AuToPostBack为True
 58         }
 59         
 60         #endregion
 61 
 62         #region   方法
 63 
 64         private void _Container_DataChanged(object sender, EventArgs e)
 65         {
 66             var Container = _Container.Data != null ? _Container.Data.ToString() : string.Empty;
 67             FrameworkSession session = FrameworkManagerUtil.GetFrameworkSession(HttpContext.Current.Session);
 68             var service = new Camstar.WCF.Services.QueryService(session.CurrentUserProfile);
 69             var QryOption = new WCF.ObjectStack.QueryOptions();
 70             var Result = new WCF.ObjectStack.RecordSet();
 71             ResultStatus success; 
 72             if(Container!=null){
 73                 string sql = @" select c.containername,pb.productname,p.productrevision,p.description,il.qtyrequired ,
 74                           il.actualqtyissued,il.actualqty2issued,il.issuecontrol from IssueActualsHistory ih
 75                          left join container c on c.containerid = ih.fromcontainerid
 76                          left join product p on p.productid = ih.productid
 77                          left join productbase pb on pb.productbaseid = p.productbaseid
 78                          left join issuehistorydetail il on il.issuehistorydetailid = ih.issuehistorydetailid
 79                          left join container tt on tt.containerid=ih.tocontainerid
 80                           where tt.containername='{0}'";
 81                 sql = string.Format(sql,Container);
 82                 success = service.ExecuteAdHoc(sql, new WCF.ObjectStack.QueryOptions(), out Result);
 83                 if (success.IsSuccess && Result.Rows != null && Result.Rows.Count() > 0)
 84                 {
 85                     List<TestDetails> list = new List<TestDetails>();
 86                     for (int i = 0; i < Result.Rows.Count(); i++)
 87                     {
 88                         TestDetails c = new TestDetails();
 89                         Row rr = Result.Rows[i];
 90                         c.Container = new ContainerRef(rr.Values[0].ToString());
 91                         c.Product = new RevisionedObjectRef(rr.Values[1].ToString(), rr.Values[2].ToString());
 92                         c.Description = rr.Values[3].ToString();
 93                         c.Qtyrequired = double.Parse(rr.Values[4].ToString());
 94                         c.ActualQtyIssued = double.Parse(rr.Values[5].ToString());
 95                         c.RemoveQty = double.Parse(rr.Values[6].ToString());
 96                         c.IssueReason = new NamedObjectRef(rr.Values[7].ToString());
 97                         list.Add(c);
 98                     }
 99                     _Testdetails.Data = list.ToArray();
100                 }
101             
102             }
103         }
104 
105         #endregion
106     }
107 }

 

站在巨人的肩膀上真的会看的更远更清晰!

                           -----用志不分,乃凝于神

 

posted @ 2018-11-07 16:43  幸运(● ̄(エ) ̄●)  阅读(575)  评论(0编辑  收藏  举报
Document