Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            var    planType  = this.rblPlanType.SelectedValue;
            string searchSql = " select top 50 ReleaseNo,Convert(varchar(10),CreateDate,121) as CreateDate1 from mrp_shipplanmstr order by createdate desc";
            if (planType == "ShipPlan")
            {
                searchSql = " select top 50 ReleaseNo,Convert(varchar(10),CreateDate,121) as CreateDate1 from mrp_shipplanmstr order by createdate desc ";
            }
            else if (planType == "ProductionPlan")
            {
                searchSql = " select top 50 ReleaseNo,Convert(varchar(10),CreateDate,121) as CreateDate1 from mrp_productionplanmstr order by createdate desc ";
            }
            else if (planType == "PurchasePlan")
            {
                searchSql = " select top 50 ReleaseNo,Convert(varchar(10),CreateDate,121) as CreateDate1 from mrp_purchaseplanmstr order by createdate desc ";
            }
            else if (planType == "PurchasePlan2")
            {
                searchSql = " select top 50 ReleaseNo,Convert(varchar(10),CreateDate,121) as CreateDate1 from mrp_purchaseplanmstr2 order by createdate desc ";
            }

            var versions = TheGenericMgr.GetDatasetBySql(searchSql).Tables[0];
            foreach (System.Data.DataRow row in versions.Rows)
            {
                this.versionSelect1.Items.Add(new ListItem(row[0].ToString() + "[" + row[1].ToString() + "]", row[0].ToString()));
                this.versionSelect2.Items.Add(new ListItem(row[0].ToString() + "[" + row[1].ToString() + "]", row[0].ToString()));
            }
        }
    }
Exemplo n.º 2
0
    public override void UpdateView()
    {
        //this.GV_List.Execute();
        com.Sconit.Control.GridPager pager = this.gp;
        pager.CurrentPageIndex = CurrentPageIndex;
        string resultSql = "select * from ( select *,RowId=row_number()over(order by " + CurrentSortParam + " asc) from (  " + StaticSql + ") as T1 ) as T2 where RowId between " + (pager.CurrentPageIndex - 1) * pager.PageSize + " and " + pager.CurrentPageIndex * pager.PageSize + "";
        var    result    = TheGenericMgr.GetDatasetBySql(resultSql).Tables[0];
        var    counts    = TheGenericMgr.GetDatasetBySql("select count(*) from (" + StaticSql + ") as T1").Tables[0].Rows[0][0];
        var    list      = new List <LocationLotDetailView>();

        foreach (System.Data.DataRow row in result.Rows)
        {
            //i.Code,i.Desc1,i.Uom,loc.Code,loc.Name,l.Bin,l.LotNo,l.Qty
            list.Add(new LocationLotDetailView
            {
                Id       = int.Parse(row[0].ToString()),
                ItemCode = row[1].ToString(),
                ItemDesc = row[2].ToString(),
                Uom      = row[3].ToString(),
                LocCode  = row[4].ToString(),
                LocName  = row[5].ToString(),
                BinCode  = row[6].ToString(),
                LotNo    = row[7].ToString(),
                Qty      = Convert.ToDecimal(row[8].ToString()),
            });
        }

        list = list == null || list.Count == 0 ? new List <LocationLotDetailView>() : list;
        pager.RecordCount       = int.Parse(counts.ToString());
        this.GV_List.DataSource = list;
        this.GV_List.DataBind();
    }
Exemplo n.º 3
0
 protected void btnUpload_Click(object sender, EventArgs e)
 {
     try
     {
         this.btQtyHidden.Value = string.Empty;
         this.btSeqHidden.Value = string.Empty;
         if (this.rbType.SelectedValue == BusinessConstants.CODE_MASTER_TIME_PERIOD_TYPE_VALUE_DAY)
         {
             var productionPlanMstr = TheGenericMgr.FindAllWithCustomQuery <ProductionPlanMstr>(" select s from ProductionPlanMstr as s where s.ReleaseNo=? ", currentRelesNo).First();
             if (productionPlanMstr.Status == BusinessConstants.CODE_MASTER_BINDING_TYPE_VALUE_SUBMIT)
             {
                 throw new BusinessErrorException("已释放的生产计划不能导入。");
             }
             TheMrpMgr.ReadProductionPlanFromXls(fileUpload.PostedFile.InputStream, this.CurrentUser, productionPlanMstr);
             ShowSuccessMessage("导入成功。");
             this.btnSearch_Click(null, null);
         }
         else
         {
             throw new BusinessErrorException("只能导入日计划。");
         }
     }
     catch (BusinessErrorException ex)
     {
         ShowErrorMessage(ex);
     }
 }
Exemplo n.º 4
0
    protected void lbtnShowErrorMsg_Click(object sender, EventArgs e)
    {
        string batchNo         = ((LinkButton)sender).CommandArgument;
        var    runShipPlanLogs = TheGenericMgr.FindAllWithCustomQuery <RunPurchasePlanLog2>("select r from RunPurchasePlanLog2 as r where r.BatchNo=?", batchNo);

        this.ucShowErrorMsg.Visible = true;
        this.ucShowErrorMsg.InitPageParameter(runShipPlanLogs);
        //this.ucShowErrorMsg.
    }
Exemplo n.º 5
0
    public void GetView(string searchSql)
    {
        allList = new List <EDIFordPlan>();
        IList <EDIFordPlan> eDIFordPlanList = TheGenericMgr.FindAllWithCustomQuery <EDIFordPlan>(searchSql);

        if (eDIFordPlanList != null && eDIFordPlanList.Count > 0)
        {
            IList <FlowDetail> flowdets = TheGenericMgr.FindAllWithCustomQuery <FlowDetail>(string.Format(" select d from FlowDetail as d where  d.ReferenceItemCode in('{0}') ", string.Join("','", eDIFordPlanList.Select(w => w.RefItem).Distinct().ToArray())));

            control_num = eDIFordPlanList.First().Control_Num;
            var groups = (from tak in eDIFordPlanList
                          group tak by new
            {
                tak.Control_Num,
                tak.RefItem
            }
                          into result
                          select new
            {
                RefItem = result.Key.RefItem,
                Control_Num = result.Key.Control_Num,
                List = result.ToList()
            }).ToList();

            forecastDateList = groups.First().List.OrderBy(g => g.ForecastDate).Select(g => g.ForecastDate).ToList();

            foreach (var g in groups)
            {
                EDIFordPlan newPlan = g.List.First();
                Dictionary <DateTime, decimal[]> planDateDic = new Dictionary <DateTime, decimal[]>();
                List <decimal[]> planQtyArr = new List <decimal[]>();
                foreach (var f in g.List)
                {
                    //forecastDateList.Add(f.ForecastDate);
                    decimal[] dicArr = new decimal[] { f.ForecastQty > 0?f.ForecastQty:0, f.ForecastCumQty > 0?f.ForecastCumQty:0 };
                    planQtyArr.Add(dicArr);
                }
                newPlan.PlanQtyArr = planQtyArr;
                if (flowdets != null && flowdets.Count > 0)
                {
                    var flowDet = flowdets.Where(f => f.ReferenceItemCode == newPlan.RefItem);
                    if (flowDet != null && flowDet.Count() > 0)
                    {
                        newPlan.Item     = flowDet.First().Item.Code;
                        newPlan.ItemDesc = flowDet.First().Item.Description;
                    }
                }
                allList.Add(newPlan);
            }
            totalItem = allList.Count;
        }
    }
Exemplo n.º 6
0
    protected void btnExport_Click(object sender, EventArgs e)
    {
        //flowDetail.PackagingCode = ((System.Web.UI.HtmlControls.HtmlSelect)this.FV_FlowDetail.FindControl("tbPackagingCode")).Value;
        string controlNums = this.btControl_Num.Value;

        if (!string.IsNullOrEmpty(controlNums))
        {
            string sql = string.Format(" select e from EDIFordPlan as e  where Control_Num in ('{0}') ", string.Join("','", controlNums.Split(',')));
            IList <EDIFordPlan> exportList = TheGenericMgr.FindAllWithCustomQuery <EDIFordPlan>(sql);
            if (exportList != null && exportList.Count > 0)
            {
                ExportExcel(exportList);
            }
        }
    }
