예제 #1
0
        public ActionResult _AjaxList(GridCommand command, ReceiptMasterSearchModel searchModel)
        {
            if (!this.CheckSearchModelIsNull(searchModel))
            {
                return(PartialView(new GridModel(new List <ReceiptMaster>())));
            }
            string whereStatement = string.Empty;

            if (!string.IsNullOrWhiteSpace(searchModel.Item) && !string.IsNullOrWhiteSpace(searchModel.OrderNo))
            {
                whereStatement += " and exists(select 1 from RecDetail as d where d.RecNo = r.RecNo and d.Item = '" + searchModel.Item + "' and d.OrderNo='" + searchModel.OrderNo + "')";
            }
            else if (!string.IsNullOrWhiteSpace(searchModel.Item) && string.IsNullOrWhiteSpace(searchModel.OrderNo))
            {
                whereStatement += " and exists(select 1 from RecDetail as d where d.RecNo = r.RecNo and d.Item = '" + searchModel.Item + "')";
            }
            else if (string.IsNullOrWhiteSpace(searchModel.Item) && !string.IsNullOrWhiteSpace(searchModel.OrderNo))
            {
                whereStatement += " and exists(select 1 from RecDetail as d where d.RecNo = r.RecNo and d.OrderNo='" + searchModel.OrderNo + "')";
            }
            whereStatement += " and r.OrderSubType=" + (int)com.Sconit.CodeMaster.OrderSubType.Normal;
            ProcedureSearchStatementModel procedureSearchStatementModel = this.PrepareProcedureSearchStatement(command, searchModel, whereStatement);

            return(PartialView(GetAjaxPageDataProcedure <ReceiptMaster>(procedureSearchStatementModel, command)));
        }
예제 #2
0
        public ActionResult CancelList(GridCommand command, ReceiptMasterSearchModel searchModel)
        {
            SearchCacheModel     searchCacheModel     = ProcessSearchModel(command, searchModel);
            SearchStatementModel searchStatementModel = this.PrepareSearchStatement(command, (ReceiptMasterSearchModel)searchCacheModel.SearchObject);

            return(View(GetPageData <ReceiptMaster>(searchStatementModel, command)));
        }
예제 #3
0
        public ActionResult _AjaxRecDetList(GridCommand command, ReceiptMasterSearchModel searchModel)
        {
            if (!this.CheckSearchModelIsNull(searchModel))
            {
                return(PartialView(new GridModel(new List <ReceiptDetail>())));
            }
            #region old
            // o.OrderSubType = " + (int)com.Sconit.CodeMaster.OrderSubType.Normal + " and o.ReceiptNo=d.ReceiptNo
            // string whereStatement = " and exists (select 1 from ReceiptMaster  as r where r.OrderSubType = " + (int)com.Sconit.CodeMaster.OrderSubType.Normal + " and r.RecNo=d.RecNo) ";
            //string whereStatement = " where  i.Type = " + (int)com.Sconit.CodeMaster.OrderSubType.Normal + "";
            // ProcedureSearchStatementModel procedureSearchStatementModel = PrepareSearchDetailStatement(command, searchModel, whereStatement);
            // return PartialView(GetAjaxPageDataProcedure<ReceiptDetail>(procedureSearchStatementModel, command));
            #endregion
            string whereStatement = " and exists (select 1 from ReceiptMaster  as r where r.OrderSubType = " + (int)com.Sconit.CodeMaster.OrderSubType.Normal + " and r.RecNo=d.RecNo) ";
            if (!string.IsNullOrWhiteSpace(searchModel.OrderNo))
            {
                whereStatement += " and d.OrderNo='" + searchModel.OrderNo + "' ";
            }
            IList <ReceiptDetail>         receiptDetailList             = new List <ReceiptDetail>();
            ProcedureSearchStatementModel procedureSearchStatementModel = PrepareSearchDetailStatement(command, searchModel, whereStatement);
            procedureSearchStatementModel.SelectProcedure = "USP_Search_PrintRecDet";
            GridModel <object[]> gridModel = GetAjaxPageDataProcedure <object[]>(procedureSearchStatementModel, command);
            if (gridModel.Data != null && gridModel.Data.Count() > 0)
            {
                #region
                receiptDetailList = (from tak in gridModel.Data
                                     select new ReceiptDetail
                {
                    Id = (int)tak[0],
                    ReceiptNo = (string)tak[1],
                    OrderNo = (string)tak[2],
                    IpNo = (string)tak[3],
                    Flow = (string)tak[4],
                    ExternalOrderNo = (string)tak[5],
                    ExternalSequence = (string)tak[6],
                    Item = (string)tak[7],
                    ReferenceItemCode = (string)tak[8],
                    ItemDescription = (string)tak[9],
                    Uom = (string)tak[10],
                    LocationFrom = (string)tak[11],
                    LocationTo = (string)tak[12],
                    ReceivedQty = (decimal)tak[13],
                    MastPartyFrom = (string)tak[14],
                    MastPartyTo = (string)tak[15],
                    MastType = systemMgr.GetCodeDetailDescription(Sconit.CodeMaster.CodeMaster.OrderType, int.Parse((tak[16]).ToString())),
                    MastStatus = systemMgr.GetCodeDetailDescription(Sconit.CodeMaster.CodeMaster.OrderStatus, int.Parse((tak[17]).ToString())),
                    MastCreateDate = (DateTime)tak[18],
                    SAPLocation = (string)tak[19],
                }).ToList();
                #endregion
            }
            procedureSearchStatementModel.PageParameters[2].Parameter = gridModel.Total;
            TempData["ReceiptDetailPrintSearchModel"] = procedureSearchStatementModel;

            GridModel <ReceiptDetail> gridModelOrderDet = new GridModel <ReceiptDetail>();
            gridModelOrderDet.Total = gridModel.Total;
            gridModelOrderDet.Data  = receiptDetailList;

            return(PartialView(gridModelOrderDet));
        }
