1、错误提示
Page.StatusBar.WriteWarning("请扫入正确的主批号!");
2、给list赋值
if (N_CombineFromDetailGrid.Data != null && N_CombineFromDetailGrid.GridContext.SelectedRowIDs != null) { N_CombineFromDetailGrid.GridContext.SelectedRowIDs.ForEach(n => { list.Add((N_CombineFromDetailGrid.GridContext as ItemDataContext).GetItem(n) as N_CombineFromDetail); });
for (int i = 0; i < list.Count; i++)
{
list[i].CombineAllQty = false;
}
(serviceData as OM.N_Combine).N_CombineFromDetail = list.Select(n => new N_CombineFromDetail()
{
ListItemAction = ListItemAction.Add,
FromContainer = new ContainerRef(n.FromContainer == null ? null : n.FromContainer.Name),
CombineAllQty = n.CombineAllQty,
CloseWhenEmpty = n.CloseWhenEmpty,
Qty = (n.CombineAllQty.Value) ? null : n.Qty
}).ToArray();
}
3.提交前验证
public override FormsFramework.ValidationStatus ValidateInputData(Service serviceData)
{
ValidationStatus status = base.ValidateInputData(serviceData);
string strSql = string.Format(@"select sta.SJ_ApprovalStatusName from SJ_PN p
left join SJ_PNBase pb on pb.SJ_PNBaseId = p.SJ_PNbaseid
left join SJ_ApprovalStatus sta on sta.SJ_ApprovalStatusId = p.SJ_ApprovalStatusId
where pb.SJ_PNName = '{0}' and p.Revision = '{1}'", _Txt.Data, _RTxt.Data);
QueryService queryService = new QueryService(FrameworkManagerUtil.GetFrameworkSession().CurrentUserProfile);
QueryOptions options = new QueryOptions()
{
QueryType = WCF.ObjectStack.QueryType.User,
StartRow = 1,
//RowSetSize = 100
};
var recordSet = new RecordSet();
var queryResult = queryService.ExecuteAdHoc(strSql, options, out recordSet);
if (queryResult.IsSuccess && recordSet.Rows != null && recordSet.Rows.Length > 0)
{
if (recordSet.Rows[0].Values[0] == "已审批")
{
string validationMessage = "已审批的数据不可修改!";
ValidationStatusItem statusItem = new FormsFramework.ValidationStatusItem(null, null, validationMessage);
status.Add(statusItem);
}
}
return status;
}
public override FormsFramework.ValidationStatus ValidateInputData(Service serviceData)
{
ValidationStatus status = base.ValidateInputData(serviceData);
List<string> selectedIDs = N_CombineFromDetailGrid.GridContext.SelectedRowIDs;
if (selectedIDs == null || selectedIDs.Count < 1)
{
string validationLabel = ((GridDataSettingsItemList)(N_CombineFromDetailGrid.Settings)).IsRequiredLabelName;
string validationMessage = N_CombineFromDetailGrid.BoundContext.LBL(validationLabel, null);
ValidationStatusItem statusItem = new FormsFramework.ValidationStatusItem(null, null, validationMessage);
status.Add(statusItem);
}
return status;
}
4.给Table赋值
public virtual void SalesOrder_DataChanged(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(SalesOrder.TextControl.Text.Trim()))
{
return;
}
//GetLotInfo by sql.
DataSet queryDataSet = CustomQuery.GetLotInfoBySalesOrder(Page, SalesOrder.TextControl.Text.Trim());
if (queryDataSet != null)
{
var ListItems = new List<N_ReserveItem>();
foreach (DataRow item in queryDataSet.Tables[0].Rows)
{
ListItems.Add(new N_ReserveItem()
{
MfgOrder = new NamedObjectRef(item["MfgOrderName"].ToString()),
Container = new ContainerRef(item["ContainerName"].ToString()),
Qty = Convert.ToDouble(item["QTY"].ToString()),
N_Reserve1 = item["SpecName"].ToString(),
Product = new RevisionedObjectRef(item["ProductName"].ToString()),
N_Reserve2 = string.IsNullOrEmpty(item["Description"].ToString()) ? string.Empty : item["Description"].ToString(),
N_Reserve3 = item["OriginalQty"].ToString(),
N_Reserve4 = string.IsNullOrEmpty(item["PlannedStartDate"].ToString()) ? string.Empty : item["PlannedStartDate"].ToString()
} );
}
ServiceDetailsGrid.Data = ListItems.ToArray();
ServiceDetailsGrid.BoundContext.LoadData();
CamstarWebControl.SetRenderToClient(ServiceDetailsGrid);
}
}
catch (Exception ex)
{
Page.DisplayMessage(ex.Message, false);
}
}
5、判断某行字段是否为空并赋值
string ContainerName = string.Empty;
string Qty = string.Empty;
string comments = string.Empty;
string ReturnMsg = string.Empty;
string Cellstatus = string.Empty;
BoundContext bxContext = (ServiceDetailsGrid.GridContext as BoundContext);
//get selectedRows
//var selectdetails = ServiceDetailsGrid.GridContext.GetSelectedItems(false) as object[];
List<string> selectedRowIDs = ServiceDetailsGrid.GridContext.SelectedRowIDs;
//string SelectedRowid = string.Empty;
for (int i = 0; i < selectedRowIDs.Count; i++)
{
//SelectedRowid = ServiceDetailsGrid.GridContext.SelectedRowIDs.ToString();
if (!string.IsNullOrEmpty(bxContext.GetCell(ServiceDetailsGrid.BoundContext.MakeAutoRowId(int.Parse(selectedRowIDs[i])), "Container").ToString()))
{
ContainerName = bxContext.GetCell(ServiceDetailsGrid.BoundContext.MakeAutoRowId(int.Parse(selectedRowIDs[i])), "Container").ToString();
}
if (bxContext.GetCell(ServiceDetailsGrid.BoundContext.MakeAutoRowId(int.Parse(selectedRowIDs[i])), "Comments") !=null)
{
comments = bxContext.GetCell(ServiceDetailsGrid.BoundContext.MakeAutoRowId(int.Parse(selectedRowIDs[i])), "Comments").ToString();
}
if (bxContext.GetCell(ServiceDetailsGrid.BoundContext.MakeAutoRowId(int.Parse(selectedRowIDs[i])), "Status") != null)
{
Cellstatus = bxContext.GetCell(ServiceDetailsGrid.BoundContext.MakeAutoRowId(int.Parse(selectedRowIDs[i])), "Status").ToString();
}
bool Success = false;
if (Cellstatus != "True")
{
Success = ExecuteMove(ContainerName, comments, ref ReturnMsg);
if (Success)
{
sum = sum + 1;//列表内执行成功数统计
//Success = true;
FillMessage(selectedRowIDs[i], ReturnMsg, Success);
}
else
{
Success = false;
FillMessage(selectedRowIDs[i], ReturnMsg, Success);
}
}
}
6、提交及页面样式变化
protected bool ExecuteMove(string ContainerName, string comments, ref string ResponseMsg) { try { N_MoveInventoryService oService = new N_MoveInventoryService(FrameworkManagerUtil.GetFrameworkSession().CurrentUserProfile); N_MoveInventory oServiceData = new N_MoveInventory();
oServiceData.Container = new ContainerRef();
oServiceData.Container.Name = ContainerName;
oServiceData.N_WareHouse = Warehouse.TextControl.Text;
oServiceData.N_Location = Location.TextControl.Text;
oServiceData.Comments = comments;
ResultStatus rs = oService.ExecuteTransaction(oServiceData);
if (rs.IsSuccess)
{
ResponseMsg = rs.Message;
return true;
}
else
{
ResponseMsg = rs.ExceptionData.Description;
}
return false;
}
catch (Exception Ex)
{
ResponseMsg = Ex.Message;
return false;
}
}
private void FillMessage(string SelectedRowid, string Msg, bool Success)
{
(ServiceDetailsGrid.GridContext as BoundContext).SetCell(ServiceDetailsGrid.BoundContext.MakeAutoRowId(int.Parse(SelectedRowid)), "N_ResponseMsg", Msg);
if (Success)
(ServiceDetailsGrid.GridContext as BoundContext).SetCell(ServiceDetailsGrid.BoundContext.MakeAutoRowId(int.Parse(SelectedRowid)), "Status", "True");
else
(ServiceDetailsGrid.GridContext as BoundContext).SetCell(ServiceDetailsGrid.BoundContext.MakeAutoRowId(int.Parse(SelectedRowid)), "Status", "False");
LoadGridStyle();
CamstarWebControl.SetRenderToClient(ServiceDetailsGrid);
}
private void LoadGridStyle()
{
ServiceDetailsGrid.Settings.Layout.ConditionalRowStyles = new StyleRule[] {
new StyleRule(){ Condition="Status='True'",NormalStyle="Background-color:green",SelectedStyle="Background-color:green"},
new StyleRule(){ Condition="Status='False'",NormalStyle="Background-color:red",SelectedStyle="Background-color:red"}
};
}
7、表格中勾选提交