Exemplo n.º 7
0
    public void GetView(string relesNo)
    {
        //this.tbFlow.Text = string.Empty;
        this.list.InnerHtml = "";
        currentRelesNo      = relesNo;
        var shipPlanMstr = TheGenericMgr.FindAllWithCustomQuery <ProductionPlanMstr>(" select s from ProductionPlanMstr as s where s.ReleaseNo=? ", currentRelesNo).First();

        if (shipPlanMstr.Status == BusinessConstants.CODE_MASTER_BINDING_TYPE_VALUE_SUBMIT)
        {
            this.importDiv.Visible = false;
        }
        else
        {
            this.importDiv.Visible = true;
        }
    }
Exemplo n.º 8
0
    protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.DataItem != null)
        {
            ProductionPlanMstr m      = (ProductionPlanMstr)e.Row.DataItem;
            var runProductionPlanLogs = TheGenericMgr.FindAllWithCustomQuery <RunProductionPlanLog>("select r from RunProductionPlanLog as r where r.BatchNo=?", m.BatchNo);
            if (runProductionPlanLogs == null || runProductionPlanLogs.Count == 0)
            {
                System.Web.UI.WebControls.LinkButton lbtnShowErrorMsg = e.Row.FindControl("lbtnShowErrorMsg") as System.Web.UI.WebControls.LinkButton;
                lbtnShowErrorMsg.Visible = false;
            }
            if (m.Status != BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE)
            {
                System.Web.UI.WebControls.LinkButton lbtSubmit = e.Row.FindControl("lbtSubmit") as System.Web.UI.WebControls.LinkButton;
                lbtSubmit.Visible = false;
            }
            if (m.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT)
            {
                string searchSql     = "select  max(releaseno) from MRP_ProductionPlanMstr where Status='Submit' ";
                var    maxReleaseNos = TheGenericMgr.GetDatasetBySql(searchSql).Tables[0];
                int    releaseNo     = 0;
                foreach (System.Data.DataRow row in maxReleaseNos.Rows)
                {
                    releaseNo = Convert.ToInt32(row[0]);
                }
                if (releaseNo == m.ReleaseNo)
                {
                }
                else
                {
                    System.Web.UI.WebControls.LinkButton lbtRunProdPlan = e.Row.FindControl("lbtRunProdPlan") as System.Web.UI.WebControls.LinkButton;
                    lbtRunProdPlan.Visible = false;

                    System.Web.UI.WebControls.LinkButton lbtRunProdPlan2 = e.Row.FindControl("lbtRunProdPlan2") as System.Web.UI.WebControls.LinkButton;
                    lbtRunProdPlan2.Visible = false;
                }
            }
            else
            {
                System.Web.UI.WebControls.LinkButton lbtRunProdPlan = e.Row.FindControl("lbtRunProdPlan") as System.Web.UI.WebControls.LinkButton;
                lbtRunProdPlan.Visible = false;

                System.Web.UI.WebControls.LinkButton lbtRunProdPlan2 = e.Row.FindControl("lbtRunProdPlan2") as System.Web.UI.WebControls.LinkButton;
                lbtRunProdPlan2.Visible = false;
            }
        }
    }
Exemplo n.º 9
0
 protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.DataItem != null)
     {
         PurchasePlanMstr2 m = (PurchasePlanMstr2)e.Row.DataItem;
         var runShipPlanLogs = TheGenericMgr.FindAllWithCustomQuery <RunPurchasePlanLog2>("select r from RunPurchasePlanLog2 as r where r.BatchNo=?", m.BatchNo);
         if (runShipPlanLogs == null || runShipPlanLogs.Count == 0)
         {
             System.Web.UI.WebControls.LinkButton lbtnShowErrorMsg = e.Row.FindControl("lbtnShowErrorMsg") as System.Web.UI.WebControls.LinkButton;
             lbtnShowErrorMsg.Visible = false;
         }
         if (m.Status != BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE)
         {
             System.Web.UI.WebControls.LinkButton lbtSubmit = e.Row.FindControl("lbtSubmit") as System.Web.UI.WebControls.LinkButton;
             lbtSubmit.Visible = false;
         }
     }
 }
Exemplo n.º 10
0
    public void GetView(string searchSql)
    {
        CurrenPage = 1;
        totalItem  = 0;
        allList    = new List <EDIFordPlan>();
        returnList = new List <EDIFordPlan>();
        IList <EDIFordPlan> eDIFordPlanList = TheGenericMgr.FindAllWithCustomQuery <EDIFordPlan>(searchSql);

        //IList<EDIFordPlan> getList = new List<EDIFordPlan>(); ;

        if (eDIFordPlanList != null && eDIFordPlanList.Count > 0)
        {
            string control_Num = string.Empty;
            var    groups      = (from tak in eDIFordPlanList
                                  group tak by new
            {
                tak.Control_Num,
            }
                                  into result
                                  select new
            {
                Control_Num = result.Key.Control_Num,
                List = result.ToList()
            }).ToList();

            foreach (var g in groups)
            {
                EDIFordPlan newPlan = g.List.First();
                newPlan.PlanDateString = g.List.Min(s => s.ForecastDate).ToShortDateString() + "~~" + g.List.Max(s => s.ForecastDate).ToShortDateString();
                allList.Add(newPlan);
            }
            totalItem     = allList.Count;
            currentItem01 = (CurrenPage - 1) * 10 + 1;
            currentItem02 = CurrenPage * 10 > totalItem ? totalItem : CurrenPage * 10;
            returnList    = allList.Skip((CurrenPage - 1) * 10).Take(10).ToList();
            isMaxPage     = currentItem02 == totalItem;
            isMinPage     = currentItem01 == 1;
        }
    }
Exemplo n.º 11
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string releaseNo = ((LinkButton)sender).CommandArgument;
        IList <PurchasePlanMstr2> mstr = TheGenericMgr.FindAllWithCustomQuery <PurchasePlanMstr2>(string.Format(" select m from PurchasePlanMstr2 as m where m.Status='{0}' and ReleaseNo={1} ", BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE, releaseNo));

        if (mstr != null && mstr.Count > 0)
        {
            PurchasePlanMstr2 m       = mstr.First();
            DateTime          dateNow = System.DateTime.Now;
            m.LastModifyUser = this.CurrentUser.Code;
            m.LastModifyDate = dateNow;
            m.ReleaseDate    = dateNow;
            m.ReleaseUser    = this.CurrentUser.Code;
            m.Status         = BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT;
            TheGenericMgr.Update(m);
            ShowSuccessMessage("释放成功。");
        }
        else
        {
            ShowErrorMessage("没有需要释放的采购计划。");
        }
    }