예제 #4
0
        private SearchStatementModel PrepareSearchStatement(GridCommand command, ReceiptMasterSearchModel searchModel)
        {
            string whereStatement = " where r.OrderSubType = " + (int)com.Sconit.CodeMaster.OrderSubType.Return +
                                    "  and r.OrderType in (" + (int)com.Sconit.CodeMaster.OrderType.CustomerGoods + "," + (int)com.Sconit.CodeMaster.OrderType.Procurement
                                    + "," + (int)com.Sconit.CodeMaster.OrderType.SubContract + ")";

            IList <object> param = new List <object>();

            //SecurityHelper.AddPartyFromPermissionStatement(ref whereStatement, "r", "PartyTo", com.Sconit.CodeMaster.OrderType.Procurement, true);
            SecurityHelper.AddPartyFromAndPartyToPermissionStatement(ref whereStatement, "r", "OrderType", "r", "PartyTo", "r", "PartyFrom", com.Sconit.CodeMaster.OrderType.Procurement, true);

            HqlStatementHelper.AddLikeStatement("WMSNo", searchModel.WMSNo, HqlStatementHelper.LikeMatchMode.Start, "r", ref whereStatement, param);
            HqlStatementHelper.AddLikeStatement("ReceiptNo", searchModel.ReceiptNo, HqlStatementHelper.LikeMatchMode.Start, "r", ref whereStatement, param);
            HqlStatementHelper.AddLikeStatement("IpNo", searchModel.IpNo, HqlStatementHelper.LikeMatchMode.Start, "r", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("PartyFrom", searchModel.PartyFrom, "r", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("PartyTo", searchModel.PartyTo, "r", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("OrderType", searchModel.GoodsReceiptOrderType, "r", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Status", searchModel.Status, "r", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Flow", searchModel.Flow, "r", ref whereStatement, param);

            if (searchModel.StartDate != null & searchModel.EndDate != null)
            {
                HqlStatementHelper.AddBetweenStatement("CreateDate", searchModel.StartDate, searchModel.EndDate, "r", ref whereStatement, param);
            }
            else if (searchModel.StartDate != null & searchModel.EndDate == null)
            {
                HqlStatementHelper.AddGeStatement("CreateDate", searchModel.StartDate, "r", ref whereStatement, param);
            }
            else if (searchModel.StartDate == null & searchModel.EndDate != null)
            {
                HqlStatementHelper.AddLeStatement("CreateDate", searchModel.EndDate, "r", ref whereStatement, param);
            }
            if (command.SortDescriptors.Count > 0)
            {
                if (command.SortDescriptors[0].Member == "ReceiptMasterStatusDescription")
                {
                    command.SortDescriptors[0].Member = "Status";
                }
            }

            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);

            if (command.SortDescriptors.Count == 0)
            {
                sortingStatement = " order by r.CreateDate desc";
            }
            SearchStatementModel searchStatementModel = new SearchStatementModel();

            searchStatementModel.SelectCountStatement = selectCountStatement;
            searchStatementModel.SelectStatement      = selectStatement;
            searchStatementModel.WhereStatement       = whereStatement;
            searchStatementModel.SortingStatement     = sortingStatement;
            searchStatementModel.Parameters           = param.ToArray <object>();

            return(searchStatementModel);
        }
예제 #5
0
        public ActionResult _AjaxRecDetList(GridCommand command, ReceiptMasterSearchModel searchModel)
        {
            if (!this.CheckSearchModelIsNull(searchModel))
            {
                return(PartialView(new GridModel(new List <ReceiptDetail>())));
            }
            string whereStatement = " and exists (select 1 from ReceiptMaster  as r where r.OrderSubType = " + (int)com.Sconit.CodeMaster.OrderSubType.Return + " and r.RecNo=d.RecNo) ";
            ProcedureSearchStatementModel procedureSearchStatementModel = PrepareSearchDetailStatement(command, searchModel, whereStatement);

            return(PartialView(GetAjaxPageDataProcedure <ReceiptDetail>(procedureSearchStatementModel, command)));
        }
예제 #6
0
        public ActionResult _AjaxList(GridCommand command, ReceiptMasterSearchModel searchModel)
        {
            if (!this.CheckSearchModelIsNull(searchModel))
            {
                return(PartialView(new GridModel(new List <ReceiptMaster>())));
            }
            string whereStatement = " and r.OrderSubType=" + (int)com.Sconit.CodeMaster.OrderSubType.Return;
            ProcedureSearchStatementModel procedureSearchStatementModel = this.PrepareProcedureSearchStatement(command, searchModel, whereStatement);

            return(PartialView(GetAjaxPageDataProcedure <ReceiptMaster>(procedureSearchStatementModel, command)));
        }
예제 #7
0
 public ActionResult Edit(GridCommand command, ReceiptMasterSearchModel searchModel)
 {
     if (string.IsNullOrEmpty(searchModel.ReceiptNo))
     {
         return(HttpNotFound());
     }
     else
     {
         ViewBag.ReceiptNo = searchModel.ReceiptNo;
         ReceiptMaster rm = base.genericMgr.FindById <ReceiptMaster>(searchModel.ReceiptNo);
         return(View(rm));
     }
 }
예제 #8
0
 public ActionResult DetailList(GridCommand command, ReceiptMasterSearchModel searchModel)
 {
     TempData["ReceiptMasterSearchModel"] = searchModel;
     if (this.CheckSearchModelIsNull(searchModel))
     {
         ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
         return(View());
     }
     else
     {
         SaveWarningMessage(Resources.ErrorMessage.Errors_NoConditions);
         return(View(new List <ReceiptDetail>()));
     }
 }
예제 #9
0
        public ActionResult List(GridCommand command, ReceiptMasterSearchModel searchModel)
        {
            SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);

            if (this.CheckSearchModelIsNull(searchCacheModel.SearchObject))
            {
                TempData["_AjaxMessage"] = "";
            }
            else
            {
                SaveWarningMessage(Resources.ErrorMessage.Errors_NoConditions);
            }
            ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
            return(View());
        }
예제 #10
0
        private string PrepareSearchDetailStatement(GridCommand command, ReceiptMasterSearchModel searchModel)
        {
            StringBuilder Sb             = new StringBuilder();
            string        whereStatement = " select  d from ReceiptDetail as d  where exists (select 1 from ReceiptMaster  as o where o.OrderType in (" + (int)com.Sconit.CodeMaster.OrderType.CustomerGoods + "," + (int)com.Sconit.CodeMaster.OrderType.Procurement
                                           + "," + (int)com.Sconit.CodeMaster.OrderType.SubContract + ")"
                                           + " and o.OrderSubType = " + (int)com.Sconit.CodeMaster.OrderSubType.Normal + " and o.ReceiptNo=d.ReceiptNo ";

            Sb.Append(whereStatement);


            if (searchModel.Status != null)
            {
                Sb.Append(string.Format(" and o.Status = '{0}'", searchModel.Status));
            }
            if (!string.IsNullOrEmpty(searchModel.ReceiptNo))
            {
                Sb.Append(string.Format(" and o.ReceiptNo like '{0}%'", searchModel.ReceiptNo));
            }
            if (!string.IsNullOrEmpty(searchModel.PartyFrom))
            {
                Sb.Append(string.Format(" and o.PartyFrom = '{0}'", searchModel.PartyFrom));
            }
            if (!string.IsNullOrEmpty(searchModel.PartyTo))
            {
                Sb.Append(string.Format(" and o.PartyTo = '{0}'", searchModel.PartyTo));
            }
            string str = Sb.ToString();

            //SecurityHelper.AddPartyFromPermissionStatement(ref str, "o", "PartyFrom", com.Sconit.CodeMaster.OrderType.Procurement, true);
            SecurityHelper.AddPartyFromAndPartyToPermissionStatement(ref str, "o", "Type", "o", "PartyFrom", "o", "PartyTo", com.Sconit.CodeMaster.OrderType.Procurement, true);

            if (searchModel.StartDate != null & searchModel.EndDate != null)
            {
                Sb.Append(string.Format(" and o.CreateDate between '{0}' and '{1}'", searchModel.StartDate, searchModel.EndDate));
                // HqlStatementHelper.AddBetweenStatement("StartTime", searchModel.DateFrom, searchModel.DateTo, "o", ref whereStatement, param);
            }
            else if (searchModel.StartDate != null & searchModel.EndDate == null)
            {
                Sb.Append(string.Format(" and o.CreateDate >= '{0}'", searchModel.StartDate));
            }
            else if (searchModel.StartDate == null & searchModel.EndDate != null)
            {
                Sb.Append(string.Format(" and o.CreateDate <= '{0}'", searchModel.EndDate));
            }

            if (!string.IsNullOrEmpty(searchModel.WMSNo))
            {
                Sb.Append(string.Format(" and  o.WMSNo like '%{0}%'", searchModel.WMSNo));
            }

            Sb.Append(" )");

            if (!string.IsNullOrEmpty(searchModel.Item))
            {
                Sb.Append(string.Format(" and  d.Item like '{0}%'", searchModel.Item));
            }

            if (searchModel.Flow != null)
            {
                Sb.Append(string.Format(" and d.Flow = '{0}'", searchModel.Flow));
            }

            return(Sb.ToString());
        }
예제 #11
0
        private ProcedureSearchStatementModel PrepareSearchDetailStatement(GridCommand command, ReceiptMasterSearchModel searchModel, string whereStatement)
        {
            List <ProcedureParameter> paraList     = new List <ProcedureParameter>();
            List <ProcedureParameter> pageParaList = new List <ProcedureParameter>();

            paraList.Add(new ProcedureParameter {
                Parameter = searchModel.ReceiptNo, Type = NHibernate.NHibernateUtil.String
            });
            paraList.Add(new ProcedureParameter {
                Parameter = searchModel.IpNo, Type = NHibernate.NHibernateUtil.String
            });
            paraList.Add(new ProcedureParameter {
                Parameter = searchModel.Status, Type = NHibernate.NHibernateUtil.Int16
            });
            paraList.Add(new ProcedureParameter
            {
                Parameter = (int)com.Sconit.CodeMaster.OrderType.CustomerGoods + "," + (int)com.Sconit.CodeMaster.OrderType.Procurement
                            + "," + (int)com.Sconit.CodeMaster.OrderType.ScheduleLine,
                Type = NHibernate.NHibernateUtil.String
                       //  + "," + (int)com.Sconit.CodeMaster.OrderType.SubContract
            });
            paraList.Add(new ProcedureParameter {
                Parameter = searchModel.PartyFrom, Type = NHibernate.NHibernateUtil.String
            });
            paraList.Add(new ProcedureParameter {
                Parameter = searchModel.PartyTo, Type = NHibernate.NHibernateUtil.String
            });
            paraList.Add(new ProcedureParameter {
                Parameter = searchModel.StartDate, Type = NHibernate.NHibernateUtil.DateTime
            });
            paraList.Add(new ProcedureParameter {
                Parameter = searchModel.EndDate, Type = NHibernate.NHibernateUtil.DateTime
            });
            paraList.Add(new ProcedureParameter {
                Parameter = searchModel.Dock, Type = NHibernate.NHibernateUtil.String
            });
            paraList.Add(new ProcedureParameter {
                Parameter = searchModel.Item, Type = NHibernate.NHibernateUtil.String
            });
            paraList.Add(new ProcedureParameter {
                Parameter = searchModel.WMSNo, Type = NHibernate.NHibernateUtil.String
            });
            paraList.Add(new ProcedureParameter {
                Parameter = searchModel.ManufactureParty, Type = NHibernate.NHibernateUtil.String
            });
            paraList.Add(new ProcedureParameter {
                Parameter = searchModel.Flow, Type = NHibernate.NHibernateUtil.String
            });
            paraList.Add(new ProcedureParameter {
                Parameter = true, Type = NHibernate.NHibernateUtil.Int64
            });
            paraList.Add(new ProcedureParameter {
                Parameter = CurrentUser.Id, Type = NHibernate.NHibernateUtil.Int32
            });
            paraList.Add(new ProcedureParameter {
                Parameter = whereStatement, Type = NHibernate.NHibernateUtil.String
            });


            if (command.SortDescriptors.Count > 0)
            {//RecNo,ItemDesc,RecQty,LocTo
                if (command.SortDescriptors[0].Member == "StatusDescription")
                {
                    command.SortDescriptors[0].Member = "Status";
                }
                if (command.SortDescriptors[0].Member == "ReceiptNo")
                {
                    command.SortDescriptors[0].Member = "RecNo";
                }
                if (command.SortDescriptors[0].Member == "ItemDescription")
                {
                    command.SortDescriptors[0].Member = "ItemDesc";
                }
                if (command.SortDescriptors[0].Member == "ReceivedQty")
                {
                    command.SortDescriptors[0].Member = "RecQty";
                }
                if (command.SortDescriptors[0].Member == "LocationTo")
                {
                    command.SortDescriptors[0].Member = "LocTo";
                }
                if (command.SortDescriptors[0].Member == "MastType")
                {
                    command.SortDescriptors[0].Member = "MastOrderType";
                }
            }
            pageParaList.Add(new ProcedureParameter {
                Parameter = command.SortDescriptors.Count > 0 ? command.SortDescriptors[0].Member : null, Type = NHibernate.NHibernateUtil.String
            });
            pageParaList.Add(new ProcedureParameter {
                Parameter = command.SortDescriptors.Count > 0 ? (command.SortDescriptors[0].SortDirection == ListSortDirection.Descending ? "desc" : "asc") : "asc", Type = NHibernate.NHibernateUtil.String
            });
            pageParaList.Add(new ProcedureParameter {
                Parameter = command.PageSize, Type = NHibernate.NHibernateUtil.Int32
            });
            pageParaList.Add(new ProcedureParameter {
                Parameter = command.Page, Type = NHibernate.NHibernateUtil.Int32
            });

            var procedureSearchStatementModel = new ProcedureSearchStatementModel();

            procedureSearchStatementModel.Parameters      = paraList;
            procedureSearchStatementModel.PageParameters  = pageParaList;
            procedureSearchStatementModel.CountProcedure  = "USP_Search_RecDetCount";
            procedureSearchStatementModel.SelectProcedure = "USP_Search_RecDet";

            return(procedureSearchStatementModel);
        }