Camstar客制化开发查询数据库数据并显示在JQDataGrid表中(SQL语句编写在UserQuery中)同时获取JQDataGrid中值回传到Designer中
UserQuery中添加SQL语句
cs代码
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using Camstar.WebPortal.WebPortlets; 6 using Camstar.WebPortal.FormsFramework.WebControls; 7 using Camstar.WebPortal.FormsFramework.WebGridControls; 8 using Camstar.WebPortal.FormsFramework.Utilities; 9 using Camstar.WCF.Services; 10 using OM = Camstar.WCF.ObjectStack; 11 using Camstar.WCF.ObjectStack; 12 using System.Data; 13 using Camstar.WebPortal.Personalization; 14 15 namespace Camstar.WebPortal.WebPortlets.Shopfloor 16 { 17 /// <summary> 18 /// desLotComponentRemove 的摘要说明 19 /// </summary>Camstar.WebPortal.WebPortlets.Shopfloor.desLotComponentRemove 20 public class desLotComponentRemove : MatrixWebPart 21 { 22 public desLotComponentRemove() 23 { 24 // 25 // TODO: 在此处添加构造函数逻辑 26 // 27 } 28 29 30 31 #region 事件 32 protected override void OnLoad(EventArgs e) 33 { 34 base.OnLoad(e); 35 JQDataGrid containerGrid = ContainerGrid; 36 _Button_Clear.Click += _Button_ClearClick; 37 _Button_Remove.Click += _Button_Remove_Click; 38 if (Page.IsPostBack) 39 { 40 CurrentContainer.DataChanged += new EventHandler(CurrentContainer_DataChanged); 41 } 42 } 43 44 private void _Button_Remove_Click(object sender, EventArgs e) //Remove物料 45 { 46 // throw new NotImplementedException(); 47 FrameworkSession session = FrameworkManagerUtil.GetFrameworkSession(HttpContext.Current.Session); 48 var service = new Camstar.WCF.Services.desLotComponentRemoveService(session.CurrentUserProfile); 49 OM.desLotComponentRemove serviceData = new OM.desLotComponentRemove(); 50 serviceData.desNumberingRule = _desNumberingRule.Data as NamedObjectRef;//serviceData传值 51 serviceData.desRemovalReason = _RemovalReason.Data as NamedObjectRef; 52 serviceData.Container = CurrentContainer.Data as ContainerRef; 53 serviceData.desPrintQueue = _PrintQueue.Data as NamedObjectRef; 54 serviceData.desLableCount = 1; 55 serviceData.desPrinterLabelDefinition = desPrinterLabelDefinition.Data as RevisionedObjectRef; 56 desLotComponentRemove_Request request = new desLotComponentRemove_Request(); 57 desLotComponentRemove_Result result = new desLotComponentRemove_Result(); 58 List<desComponentRemoveList> list = new List<desComponentRemoveList>(); 59 JQDataGrid grid = ContainerGrid; 60 int j = grid.TotalRowCount; 61 for (int i = j - 1; i >= 0; i--) 62 { 63 desComponentRemoveList Item = (desComponentRemoveList)grid.GridContext.GetItem(i.ToString()); 64 desComponentRemoveList eiten = new desComponentRemoveList(); 65 66 if (Item.desStatus == true)//传入页面勾选的值(其中desStatus为在Designer中添加的Boolean[Boolean]类型的字段) 67 { 68 eiten.Product = Item.Product; 69 eiten.IssueQty = Item.IssueQty; 70 eiten.ProductDescription = Item.ProductDescription; 71 eiten.IssueFromContainer = Item.IssueFromContainer; 72 eiten.IssueControl = Item.IssueControl; 73 eiten.desRemoveLotQty = Item.desRemoveLotQty; 74 eiten.desStatus = Item.desStatus; 75 eiten.ActualQtyIssued = Item.ActualQtyIssued; 76 eiten.IssueActualsHistory = Item.IssueActualsHistory; 77 list.Add(eiten); 78 } 79 } 80 if (list.Count < 1) 81 { 82 Page.DisplayMessage("错误信息:未选择移除的物料!", false); 83 } 84 else 85 { 86 serviceData.desComponentRemoveList = list.ToArray(); 87 ResultStatus resultStatus = new ResultStatus(); 88 resultStatus = service.ExecuteTransaction(serviceData, request, out result); 89 90 if (resultStatus.IsSuccess) 91 { 92 Page.ClearValues(true); 93 Page.DisplayMessage("物料移除成功", true); 94 } 95 else 96 { 97 Page.ClearValues(false); 98 Page.DisplayMessage("物料移除失败:"+ resultStatus, false); 99 } 100 } 101 } 102 103 private void _Button_ClearClick(object sender, EventArgs e) 104 { 105 //throw new NotImplementedException(); 106 CurrentContainer.ClearData(); 107 ContainerGrid.ClearData(); 108 Page.ClearValues(); 109 } 110 #endregion 111 112 113 114 #region 方法 115 private void CurrentContainer_DataChanged(object sender, EventArgs e)//通过Container查询 116 { 117 //throw new NotImplementedException(); 118 var Container = CurrentContainer.Data != null ? CurrentContainer.Data.ToString() : string.Empty; 119 FrameworkSession fs = FrameworkManagerUtil.GetFrameworkSession(this.Page.Session); 120 QueryService queryService = new QueryService(fs.CurrentUserProfile); 121 122 QueryParameters queryParam = new QueryParameters(); 123 queryParam.Parameters = new QueryParameter[1]; 124 queryParam.Parameters[0] = new QueryParameter(); 125 queryParam.Parameters[0].Name = "containername"; 126 queryParam.Parameters[0].Value = Container; 127 QueryOptions queryOption = new QueryOptions(); 128 queryOption.QueryType = Camstar.WCF.ObjectStack.QueryType.User; 129 if (Container != null) 130 { 131 RecordSet record = new RecordSet(); 132 ResultStatus Result = queryService.Execute("desGetComponentRemoveDetail", queryParam, queryOption, out record); 133 134 if (Result.IsSuccess && record.TotalCount.ToString()!=null) 135 { 136 Page.ClearValues(true); 137 DataTable resultDt = record.GetAsDataTable(); 138 List<desComponentRemoveList> list = new List<desComponentRemoveList>(); 139 if (resultDt != null && resultDt.Rows != null && resultDt.Rows.Count > 0) 140 { 141 foreach (DataRow row in resultDt.Rows) 142 { 143 desComponentRemoveList c = new desComponentRemoveList(); 144 c.IssueActualsHistory = new SubentityRef(row[0].ToString()); 145 c.IssueFromContainer = new ContainerRef(row[1].ToString()); 146 c.Product = new RevisionedObjectRef(row[2].ToString(), row[3].ToString()); 147 c.ProductDescription = row[4].ToString(); 148 c.IssueQty = double.Parse(row[5].ToString()); 149 c.ActualQtyIssued = double.Parse(row[6].ToString()); 150 switch (row[7].ToString()) 151 { 152 case "1": c.IssueControl = IssueControlEnum.Serialized;break; 153 case "2": c.IssueControl = IssueControlEnum.Bulk; break; 154 case "3": c.IssueControl = IssueControlEnum.LotAndStockPoint; break; 155 case "4": c.IssueControl = IssueControlEnum.StockPointOnly; break; 156 case "5": c.IssueControl = IssueControlEnum.NoTracking; break; 157 case "6": c.IssueControl = IssueControlEnum.CommentOnly; break; 158 default : c.IssueControl = null; break; 159 160 } 161 162 c.desRemoveLotQty = double.Parse(row[6].ToString()); 163 164 list.Add(c); 165 } 166 ContainerGrid.Data = list.ToArray(); 167 } 168 else 169 { 170 Page.DisplayMessage("未查询到Contaienr:" + Container + "的相关信息。", false); 171 } 172 } 173 174 } 175 } 176 177 178 179 #endregion 180 181 182 #region 捕获控件 183 protected virtual ContainerListGrid CurrentContainer 184 { 185 get 186 { 187 return Page.FindCamstarControl("desLotComponentRemove_Container") as ContainerListGrid; 188 } 189 } 190 191 protected virtual JQDataGrid ContainerGrid 192 { 193 get 194 { 195 return Page.FindCamstarControl("desLotComponentRemove_desComponentRemoveList") as JQDataGrid; 196 } 197 } 198 protected virtual Button _Button_Clear 199 { 200 get 201 { 202 return Page.FindCamstarControl("Button_Clear") as Button; 203 } 204 } 205 protected virtual Button _Button_Remove 206 { 207 get 208 { 209 return Page.FindCamstarControl("Button_Remove") as Button; 210 } 211 } 212 protected virtual NamedObject _RemovalReason 213 { 214 get 215 { 216 return Page.FindCamstarControl("desLotComponentRemove_desRemovalReason") as NamedObject; 217 } 218 } 219 protected virtual NamedObject _desNumberingRule 220 { 221 get 222 { 223 return Page.FindCamstarControl("desLotComponentRemove_desNumberingRule") as NamedObject; 224 } 225 } 226 227 protected virtual TextBox desLableCount 228 { 229 get 230 { 231 return Page.FindCamstarControl("desLotComponentRemove_desLableCount") as TextBox; 232 } 233 } 234 235 236 protected virtual NamedObject _PrintQueue 237 { 238 get 239 { 240 return Page.FindCamstarControl("desLotComponentRemove_desPrintQueue") as NamedObject; 241 } 242 } 243 244 protected virtual Camstar.WebPortal.FormsFramework.WebControls.RevisionedObject desPrinterLabelDefinition 245 { 246 get 247 { 248 return Page.FindCamstarControl("desLotComponentRemove_desPrinterLabelDefinition") as Camstar.WebPortal.FormsFramework.WebControls.RevisionedObject; 249 } 250 } 251 #endregion 252 253 } 254 }
站在巨人的肩膀上真的会看的更远更清晰!
-----用志不分,乃凝于神