Exemplo n.º 12
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        try
        {
            HSSFWorkbook excel = new HSSFWorkbook(fileUpload.PostedFile.InputStream);
            Sheet        sheet = excel.GetSheetAt(0);
            IEnumerator  rows  = sheet.GetRowEnumerator();
            ImportHelper.JumpRows(rows, 10);
            //生产线	物料号	物料描述	条码	数量	上线日期	上线时间	生产单号


            #region 列定义
            int colProdLine       = 1; //供货路线
            int colItemCode       = 2; //物料号
            int colHuId           = 4; // 条码号
            int colQty            = 5; //订单数
            int colOfflineDateStr = 6; //上线日期
            int colOfflineTimeStr = 7; //上线时间
            int colOrderNo        = 8; //生产单号
            #endregion
            int rowCount = 10;
            //IList<Exception> exceptionList = new List<Exception>();
            //Exception exceptio = new Exception();
            string                   errorMessage = string.Empty;
            DateTime                 nowTime      = DateTime.Now;
            DssInboundControl        control      = TheGenericMgr.FindById <DssInboundControl>(9);
            IList <DssImportHistory> importList   = new List <DssImportHistory>();
            while (rows.MoveNext())
            {
                rowCount++;
                HSSFRow row = (HSSFRow)rows.Current;
                if (!TheImportMgr.CheckValidDataRow(row, 1, 4))
                {
                    break;//边界
                }
                string  prodLineCode   = string.Empty;
                Item    Item           = null;
                string  huId           = string.Empty;
                decimal qty            = 0;
                string  offlineDateStr = string.Empty;
                string  offlineTimeStr = string.Empty;
                string  orderNo        = string.Empty;

                #region 读取数据
                #region 生产线
                prodLineCode = row.GetCell(colProdLine) != null?row.GetCell(colProdLine).StringCellValue : string.Empty;

                if (string.IsNullOrEmpty(prodLineCode))
                {
                    //ShowErrorMessage(string.Format("第{0}行:供货路线不能为空。", rowCount));
                    errorMessage += string.Format("第{0}行:生产线不能为空。<br/>", rowCount);
                    continue;
                }
                #endregion

                #region 读取物料代码
                string itemCode = row.GetCell(colItemCode) != null?row.GetCell(colItemCode).StringCellValue : string.Empty;

                if (itemCode == null || itemCode.Trim() == string.Empty)
                {
                    errorMessage += string.Format("第{0}行:物料代码不能为空。<br/>", rowCount);
                    //ShowErrorMessage(string.Format("第{0}行:物料代码不能为空。", rowCount));
                    continue;
                }
                else
                {
                    Item = this.TheGenericMgr.FindById <Item>(itemCode);
                    if (Item == null)
                    {
                        errorMessage += string.Format("第{0}行:物料代码{1}不存在。<br/>", rowCount, itemCode);
                        continue;
                    }
                }

                #endregion

                #region 条码
                huId = row.GetCell(colHuId) != null?row.GetCell(colHuId).StringCellValue : string.Empty;

                if (string.IsNullOrEmpty(huId))
                {
                    errorMessage += string.Format("第{0}行:条码不能为空。<br/>", rowCount);
                    continue;
                }
                else
                {
                    if (huId.Length < 9)
                    {
                        errorMessage += string.Format("第{0}行:条码长度不能小于9。<br/>", rowCount);
                        continue;
                    }
                    var yearCodeArr  = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "S", "T", "V", "W", "X", "Y" };
                    var monthCodeArr = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C" };
                    var yearCode     = huId.Substring(huId.Length - 8, 1);
                    if (yearCodeArr.Where(a => a == yearCode).Count() == 0)
                    {
                        errorMessage += string.Format("第{0}行:批号的年份格式不正确。。<br/>", rowCount);
                        continue;
                    }

                    var monthCode = huId.Substring(huId.Length - 7, 1);
                    if (monthCodeArr.Where(a => a == monthCode).Count() == 0)
                    {
                        errorMessage += string.Format("第{0}行:批号的月份格式不正确。。。<br/>", rowCount);
                        continue;
                    }

                    var dayCode = int.Parse(huId.Substring(huId.Length - 6, 2));
                    if (dayCode < 1 || dayCode > 31)
                    {
                        errorMessage += string.Format("第{0}行:批号的日期格式不正确。<br/>", rowCount);
                        continue;
                    }
                }
                #endregion

                #region 读取数量
                try
                {
                    qty = Convert.ToDecimal(row.GetCell(colQty).NumericCellValue);
                }
                catch
                {
                    errorMessage += string.Format("第{0}行:数量填写有误。<br/>", rowCount);
                    continue;
                }
                #endregion

                #region  线日期
                offlineDateStr = row.GetCell(colOfflineDateStr) != null?row.GetCell(colOfflineDateStr).StringCellValue : string.Empty;

                if (string.IsNullOrEmpty(offlineDateStr))
                {
                    errorMessage += string.Format("第{0}行:上线日期不能为空。<br/>", rowCount);
                    continue;
                }
                #endregion

                #region  线时间
                offlineTimeStr = row.GetCell(colOfflineTimeStr) != null?row.GetCell(colOfflineTimeStr).StringCellValue : string.Empty;

                if (string.IsNullOrEmpty(offlineTimeStr))
                {
                    errorMessage += string.Format("第{0}行:上线时间不能为空。<br/>", rowCount);
                    continue;
                }
                else
                {
                    try
                    {
                        var offlineDateTime = DateTime.Parse(offlineDateStr + " " + offlineTimeStr);
                    }
                    catch (Exception ex)
                    {
                        errorMessage += string.Format("第{0}行:[上线日期{1}+上线时间{2}]不符合要求。<br/>", rowCount, offlineDateStr, offlineTimeStr);
                        continue;
                    }
                }
                #endregion



                #region 生产线
                orderNo = row.GetCell(colOrderNo) != null?row.GetCell(colOrderNo).StringCellValue : string.Empty;

                if (string.IsNullOrEmpty(orderNo))
                {
                    errorMessage += string.Format("第{0}行:生产单号不能为空。<br/>", rowCount);
                    continue;
                }
                #endregion
                #endregion

                #region 填充数据
                DssImportHistory dssImportHistory = new DssImportHistory {
                    data0          = prodLineCode,
                    data1          = Item.Code,
                    data2          = huId,
                    data3          = qty.ToString(),
                    data7          = offlineDateStr,
                    data8          = offlineTimeStr,
                    data12         = orderNo,
                    IsActive       = true,
                    ErrorCount     = 0,
                    CreateDate     = nowTime,
                    LastModifyDate = nowTime,
                    LastModifyUser = CurrentUser.Code,
                    DssInboundCtrl = control,
                    EventCode      = "CREATE",
                    KeyCode        = "EXCEL",
                };
                importList.Add(dssImportHistory);

                #endregion
            }
            if (!string.IsNullOrEmpty(errorMessage))
            {
                throw new Exception(errorMessage);
            }
            if (importList.Count == 0)
            {
                throw new Exception("导入的有效数据为0.");
            }

            //try
            //{
            //    foreach (var dssImpHis in importList)
            //    {
            //        TheGenericMgr.Create(dssImpHis);
            //    }
            //}
            //catch (Exception ex)
            //{

            //    throw ex;
            //}


            TheMaterialFlushBackMgr.ImportProdItemHuId(importList);

            ShowSuccessMessage("导入成功。");
        }
        catch (BusinessErrorException ex)
        {
            ShowErrorMessage(ex);
        }
        catch (Exception ex)
        {
            ShowErrorMessage(ex.Message);
            return;
        }
    }
