//根据状态字段获取状态类型 public static string GetSCPStatusName(string scpStatus) { string name = ""; EnumData.SCPStatusEnum enumNotKnown; if (Enum.TryParse <EnumData.SCPStatusEnum>(scpStatus, out enumNotKnown)) { name = EnumData.GetEnumDesc(enumNotKnown); } return(name); }
//设置编辑按钮可用性 protected void gv_CargoList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //Label lblRowBinType = e.Row.FindControl("lblRowBinType") as Label; Label lblStatus = e.Row.FindControl("lblStatus") as Label; if (lblStatus != null) { if (lblStatus.Text == EnumData.GetEnumDesc(EnumData.SCDetailStatusEnum.Uncompleted))//只要有未完成的项,结束盘点的按钮就不可用 { btnFinish.Enabled = false; btnFinish.CssClass = "ButtonImageStyleEnableFalse"; btnFinish.OnClientClick = "alert('该盘点计划单还有未完成的盘点项,请先完成盘点项后再点击此[结束盘点]按钮!');";//使用js显示消息提示文字 } } } }
//设置编辑按钮可用性 protected void gv_CargoList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //Label lblRowBinType = e.Row.FindControl("lblRowBinType") as Label; Label lblSCPStatus = e.Row.FindControl("lblSCPStatus") as Label; LinkButton btnEdit = e.Row.FindControl("btnEdit") as LinkButton; LinkButton btnDel = e.Row.FindControl("btnDel") as LinkButton; if (lblSCPStatus != null && btnEdit != null && btnDel != null) { if (lblSCPStatus.Text != EnumData.GetEnumDesc(EnumData.SCPStatusEnum.Initial))//只有初始态才可编辑 { btnEdit.Enabled = false; btnEdit.OnClientClick = "alert('该盘点计划单不是初始状态,不能进行编辑!');";//使用js显示消息提示文字 } if (lblSCPStatus.Text == EnumData.GetEnumDesc(EnumData.SCPStatusEnum.Executing))//执行中的单据不可删除 { btnDel.Enabled = false; btnDel.OnClientClick = "alert('该盘点计划单正在执行中,不能删除!');";//使用js显示消息提示文字 } } } }
void LoadByCargo(string whCode, string whName, string cargoCode, string cargoName, string packageShareNo, string storePickType, string isProfitOrLoss, string packageName, string startDateStr, string endDateStr, string sortExpression, string sortDirectionStr) { DateTime startDate = DateTime.Parse(startDateStr); DateTime endDate = DateTime.Parse(endDateStr); DateTime startTime = new DateTime(startDate.Year, startDate.Month, startDate.Day, 0, 0, 0); DateTime endTime = new DateTime(endDate.Year, endDate.Month, endDate.Day, 23, 59, 59, 999); using (DAL.GoldEntities context = new DAL.GoldEntities()) { ReportViewer1.LocalReport.ReportPath = @"Reports\Report_StorePicAccountList.rdlc"; List <proc_WebSelectStorePickAccount_Result> queryResult = context.proc_WebSelectStorePickAccount(whCode, cargoCode, cargoName, storePickType, isProfitOrLoss, packageName, packageShareNo, startTime.ToString(), endTime.ToString()).ToList <proc_WebSelectStorePickAccount_Result>(); foreach (proc_WebSelectStorePickAccount_Result p in queryResult) { if (p.StorePickType == ((int)EnumData.PickOrStore.Pick).ToString()) { p.StorePickType = EnumData.GetEnumDesc(EnumData.PickOrStore.Pick); } else if (p.StorePickType == ((int)EnumData.PickOrStore.Store).ToString()) { p.StorePickType = EnumData.GetEnumDesc(EnumData.PickOrStore.Store); } } //string sortExpression = gv_CargoList.Attributes["sortExpression"]; SortDirection sortDirection = sortExpression == "ASC" ? SortDirection.Ascending : SortDirection.Descending; if (sortDirection == SortDirection.Ascending) { queryResult = queryResult.OrderBy(r => r.GetType().GetProperty(sortExpression).GetValue(r, null)).ToList(); } else { queryResult = queryResult.OrderByDescending(r => r.GetType().GetProperty(sortExpression).GetValue(r, null)).ToList(); } ReportDataSource rds = new ReportDataSource("DataSet_StorePickAccount", queryResult); ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(rds); /* * RP_CargoCode * RP_CargoName * RP_CargoModel * RP_CargoSpec * RP_CargoUnits * RP_DisplayPattern * RP_WHName * RP_StartDate * RP_EndDate * RP_TotalSumNumCurrent * RP_TotalFirstOriginalNum * RP_TotalSumNumAdd * RP_TotalSumDel */ ReportParameter RP_CargoCode = new ReportParameter("RP_CargoCode", cargoCode); ReportParameter RP_CargoName = new ReportParameter("RP_CargoName", cargoName); //ReportParameter RP_CargoModel = new ReportParameter("RP_CargoModel", modelName); //ReportParameter RP_CargoSpec = new ReportParameter("RP_CargoSpec", specName); //ReportParameter RP_CargoUnits = new ReportParameter("RP_CargoUnits", ""); //ReportParameter RP_DisplayPattern = new ReportParameter("RP_DisplayPattern", (displayPattern == "ByCargo" ? "按商品汇总" : "按仓库汇总")); ReportParameter RP_WHName = new ReportParameter("RP_WHName", whName); ReportParameter RP_WHCode = new ReportParameter("RP_WHCode", whCode); ReportParameter RP_StartDate = new ReportParameter("RP_StartDate", startDateStr); ReportParameter RP_EndDate = new ReportParameter("RP_EndDate", endDateStr); string storePickTypeName = ""; if (storePickType == ((int)EnumData.PickOrStore.Pick).ToString()) { storePickTypeName = EnumData.GetEnumDesc(EnumData.PickOrStore.Pick); } else if (storePickType == ((int)EnumData.PickOrStore.Store).ToString()) { storePickTypeName = EnumData.GetEnumDesc(EnumData.PickOrStore.Store); } ReportParameter RP_StorePickType = new ReportParameter("RP_StorePickType", storePickTypeName); ReportParameter RP_PackageShareNo = new ReportParameter("RP_PackageShareNo", packageShareNo); ReportParameter RP_IsProfitOrLoss = new ReportParameter("RP_IsProfitOrLoss", isProfitOrLoss); ReportParameter RP_PackageName = new ReportParameter("RP_PackageName", packageName); ReportParameterCollection rpList = new ReportParameterCollection(); rpList.Add(RP_CargoCode); rpList.Add(RP_CargoName); //rpList.Add(RP_CargoModel); //rpList.Add(RP_CargoSpec); //rpList.Add(RP_CargoUnits); //rpList.Add(RP_DisplayPattern); rpList.Add(RP_WHName); rpList.Add(RP_WHCode); rpList.Add(RP_StartDate); rpList.Add(RP_EndDate); rpList.Add(RP_StorePickType); rpList.Add(RP_PackageShareNo); rpList.Add(RP_IsProfitOrLoss); rpList.Add(RP_PackageName); ReportViewer1.LocalReport.SetParameters(rpList); ReportViewer1.DataBind(); } }
void GridViewBind() { try { string scpCode = ViewState["EditID"].ToString(); using (DAL.GoldEntities context = new DAL.GoldEntities()) { //查询基本信息 StockCountingPlan planModel = (from r in context.StockCountingPlan where r.SCPCode == scpCode select r).FirstOrDefault(); if (planModel != null) { lblSCPCodeShow.Text = planModel.SCPCode; lblWHName.Text = planModel.WHName; EnumData.SCPStatusEnum status = (EnumData.SCPStatusEnum)Enum.Parse(typeof(EnumData.SCPStatusEnum), planModel.SCPStatus.Value.ToString()); lblStatusShow.Text = EnumData.GetEnumDesc(status); EnumData.SCPTypeEnum types = (EnumData.SCPTypeEnum)Enum.Parse(typeof(EnumData.SCPTypeEnum), planModel.SCPType.Value.ToString()); lblType.Text = EnumData.GetEnumDesc(types); lblCreateTime.Text = planModel.CreateDate.ToString(); if (lblStatusShow.Text == EnumData.GetEnumDesc(EnumData.SCDetailStatusEnum.Complete))//结束盘点的按钮不可用 { btnFinish.Enabled = false; btnFinish.CssClass = "ButtonImageStyleEnableFalse"; } } var queryResult = (from r in context.StockCountingDetail where r.SCPCode == scpCode select r).ToList(); foreach (var d in queryResult) { DateTime FinishTime = DateTime.Now; //如果盘点未结束则计算盘点开始至当前时间段内的出入数量 if (d.Status == (int)EnumData.SCDetailStatusEnum.Complete) //如果盘点已经结束则计算盘点开始和结束之间的出入数量 { FinishTime = d.CountingEndTime.Value; } //台账中ChangeType 1,3出,2,4入 //此层位此商品 盘点至今/结束的入库数量 double?sumIn = (from r in context.InventoryBook where r.WHCode == planModel.WHCode && r.CargoCode == d.CargoCode && r.BinCode == d.BinCode && (r.ChangeType == 2 || r.ChangeType == 4) && r.ChangeTime >= planModel.CreateDate && r.ChangeTime <= FinishTime select r.NumAdd).Sum(); //此层位此商品 盘点至今/结束的出库数量 double?sumOut = (from r in context.InventoryBook where r.WHCode == planModel.WHCode && r.CargoCode == d.CargoCode && r.BinCode == d.BinCode && (r.ChangeType == 1 || r.ChangeType == 3) && r.ChangeTime >= planModel.CreateDate && r.ChangeTime <= FinishTime select r.NumDel).Sum(); d.PeriodInNum = sumIn == null ? 0 : sumIn; d.PeriodOutNum = sumOut == null ? 0 : sumOut; if (d.NumActual != null) { d.NumDifference = d.NumActual - (d.NumPlan + d.PeriodInNum - d.PeriodOutNum); } } string sortExpression = gv_CargoList.Attributes["sortExpression"]; SortDirection sortDirection = gv_CargoList.Attributes["sortDirection"] == "ASC" ? SortDirection.Ascending : SortDirection.Descending; if (sortDirection == SortDirection.Ascending) { queryResult = queryResult.OrderBy(r => r.GetType().GetProperty(sortExpression).GetValue(r, null)).ToList(); } else { queryResult = queryResult.OrderByDescending(r => r.GetType().GetProperty(sortExpression).GetValue(r, null)).ToList(); } gv_CargoList.DataSource = queryResult; 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提示 } }