Exemplo n.º 13
0
    protected void ExportExcel(IList <EDIFordPlan> exportList)
    {
        HSSFWorkbook hssfworkbook = new HSSFWorkbook();
        //Sheet sheet1 = hssfworkbook.CreateSheet("Sheet1");
        MemoryStream output = new MemoryStream();

        if (exportList != null && exportList.Count > 0)
        {
            var groups = (from tak in exportList
                          group tak by tak.Control_Num into result
                          select new
            {
                Control_Num = result.Key,
                List = result.ToList()
            }).ToList();
            for (int ti = 0; ti < groups.Count(); ti++)
            {
                var              g           = groups[ti];
                Sheet            sheet1      = hssfworkbook.CreateSheet(g.Control_Num);
                IList <DateTime> dateListDic = g.List.OrderBy(l => l.ForecastDate).Select(l => l.ForecastDate).Distinct().ToList();
                #region 写入字段
                Row rowHeader = sheet1.CreateRow(0);
                for (int i = 0; i < 6 + dateListDic.Count; i++)
                {
                    if (i == 0) //版本号
                    {
                        rowHeader.CreateCell(i).SetCellValue("版本号");
                    }
                    else if (i == 1)  //文件发布日期
                    {
                        rowHeader.CreateCell(i).SetCellValue("文件发布日期");
                    }
                    else if (i == 2) //物料号
                    {
                        rowHeader.CreateCell(i).SetCellValue("物料号");
                    }
                    else if (i == 3)    //物料描述
                    {
                        rowHeader.CreateCell(i).SetCellValue("物料描述");
                    }
                    else if (i == 4)    //福特物料号
                    {
                        rowHeader.CreateCell(i).SetCellValue("福特物料号");
                    }
                    else if (i == 5)      //单位
                    {
                        rowHeader.CreateCell(i).SetCellValue("单位");
                    }
                    else
                    {
                        foreach (var date in dateListDic)
                        {
                            rowHeader.CreateCell(i++).SetCellValue(date.ToShortDateString());
                        }
                    }
                }
                #endregion

                #region 写入数值
                //Caption.Visible = true;
                var groupByRefItem = (from tak in g.List
                                      group tak by tak.RefItem into result
                                      select new
                {
                    RefItem = result.Key,
                    List = result.ToList()
                }).ToList();
                IList <FlowDetail> flowdets = TheGenericMgr.FindAllWithCustomQuery <FlowDetail>(string.Format(" select d from FlowDetail as d where  d.ReferenceItemCode in('{0}') ", string.Join("','", g.List.Select(w => w.RefItem).Distinct().ToArray())));
                int j = 1;
                foreach (var d in groupByRefItem)
                {
                    Row         rowDetail  = sheet1.CreateRow(j);
                    Row         rowDetail2 = sheet1.CreateRow(j + 1);
                    EDIFordPlan newPlan    = d.List.First();
                    if (flowdets != null && flowdets.Count > 0)
                    {
                        var flowDet = flowdets.Where(f => f.ReferenceItemCode == newPlan.RefItem);
                        if (flowDet != null && flowDet.Count() > 0)
                        {
                            newPlan.Item     = flowDet.First().Item.Code;
                            newPlan.ItemDesc = flowDet.First().Item.Description;
                        }
                    }
                    rowDetail.CreateCell(0).SetCellValue(newPlan.Control_Num);
                    rowDetail.CreateCell(1).SetCellValue(newPlan.ReleaseIssueDate.ToShortDateString());
                    rowDetail.CreateCell(2).SetCellValue(newPlan.Item);
                    rowDetail.CreateCell(3).SetCellValue(newPlan.ItemDesc);
                    rowDetail.CreateCell(4).SetCellValue(newPlan.RefItem);
                    rowDetail.CreateCell(5).SetCellValue(newPlan.Uom);
                    int cell = 0;
                    foreach (var f in d.List.OrderBy(o => o.ForecastDate))
                    {
                        cell++;
                        //rowDetail.CreateCell(5 + cell).
                        var createCell = rowDetail.CreateCell(5 + cell);
                        createCell.SetCellType(CellType.NUMERIC);
                        createCell.SetCellValue(Convert.ToDouble(f.ForecastQty > 0 ? f.ForecastQty : 0));

                        var createCell2 = rowDetail2.CreateCell(5 + cell);
                        createCell2.SetCellType(CellType.NUMERIC);
                        createCell2.SetCellValue(Convert.ToDouble(f.ForecastCumQty > 0 ? f.ForecastCumQty : 0));
                    }
                    j += 2;
                }
                #endregion
            }
            hssfworkbook.Write(output);

            string filename = "FordEdiPlan.xls";
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", filename));
            Response.Clear();

            Response.BinaryWrite(output.GetBuffer());
            Response.End();
            //return File(output, contentType, exportName + "." + fileSuffiex);
        }
    }
Exemplo n.º 14
0
    private void ContrastPurchasePlan2(int version1, int version2, string[] flowArr, string item)
    {
        var mstrs1 = TheGenericMgr.FindAllWithCustomQuery <PurchasePlanMstr2>("select m from PurchasePlanMstr2 as m where m.ReleaseNo=?", version1);
        var mstrs2 = TheGenericMgr.FindAllWithCustomQuery <PurchasePlanMstr2>("select m from PurchasePlanMstr2 as m where m.ReleaseNo=?", version2);

        if (mstrs1 == null || mstrs1.Count == 0)
        {
            this.Resultlist.InnerHtml = "";
            ShowErrorMessage(string.Format("版本号{0}不存在,请确认。", version1));
            return;
        }
        if (mstrs2 == null || mstrs2.Count == 0)
        {
            this.Resultlist.InnerHtml = "";
            ShowErrorMessage(string.Format("版本号{0}不存在,请确认。", version2));
            return;
        }

        string searchHql = " select d from  PurchasePlanDet2 as d where Type='Daily' ";

        if (!string.IsNullOrEmpty(item))
        {
            searchHql += string.Format(" and d.Item='{0}' ", item);
        }

        string flowstr = string.Empty;

        if (flowArr.Length > 0)
        {
            foreach (var flow in flowArr)
            {
                if (string.IsNullOrEmpty(flowstr))
                {
                    flowstr = string.Format(" and (d.Flow='{0}' ", flow);
                }
                else
                {
                    flowstr += string.Format(" or d.Flow='{0}' ", flow);
                }
            }
            searchHql += flowstr + ")";
        }

        var dets1         = TheGenericMgr.FindAllWithCustomQuery <PurchasePlanDet2>(searchHql + " and d.PurchasePlanId= " + mstrs1.First().Id);
        var dets2         = TheGenericMgr.FindAllWithCustomQuery <PurchasePlanDet2>(searchHql + " and d.PurchasePlanId= " + mstrs2.First().Id);
        var minStartTime1 = dets1.Min(s => s.StartTime);

        dets1 = (from d in dets1
                 where  d.StartTime < minStartTime1.AddDays(14)
                 select d).ToList();


        var minStartTime2 = dets2.Min(s => s.StartTime);

        dets2 = (from d in dets2
                 where d.StartTime < minStartTime2.AddDays(14)
                 select d).ToList();

        var allResult1 = new System.Collections.Generic.List <PurchasePlanDet2>();

        allResult1.AddRange(dets1);
        allResult1.AddRange(dets2);

        var planByFlowItems = allResult1.OrderBy(p => p.Flow).GroupBy(p => new { p.Flow, p.Item });

        var sTime = minStartTime1 < minStartTime2 ? minStartTime1 : minStartTime2;

        var eTime = minStartTime1 < minStartTime2 ? minStartTime2 : minStartTime1;

        StringBuilder str = new StringBuilder();

        str.Append("<table id='tt' runat='server' border='1' class='GV' style='width:150%;border-collapse:collapse;'>");
        str.Append("<thead><tr class='GVHeader'><th rowspan='2'>序号</th><th rowspan='2'>路线</th><th rowspan='2'>物料号</th><th rowspan='2'>物料描述</th>");

        if (sTime.AddDays(14) <= eTime)
        {
            for (int i = 0; i < 14; i++)
            {
                str.Append("<th colspan='2'>");
                str.Append(sTime.ToString("yyyy-MM-dd"));
                str.Append("</th>");
                sTime = sTime.AddDays(1);
            }
            for (int i = 0; i < 14; i++)
            {
                str.Append("<th colspan='2'>");
                str.Append(eTime.ToString("yyyy-MM-dd"));
                str.Append("</th>");
                eTime = eTime.AddDays(1);
            }
            str.Append("</tr><tr class='GVHeader'>");

            for (int i = 0; i < 28; i++)
            {
                str.Append(string.Format("<th >{0}</th><th >{1}</th>", version1, version2));
            }
        }
        else
        {
            while (sTime <= eTime.AddDays(14))
            {
                str.Append("<th colspan='2'>");
                str.Append(sTime.ToString("yyyy-MM-dd"));
                str.Append("</th>");
                sTime = sTime.AddDays(1);
            }

            str.Append("</tr><tr class='GVHeader'>");
            sTime = minStartTime1 < minStartTime2 ? minStartTime1 : minStartTime2;
            while (sTime <= eTime.AddDays(14))
            {
                str.Append(string.Format("<th >{0}</th><th >{1}</th>", version1, version2));
                sTime = sTime.AddDays(1);
            }
        }
        str.Append("</tr></thead>");
        str.Append("<tbody>");
        int l = 0;

        foreach (var planByFlowItem in planByFlowItems)
        {
            var firstPlan = planByFlowItem.First();
            l++;
            if (l % 2 == 0)
            {
                str.Append("<tr class='GVAlternatingRow'>");
            }
            else
            {
                str.Append("<tr class='GVRow'>");
            }
            str.Append("<td>");
            str.Append(l);
            str.Append("</td>");
            str.Append("<td>");
            str.Append(planByFlowItem.Key.Flow);
            str.Append("</td>");
            str.Append("<td>");
            str.Append(planByFlowItem.Key.Item);
            str.Append("</td>");
            str.Append("<td>");
            str.Append(firstPlan.ItemDesc);
            str.Append("</td>");

            sTime = minStartTime1 < minStartTime2 ? minStartTime1 : minStartTime2;

            eTime = minStartTime1 < minStartTime2 ? minStartTime2 : minStartTime1;
            if (sTime.AddDays(14) <= eTime)
            {
                for (int i = 0; i < 28; i++)
                {
                    var curenPlan1 = dets1.Where(p => p.StartTime.Date == sTime.Date && p.Item == firstPlan.Item && p.Flow == firstPlan.Flow);
                    var curenPlan2 = dets2.Where(p => p.StartTime.Date == sTime.Date && p.Item == firstPlan.Item && p.Flow == firstPlan.Flow);
                    if (i > 14)
                    {
                        curenPlan1 = dets1.Where(p => p.StartTime.Date == eTime.Date && p.Item == firstPlan.Item && p.Flow == firstPlan.Flow);
                        curenPlan2 = dets2.Where(p => p.StartTime.Date == eTime.Date && p.Item == firstPlan.Item && p.Flow == firstPlan.Flow);
                    }

                    var shipPlanDet1 = curenPlan1.Count() > 0 ? curenPlan1.First() : new PurchasePlanDet2();
                    var shipPlanDet2 = curenPlan2.Count() > 0 ? curenPlan2.First() : new PurchasePlanDet2();
                    if (shipPlanDet1.PurchaseQty == shipPlanDet2.PurchaseQty)
                    {
                        str.Append("<td>");
                        str.Append(shipPlanDet1.PurchaseQty.ToString("0.##"));
                        str.Append("</td>");
                        str.Append("<td>");
                        str.Append(shipPlanDet2.PurchaseQty.ToString("0.##"));
                        str.Append("</td>");
                    }
                    else
                    {
                        str.Append("<td style='background-color:red;'>");
                        str.Append(shipPlanDet1.PurchaseQty.ToString("0.##"));
                        str.Append("</td>");
                        str.Append("<td style='background-color:red;'>");
                        str.Append(shipPlanDet2.PurchaseQty.ToString("0.##"));
                        str.Append("</td>");
                    }
                    if (i <= 14)
                    {
                        sTime = sTime.AddDays(1);
                    }
                    else
                    {
                        eTime = eTime.AddDays(1);
                    }
                }
            }
            else
            {
                while (sTime <= eTime.AddDays(14))
                {
                    var curenPlan1   = dets1.Where(p => p.StartTime.Date == sTime.Date && p.Item == firstPlan.Item && p.Flow == firstPlan.Flow);
                    var curenPlan2   = dets2.Where(p => p.StartTime.Date == sTime.Date && p.Item == firstPlan.Item && p.Flow == firstPlan.Flow);
                    var shipPlanDet1 = curenPlan1.Count() > 0 ? curenPlan1.First() : new PurchasePlanDet2();
                    var shipPlanDet2 = curenPlan2.Count() > 0 ? curenPlan2.First() : new PurchasePlanDet2();
                    if (shipPlanDet1.PurchaseQty == shipPlanDet2.PurchaseQty)
                    {
                        str.Append("<td>");
                        str.Append(shipPlanDet1.PurchaseQty.ToString("0.##"));
                        str.Append("</td>");
                        str.Append("<td>");
                        str.Append(shipPlanDet2.PurchaseQty.ToString("0.##"));
                        str.Append("</td>");
                    }
                    else
                    {
                        str.Append("<td style='background-color:red;'>");
                        str.Append(shipPlanDet1.PurchaseQty.ToString("0.##"));
                        str.Append("</td>");
                        str.Append("<td style='background-color:red;'>");
                        str.Append(shipPlanDet2.PurchaseQty.ToString("0.##"));
                        str.Append("</td>");
                    }
                    sTime = sTime.AddDays(1);
                }
            }
            str.Append("</tr>");
        }
        str.Append("</tbody></table>");
        this.Resultlist.InnerHtml = str.ToString();
    }
Exemplo n.º 15
0
    protected void btnExport_Click(object sender, EventArgs e)
    {
        this.btQtyHidden.Value = string.Empty;
        this.btSeqHidden.Value = string.Empty;
        var searchSql = @"  select m.Id,m.ReleaseNo,det.Id,det.Item,det.itemDesc,det.RefItemCode,isnull(det.OrgQty,0),isnull(det.Qty,0),det.Uom,det.StartTime,det.WindowTime,det.UUID,isnull(det.OrderQty,0),isnull(l.initStock,0),isnull(l.SafeStock,0),isnull(l.MaxStock,0),isnull(l.InTransitQty,0),isnull(l.InspectQty,0),isnull(det.ReqQty,0),isnull(det.UC,0),isnull(MinLotSize,0),l.InventoryCountDown
 from  dbo.MRP_ProductionPlanDet as det with(nolock) inner join MRP_ProductionPlanMstr as m with(nolock) on det.ProductionPlanId=m.Id
inner join MRP_ProductionPlanInitLocationDet as l with(nolock) on det.ProductionPlanId=l.ProductionPlanId and det.Item=l.Item  where 1=1  ";

        searchSql += string.Format(" and det.Type='{0}' ", this.rbType.SelectedValue);
        if (!string.IsNullOrEmpty(this.tbItemCode.Text.Trim()))
        {
            searchSql += string.Format(" and det.Item ='{0}' ", this.tbItemCode.Text.Trim());
        }

        if (!string.IsNullOrEmpty(currentRelesNo))
        {
            searchSql += string.Format(" and m.ReleaseNo ='{0}' ", currentRelesNo);
        }

        searchSql += " order by det.Item asc ";

        var allResult             = TheGenericMgr.GetDatasetBySql(searchSql).Tables[0];
        var productionPlanDetList = new List <ProductionPlanDet>();

        foreach (System.Data.DataRow row in allResult.Rows)
        {
            productionPlanDetList.Add(new ProductionPlanDet
            {
                ProductionPlanId = Int32.Parse(row[0].ToString()),
                ReleaseNo        = Int32.Parse(row[1].ToString()),
                Id                 = Int32.Parse(row[2].ToString()),
                Item               = row[3].ToString(),
                ItemDesc           = row[4].ToString(),
                RefItemCode        = row[5].ToString(),
                OrgQty             = Math.Round(Convert.ToDecimal(row[6])),
                Qty                = Math.Round(Convert.ToDecimal(row[7])),
                Uom                = row[8].ToString(),
                StartTime          = Convert.ToDateTime(row[9]),
                WindowTime         = Convert.ToDateTime(row[10]),
                UUID               = row[11].ToString(),
                OrderQty           = Math.Round(Convert.ToDecimal(row[12])),
                InitStock          = Math.Round(Convert.ToDecimal(row[13])),
                SafeStock          = Math.Round(Convert.ToDecimal(row[14])),
                MaxStock           = Math.Round(Convert.ToDecimal(row[15])),
                InTransitQty       = Math.Round(Convert.ToDecimal(row[16])),
                InspectQty         = Math.Round(Convert.ToDecimal(row[17])),
                ReqQty             = Math.Round(Convert.ToDecimal(row[18])),
                UnitCount          = Math.Round(Convert.ToDecimal(row[19])),
                MinLotSize         = Math.Round(Convert.ToDecimal(row[20])),
                InventoryCountDown = !string.IsNullOrEmpty(row[21].ToString()) ? (decimal?)row[22] : null,
                //InventoryCountDown = (decimal?)row[21],
            });
        }
        if (this.rbType.SelectedValue == BusinessConstants.CODE_MASTER_TIME_PERIOD_TYPE_VALUE_DAY)
        {
            var minStartTime = productionPlanDetList.Min(s => s.StartTime).AddDays(13);
            productionPlanDetList = productionPlanDetList.Where(s => s.StartTime <= minStartTime).ToList();
            IList <object> data = new List <object>();
            data.Add(productionPlanDetList);
            TheReportMgr.WriteToClient("ProductionPlanDaily.xls", data, "ProductionPlanDaily.xls");
        }
        else
        {
            ExportWeeklyExcel(productionPlanDetList);
        }
    }
Exemplo n.º 16
0
    private void ExportExcel()
    {
        HSSFWorkbook hssfworkbook = new HSSFWorkbook();
        //Sheet sheet1 = hssfworkbook.CreateSheet("Sheet1");
        MemoryStream output     = new MemoryStream();
        var          result     = TheGenericMgr.GetDatasetBySql(StaticSql).Tables[0];
        var          exportList = new List <LocationLotDetailView>();

        foreach (System.Data.DataRow row in result.Rows)
        {
            exportList.Add(new LocationLotDetailView
            {
                Id       = int.Parse(row[0].ToString()),
                ItemCode = row[1].ToString(),
                ItemDesc = row[2].ToString(),
                Uom      = row[3].ToString(),
                LocCode  = row[4].ToString(),
                LocName  = row[5].ToString(),
                BinCode  = row[6].ToString(),
                LotNo    = row[7].ToString(),
                Qty      = Convert.ToDecimal(row[8].ToString()),
            });
        }
        exportList = exportList == null || exportList.Count == 0 ? new List <LocationLotDetailView>() : exportList;
        if (exportList != null && exportList.Count > 0)
        {
            Sheet sheet1 = hssfworkbook.CreateSheet("sheet1");

            #region 写入字段
            int i         = 0;
            Row rowHeader = sheet1.CreateRow(i++);
            //No.	物料代码	物料描述	单位	库位	库位名称	库格	批号	数量
            rowHeader.CreateCell(0).SetCellValue("No.");
            rowHeader.CreateCell(1).SetCellValue("物料代码");
            rowHeader.CreateCell(2).SetCellValue("物料描述");
            rowHeader.CreateCell(3).SetCellValue("单位");
            rowHeader.CreateCell(4).SetCellValue("库位");
            rowHeader.CreateCell(5).SetCellValue("库位名称");
            rowHeader.CreateCell(6).SetCellValue("库格");
            rowHeader.CreateCell(7).SetCellValue("批号");
            rowHeader.CreateCell(8).SetCellValue("数量");
            #endregion

            #region 写入数值
            foreach (var d in exportList)
            {
                Row rowDetail = sheet1.CreateRow(i++);
                rowDetail.CreateCell(0).SetCellValue(i - 1);
                rowDetail.CreateCell(1).SetCellValue(d.ItemCode);
                rowDetail.CreateCell(2).SetCellValue(d.ItemDesc);
                rowDetail.CreateCell(3).SetCellValue(d.Uom);
                rowDetail.CreateCell(4).SetCellValue(d.LocCode);
                rowDetail.CreateCell(5).SetCellValue(d.LocName);
                rowDetail.CreateCell(6).SetCellValue(d.BinCode);
                rowDetail.CreateCell(7).SetCellValue(d.LotNo);
                rowDetail.CreateCell(8).SetCellValue(d.Qty.Value.ToString("0.##"));
            }
            #endregion
        }
        hssfworkbook.Write(output);

        string filename = "export.xls";
        Response.ContentType = "application/vnd.ms-excel";
        Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", filename));
        Response.Clear();

        Response.BinaryWrite(output.GetBuffer());
        Response.End();
        //return File(output, contentType, exportName + "." + fileSuffiex);
    }
Exemplo n.º 17
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        this.btQtyHidden.Value = string.Empty;
        this.btSeqHidden.Value = string.Empty;
        var searchSql = @"  select m.Id,m.ReleaseNo,det.Id,det.Item,det.itemDesc,det.RefItemCode,isnull(det.OrgQty,0),isnull(det.Qty,0),det.Uom,det.StartTime,det.WindowTime,det.UUID,isnull(det.OrderQty,0),isnull(l.initStock,0),isnull(l.SafeStock,0),isnull(l.MaxStock,0),isnull(l.InTransitQty,0),isnull(l.InspectQty,0),isnull(det.ReqQty,0),isnull(det.UC,0),isnull(MinLotSize,0),isnull(m.Status,'Submit'),l.InventoryCountDown
 from  dbo.MRP_ProductionPlanDet as det with(nolock) inner join MRP_ProductionPlanMstr as m with(nolock) on det.ProductionPlanId=m.Id
inner join MRP_ProductionPlanInitLocationDet as l with(nolock) on det.ProductionPlanId=l.ProductionPlanId and det.Item=l.Item  where 1=1  ";

        //if (!string.IsNullOrEmpty(this.tbFlow.Text.Trim()))
        //{
        //    searchSql += string.Format(" and det.Flow ='{0}' ", this.tbFlow.Text.Trim());
        //}
        //else
        //{
        //    this.list.InnerHtml = "";
        //    ShowErrorMessage("发运路线不能为空。");
        //    return;
        //}

        searchSql += string.Format(" and det.Type='{0}' ", this.rbType.SelectedValue);
        if (!string.IsNullOrEmpty(this.tbItemCode.Text.Trim()))
        {
            searchSql += string.Format(" and det.Item ='{0}' ", this.tbItemCode.Text.Trim());
        }

        if (!string.IsNullOrEmpty(currentRelesNo))
        {
            searchSql += string.Format(" and m.ReleaseNo ='{0}' ", currentRelesNo);
        }

        searchSql += " order by det.Item asc ";



        var allResult             = TheGenericMgr.GetDatasetBySql(searchSql).Tables[0];
        var productionPlanDetList = new List <ProductionPlanDet>();

        foreach (System.Data.DataRow row in allResult.Rows)
        {
            //m.Id,m.ReleaseNo,det.Id,det.Item,det.itemDesc,det.RefItemCode,isnull(det.OrgQty,0),isnull(det.Qty,0),
            //det.Uom,det.StartTime,det.WindowTime,det.UUID,isnull(det.OrderQty,0),isnull(l.initStock,0),
            //isnull(l.SafeStock,0),isnull(l.MaxStock,0),isnull(l.InTransitQty,0),isnull(l.InspectQty,0)
            productionPlanDetList.Add(new ProductionPlanDet
            {
                ProductionPlanId = Int32.Parse(row[0].ToString()),
                ReleaseNo        = Int32.Parse(row[1].ToString()),
                Id                 = Int32.Parse(row[2].ToString()),
                Item               = row[3].ToString(),
                ItemDesc           = row[4].ToString(),
                RefItemCode        = row[5].ToString(),
                OrgQty             = Math.Round(Convert.ToDecimal(row[6])),
                Qty                = Math.Round(Convert.ToDecimal(row[7])),
                Uom                = row[8].ToString(),
                StartTime          = Convert.ToDateTime(row[9]),
                WindowTime         = Convert.ToDateTime(row[10]),
                UUID               = row[11].ToString(),
                OrderQty           = Math.Round(Convert.ToDecimal(row[12])),
                InitStock          = Math.Round(Convert.ToDecimal(row[13])),
                SafeStock          = Math.Round(Convert.ToDecimal(row[14])),
                MaxStock           = Math.Round(Convert.ToDecimal(row[15])),
                InTransitQty       = Math.Round(Convert.ToDecimal(row[16])),
                InspectQty         = Math.Round(Convert.ToDecimal(row[17])),
                ReqQty             = Math.Round(Convert.ToDecimal(row[18])),
                UnitCount          = Math.Round(Convert.ToDecimal(row[19])),
                MinLotSize         = Math.Round(Convert.ToDecimal(row[20])),
                Status             = row[21].ToString(),
                InventoryCountDown = !string.IsNullOrEmpty(row[22].ToString())? (decimal?)row[22] : null,
            });
        }
        if (this.rbType.SelectedValue == BusinessConstants.CODE_MASTER_TIME_PERIOD_TYPE_VALUE_DAY)
        {
            ListTable(productionPlanDetList);
        }
        else
        {
            WeeklyListTable(productionPlanDetList);
        }
    }
Exemplo n.º 18
0
    private List <EDIFordPlan> GetShipEDIFordPlan()
    {
        List <EDIFordPlan> eDIFordPlanList = new List <EDIFordPlan>();

        foreach (GridViewRow gvr in GV_List.Rows)
        {
            EDIFordPlan eDIFordPlan     = new EDIFordPlan();
            CheckBox    cbCheckBoxGroup = (CheckBox)gvr.FindControl("CheckBoxGroup");
            if (cbCheckBoxGroup.Checked)
            {
                int id = int.Parse(((HiddenField)gvr.FindControl("ftId")).Value);
                eDIFordPlan = TheGenericMgr.FindAllWithCustomQuery <EDIFordPlan>(" select e from EDIFordPlan as e where Id=? ", id).First();

                string itemCode = ((HiddenField)gvr.FindControl("ftItem")).Value;
                string itemDesc = ((HiddenField)gvr.FindControl("ftItemDesc")).Value;
                if (string.IsNullOrEmpty(itemCode))
                {
                    throw new BusinessErrorException(string.Format("福特物料号{0}在路线{1}中没有找到有效的路线明细,发货失败。", eDIFordPlan.RefItem, this.tbFlow.Text.Trim()));
                }
                else
                {
                    eDIFordPlan.Item     = itemCode;
                    eDIFordPlan.ItemDesc = itemDesc;
                }

                #region   本次发货量
                try
                {
                    eDIFordPlan.ShipQty = decimal.Parse(((TextBox)gvr.FindControl("tbShipQty")).Text.Trim());
                }
                catch (Exception e)
                {
                    throw new BusinessErrorException(string.Format("版本号{0}物料号{1}本次发货量填写有误。", eDIFordPlan.Control_Num, eDIFordPlan.Item));
                }
                #endregion

                #region   发货总毛重
                try
                {
                    eDIFordPlan.GrossWeight = decimal.Parse(((TextBox)gvr.FindControl("tbGrossWeight")).Text.Trim()) * eDIFordPlan.ShipQty;
                }
                catch (Exception e)
                {
                    throw new BusinessErrorException(string.Format("版本号{0}物料号{1}发货总毛重填写有误。", eDIFordPlan.Control_Num, eDIFordPlan.Item));
                }
                #endregion

                #region   发货总净重
                try
                {
                    eDIFordPlan.NetWeight = decimal.Parse(((TextBox)gvr.FindControl("tbNetWeight")).Text.Trim()) * eDIFordPlan.ShipQty;
                }
                catch (Exception e)
                {
                    throw new BusinessErrorException(string.Format("版本号{0}物料号{1}发货总净重填写有误。", eDIFordPlan.Control_Num, eDIFordPlan.Item));
                }
                #endregion

                #region   毛重净重单位
                if (string.IsNullOrEmpty(((TextBox)gvr.FindControl("tbWeightUom")).Text.Trim()))
                {
                    throw new BusinessErrorException(string.Format("版本号{0}物料号{1}毛重净重单位填写有误。", eDIFordPlan.Control_Num, eDIFordPlan.Item));
                }
                else
                {
                    eDIFordPlan.WeightUom = ((TextBox)gvr.FindControl("tbWeightUom")).Text.Trim();
                }
                #endregion

                #region   装箱单号
                if (string.IsNullOrEmpty(((TextBox)gvr.FindControl("tbShipmentID")).Text.Trim()))
                {
                    throw new BusinessErrorException(string.Format("版本号{0}物料号{1}装箱单号填写有误。", eDIFordPlan.Control_Num, eDIFordPlan.Item));
                }
                else
                {
                    eDIFordPlan.ShipmentID = ((TextBox)gvr.FindControl("tbShipmentID")).Text.Trim();
                }
                #endregion

                #region   提单号
                if (string.IsNullOrEmpty(((TextBox)gvr.FindControl("tbLadingNum")).Text.Trim()))
                {
                    throw new BusinessErrorException(string.Format("版本号{0}物料号{1}提单号填写有误。", eDIFordPlan.Control_Num, eDIFordPlan.Item));
                }
                else
                {
                    eDIFordPlan.LadingNum = ((TextBox)gvr.FindControl("tbLadingNum")).Text.Trim();
                }
                #endregion

                #region   外包装类型
                eDIFordPlan.OutPackType = ((TextBox)gvr.FindControl("tbOutPackType")).Text.Trim();
                #endregion

                #region   外包装数量
                try
                {
                    eDIFordPlan.OutPackQty = decimal.Parse(((TextBox)gvr.FindControl("tbOutPackQty")).Text.Trim());
                }
                catch (Exception e)
                {
                    eDIFordPlan.OutPackQty = null;
                }
                #endregion

                #region   承运商
                if (string.IsNullOrEmpty(((TextBox)gvr.FindControl("tbCarrierCode")).Text.Trim()))
                {
                    throw new BusinessErrorException(string.Format("版本号{0}物料号{1}承运商填写有误。", eDIFordPlan.Control_Num, eDIFordPlan.Item));
                }
                else
                {
                    eDIFordPlan.CarrierCode = ((TextBox)gvr.FindControl("tbCarrierCode")).Text.Trim();
                }
                #endregion

                #region   运输方式
                if (string.IsNullOrEmpty(((TextBox)gvr.FindControl("tbTransportationMethod")).Text.Trim()))
                {
                    throw new BusinessErrorException(string.Format("版本号{0}物料号{1}运输方式填写有误。", eDIFordPlan.Control_Num, eDIFordPlan.Item));
                }
                else
                {
                    eDIFordPlan.TransportationMethod = ((TextBox)gvr.FindControl("tbTransportationMethod")).Text.Trim();
                }
                #endregion

                #region   运载媒介
                eDIFordPlan.EquipmentDesc = eDIFordPlan.TransportationMethod;
                if (eDIFordPlan.TransportationMethod == "M")
                {
                    eDIFordPlan.EquipmentDesc = "TL";
                }
                else if (eDIFordPlan.TransportationMethod == "O")
                {
                    eDIFordPlan.EquipmentDesc = "CN";
                }
                else if (eDIFordPlan.TransportationMethod == "A")
                {
                    eDIFordPlan.EquipmentDesc = "AF";
                }
                //if (string.IsNullOrEmpty(((TextBox)gvr.FindControl("tbEquipmentDesc")).Text.Trim()))
                //{
                //    throw new BusinessErrorException(string.Format("版本号{0}物料号{1}运载媒介填写有误。", eDIFordPlan.Control_Num, eDIFordPlan.Item));
                //}
                //else
                //{
                //eDIFordPlan.EquipmentDesc = ((TextBox)gvr.FindControl("tbEquipmentDesc")).Text.Trim();
                // }
                #endregion

                #region   运载媒介序列号
                if (string.IsNullOrEmpty(((TextBox)gvr.FindControl("tbEquipmentNum")).Text.Trim()))
                {
                    throw new BusinessErrorException(string.Format("版本号{0}物料号{1}运载媒介序列号填写有误。", eDIFordPlan.Control_Num, eDIFordPlan.Item));
                }
                else
                {
                    eDIFordPlan.EquipmentNum = ((TextBox)gvr.FindControl("tbEquipmentNum")).Text.Trim();
                }
                #endregion



                #region   累计发货量
                eDIFordPlan.LastShippedCumulative = eDIFordPlan.LastShippedCumulative.HasValue ? eDIFordPlan.LastShippedCumulative : 0;
                //try
                //{
                //    eDIFordPlan.ShipQtyCum = decimal.Parse(((TextBox)gvr.FindControl("tbShipQtyCum")).Text.Trim());
                //}
                //catch (Exception e)
                //{
                //    throw new BusinessErrorException(string.Format("版本号{0}物料号{1}累计发货量填写有误。", eDIFordPlan.Control_Num, eDIFordPlan.Item));
                //}
                #endregion

                #region   单位
                if (string.IsNullOrEmpty(((TextBox)gvr.FindControl("tbInUom")).Text.Trim()))
                {
                    throw new BusinessErrorException(string.Format("版本号{0}物料号{1}单位填写有误。", eDIFordPlan.Control_Num, eDIFordPlan.Item));
                }
                else
                {
                    eDIFordPlan.Uom = ((TextBox)gvr.FindControl("tbInUom")).Text.Trim();
                }
                #endregion

                #region   内包装类型
                eDIFordPlan.InPackType = ((TextBox)gvr.FindControl("tbOutPackType")).Text.Trim();
                #endregion

                #region   每个包装数量
                try
                {
                    eDIFordPlan.PerLoadQty = decimal.Parse(((TextBox)gvr.FindControl("tbPerLoadQty")).Text.Trim());
                    if (eDIFordPlan.PerLoadQty == 0)
                    {
                        throw new BusinessErrorException(string.Format("版本号{0}物料号{1}每个包装件数必须大于0。", eDIFordPlan.Control_Num, eDIFordPlan.Item));
                    }
                }
                catch (Exception e)
                {
                    eDIFordPlan.PerLoadQty = null;
                }
                #endregion

                #region   内包装数量
                eDIFordPlan.InPackQty = eDIFordPlan.PerLoadQty == null ? 1 : (int?)Convert.ToInt32((eDIFordPlan.ShipQty.Value % eDIFordPlan.PerLoadQty.Value == 0 ? eDIFordPlan.ShipQty.Value / eDIFordPlan.PerLoadQty.Value : eDIFordPlan.ShipQty.Value / eDIFordPlan.PerLoadQty.Value + 1));
                //try
                //{
                //    eDIFordPlan.InPackQty = decimal.Parse(((TextBox)gvr.FindControl("tbInPackQty")).Text.Trim());
                //}
                //catch (Exception e)
                //{
                //    eDIFordPlan.InPackQty = null;
                //}
                #endregion

                #region   机场代码
                eDIFordPlan.AirportCode = ((TextBox)gvr.FindControl("tbAirportCode")).Text.Trim();
                if (eDIFordPlan.TransportationMethod == "A")
                {
                    if (string.IsNullOrEmpty(eDIFordPlan.AirportCode))
                    {
                        throw new BusinessErrorException(string.Format("版本号{0}物料号{1},在选择空运的时候机场代码不能为空。", eDIFordPlan.Control_Num, eDIFordPlan.Item));
                    }
                }
                else
                {
                    eDIFordPlan.AirportCode = string.Empty;
                }
                #endregion

                eDIFordPlan.Purpose = ((System.Web.UI.HtmlControls.HtmlSelect)gvr.FindControl("tbPurpose")).Value;

                eDIFordPlanList.Add(eDIFordPlan);
            }
        }
        return(eDIFordPlanList);
    }
Exemplo n.º 19
0
    public void GetView(string searchSql)
    {
        IList <EDIFordPlan> fordPlanList = new List <EDIFordPlan>();

        if (!string.IsNullOrEmpty(searchSql))
        {
            SearchSql    = searchSql;
            fordPlanList = TheGenericMgr.FindAllWithCustomQuery <EDIFordPlan>(searchSql);
        }
        List <EDIFordPlan> returnList = new List <EDIFordPlan>();

        if (fordPlanList != null && fordPlanList.Count > 0)
        {
            control_num = fordPlanList.First().Control_Num;
            string flowCode    = this.tbFlow.Text.Trim();
            Flow   currentFlow = null;
            if (!string.IsNullOrEmpty(flowCode))
            {
                currentFlow = TheFlowMgr.LoadFlow(flowCode, this.CurrentUser.Code, true);
                //if (currentFlow != null)
                //{
                //    fordPlanList = (from det in fordPlanList
                //                    where currentFlow.FlowDetails.Select(s => s.Item.Code).Contains(det.Item)
                //                    select det).ToList();
                //}
            }
            var groups = (from tak in fordPlanList.OrderBy(f => f.ForecastDate)
                          group tak by new
            {
                tak.Control_Num,
                tak.RefItem
            }
                          into result
                          select new
            {
                RefItem = result.Key.RefItem,
                Control_Num = result.Key.Control_Num,
                List = result.ToList()
            }).ToList();

            foreach (var g in groups)
            {
                var r = g.List.First();
                r.Item     = string.Empty;
                r.ItemDesc = string.Empty;
                if (currentFlow != null)
                {
                    if (string.IsNullOrEmpty(currentFlow.CustomerCodes))
                    {
                        ShowErrorMessage("请维护路线的收货工厂");
                    }
                    if (string.IsNullOrEmpty(currentFlow.SupplierCodes))
                    {
                        ShowErrorMessage("请维护路线的发货工厂");
                    }
                    var customerCodes = currentFlow.CustomerCodes.Split(',');
                    var supplierCodes = currentFlow.SupplierCodes.Split(',');
                    var fdet          = currentFlow.FlowDetails.Where(d => d.ReferenceItemCode == r.RefItem);
                    if (fdet != null && fdet.Count() > 0 && customerCodes.Contains(r.CustomerCode) && supplierCodes.Contains(r.SupplierCode))
                    {
                        var f = fdet.First();
                        r.Item     = f.Item.Code;
                        r.ItemDesc = f.Item.Description;
                        //r.CustomerCode = f.ReceivingPlant;
                        //r.SupplierCode = f.ShipFrom;
                        r.TransportationMethod = f.TransModeCode;
                        r.EquipmentNum         = f.ConveyanceNumber;
                        r.CarrierCode          = f.CarrierCode;
                        try
                        {
                            r.GrossWeight = Convert.ToDecimal(f.GrossWeight);
                        }
                        catch (Exception)
                        {
                            r.GrossWeight = 0;
                        }
                        try
                        {
                            r.NetWeight = Convert.ToDecimal(f.NetWeight);
                        }
                        catch (Exception)
                        {
                            r.NetWeight = 0;
                        }
                        r.WeightUom   = f.WeightUom;
                        r.OutPackType = f.PackagingCode;
                        r.InPackType  = f.PackagingCode;
                        try
                        {
                            r.OutPackQty = Convert.ToDecimal(f.LadingQuantity);
                        }
                        catch (Exception)
                        {
                            r.OutPackQty = 0;
                        }
                        try
                        {
                            r.PerLoadQty = Convert.ToDecimal(f.UnitsPerContainer);
                        }
                        catch (Exception)
                        {
                            r.PerLoadQty = 0;
                        }
                    }
                }
                returnList.Add(r);
            }
        }
        this.GV_List.DataSource = returnList;
        this.GV_List.DataBind();
    }