public ActionResult _AjaxList(GridCommand command, ReceiptMasterSearchModel searchModel)
 {
     if (!this.CheckSearchModelIsNull(searchModel))
     {
         return PartialView(new GridModel(new List<ReceiptMaster>()));
     }
     SearchStatementModel searchStatementModel = this.PrepareSearchStatement(command, searchModel);
     return PartialView(GetAjaxPageData<ReceiptMaster>(searchStatementModel, command));
 }
 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));
 }
        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));
        }
 public ActionResult _AjaxList(GridCommand command, ReceiptMasterSearchModel searchModel)
 {
     this.GetCommand(ref command, searchModel);
     if (!this.CheckSearchModelIsNull(searchModel))
     {
         return PartialView(new GridModel(new List<ReceiptMaster>()));
     }
     string whereStatement = string.Empty;
     ProcedureSearchStatementModel procedureSearchStatementModel = this.PrepareProcedureSearchStatement(command, searchModel, whereStatement);
     return PartialView(GetAjaxPageDataProcedure<ReceiptMaster>(procedureSearchStatementModel, command));
 }
 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);
     }
 }
 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();
 }
 public ActionResult List(GridCommand command, ReceiptMasterSearchModel searchModel)
 {
     SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
     if (this.CheckSearchModelIsNull(searchCacheModel.SearchObject))
     {
         TempData["_AjaxMessage"] = "";
     }
     else
     {
         SaveWarningMessage(Resources.SYS.ErrorMessage.Errors_NoConditions);
     }
     if (searchCacheModel.isBack == true)
     {
         ViewBag.Page = searchCacheModel.Command.Page == 0 ? 1 : searchCacheModel.Command.Page;
     }
     ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
     ViewBag.OrderSubType = ((ReceiptMasterSearchModel)searchCacheModel.SearchObject).OrderSubType;
     return View();
 }
        public ActionResult _AjaxNewList(GridCommand command, ReceiptMasterSearchModel searchModel)
        {
            if (command.SortDescriptors.Count > 0)
            {
                if (command.SortDescriptors[0].Member == "ExternalOrderNo")
                {
                    command.SortDescriptors[0].Member = "ExtNo";
                }
                else if (command.SortDescriptors[0].Member == "OrderedQty")
                {
                    command.SortDescriptors[0].Member = "OrderQty";
                }
                else if (command.SortDescriptors[0].Member == "MastPartyFrom")
                {
                    command.SortDescriptors[0].Member = "PartyFrom";
                }
                else if (command.SortDescriptors[0].Member == "MastPartyTo")
                {
                    command.SortDescriptors[0].Member = "PartyTo";
                }
                else if (command.SortDescriptors[0].Member == "LocationTo")
                {
                    command.SortDescriptors[0].Member = "LocFrom";
                }
            }
            SqlParameter[] parameters = new SqlParameter[12];
            parameters[0] = new SqlParameter("@OrderNo", System.Data.SqlDbType.VarChar,50);
            parameters[0].Value = searchModel.OrderNo;

            parameters[1] = new SqlParameter("@LocFrom", System.Data.SqlDbType.VarChar, 50);
            parameters[1].Value = searchModel.LocFrom;

            parameters[2] = new SqlParameter("@Item", System.Data.SqlDbType.VarChar, 50);
            parameters[2].Value = searchModel.Item;

            parameters[3] = new SqlParameter("@ExtNo", System.Data.SqlDbType.VarChar, 50);
            parameters[3].Value = searchModel.ExtNo;

            parameters[4] = new SqlParameter("@ExtSeq", System.Data.SqlDbType.VarChar, 50);
            parameters[4].Value = searchModel.ExtSeq;

            parameters[5] = new SqlParameter("@StartDate", System.Data.SqlDbType.DateTime);
            parameters[5].Value = searchModel.StartDate;

            parameters[6] = new SqlParameter("@EndDate", System.Data.SqlDbType.DateTime);
            parameters[6].Value = searchModel.EndDate;

            parameters[7] = new SqlParameter("@SortCloumn", System.Data.SqlDbType.VarChar, 50);
            parameters[7].Value = command.SortDescriptors.Count > 0 ? command.SortDescriptors[0].Member : string.Empty;

            parameters[8] = new SqlParameter("@SortRule", System.Data.SqlDbType.VarChar, 50);
            parameters[8].Value = command.SortDescriptors.Count > 0 ? command.SortDescriptors[0].SortDirection == ListSortDirection.Descending ? "desc" : "asc" : string.Empty;

            parameters[9] = new SqlParameter("@PageSize", SqlDbType.Int);
            parameters[9].Value = command.PageSize;

            parameters[10] = new SqlParameter("@Page", SqlDbType.Int);
            parameters[10].Value = command.Page;

            parameters[11] = new SqlParameter("@RowCount", System.Data.SqlDbType.VarChar, 50);
            parameters[11].Direction = ParameterDirection.Output;

            IList<OrderDetail> returList = new List<OrderDetail>();
            try
            {
                DataSet dataSet = sqlDao.GetDatasetByStoredProcedure("USP_Search_CreateRequisitionDetail", parameters, false);

                //det.Id,det.OrderNo,det.ExtNo,det.ExtSeq,det.Item,det.ItemDesc,det.RefItemCode,det.Uom,det.UC,det.LocFrom,
                //        //det.LocTo,det.OrderQty,det.RecQty,det.CreateDate,fm.Code,fm.Desc1,fm.PartyFrom,fm.PartyTo,fd.Container,fd.ContainerDesc
                if (dataSet.Tables[0] != null && dataSet.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in dataSet.Tables[0].Rows)
                    {
                        //row.ItemArray[0].ToString()
                        OrderDetail det = new OrderDetail();
                        det.Id = Convert.ToInt32(row.ItemArray[0].ToString());
                        det.OrderNo = row.ItemArray[1].ToString();
                        det.ExternalOrderNo = row.ItemArray[2].ToString();
                        det.ExternalSequence = row.ItemArray[3].ToString();
                        det.Item = row.ItemArray[4].ToString();
                        det.ItemDescription = row.ItemArray[5].ToString();
                        det.ReferenceItemCode = row.ItemArray[6].ToString();
                        det.Uom = row.ItemArray[7].ToString();
                        det.BaseUom = row.ItemArray[7].ToString();
                        det.UnitCount =  Convert.ToDecimal(row.ItemArray[8]);
                        det.MinUnitCount = Convert.ToDecimal(row.ItemArray[8]);
                        det.LocationTo = row.ItemArray[9].ToString();
                        det.OrderedQty = Convert.ToDecimal(row.ItemArray[11]);
                        det.RejectedQty = Convert.ToDecimal(row.ItemArray[12]);
                        det.CreateDate = Convert.ToDateTime(row.ItemArray[13]);
                        det.Flow = row.ItemArray[14].ToString();
                        det.FlowDescription = row.ItemArray[15].ToString();
                        det.MastPartyFrom = row.ItemArray[16].ToString();
                        det.PartyTo = row.ItemArray[17].ToString();
                        det.Container = row.ItemArray[18].ToString();
                        det.ContainerDescription = row.ItemArray[19].ToString();
                        returList.Add(det);
                    }
                }
            }
            catch (BusinessException be)
            {
                SaveBusinessExceptionMessage(be);
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    if (ex.InnerException.InnerException != null)
                    {
                        SaveErrorMessage(ex.InnerException.InnerException.Message);
                    }
                    else
                    {
                        SaveErrorMessage(ex.InnerException.Message);
                    }
                }
                else
                {
                    SaveErrorMessage(ex.Message);
                }
            }
            GridModel<OrderDetail> gridModel = new GridModel<OrderDetail>();
            gridModel.Total = string.IsNullOrWhiteSpace(parameters[11].Value.ToString()) ? 0 : Convert.ToInt32(parameters[11].Value);
            gridModel.Data = returList;
            TempData["DetailList"] = returList;
            return PartialView(gridModel);
        }
 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>());
     }
 }
 public ActionResult _AjaxList(GridCommand command, ReceiptMasterSearchModel searchModel)
 {
     if (!this.CheckSearchModelIsNull(searchModel))
     {
         return PartialView(new GridModel(new List<ReceiptMaster>()));
     }
     if (searchModel.OrderSubType == (int)com.Sconit.CodeMaster.OrderSubType.Return)
     {
         string centre = searchModel.PartyFrom;
         searchModel.PartyFrom = searchModel.PartyTo;
         searchModel.PartyTo = centre;
     }
     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=" + searchModel.OrderSubType;
     ProcedureSearchStatementModel procedureSearchStatementModel = this.PrepareProcedureSearchStatement(command, searchModel, whereStatement);
     return PartialView(GetAjaxPageDataProcedure<ReceiptMaster>(procedureSearchStatementModel, command));
 }
 public ActionResult NewList(GridCommand command, ReceiptMasterSearchModel searchModel)
 {
     SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
     ViewBag.PageSize = 50;
     return View();
 }
 public ActionResult _AjaxRecDetList(GridCommand command, ReceiptMasterSearchModel searchModel)
 {
     if (!this.CheckSearchModelIsNull(searchModel))
     {
         return PartialView(new GridModel(new List<ReceiptDetail>()));
     }
     string whereStatement = null;
     //string whereStatement = " where  i.Type = " + (int)com.Sconit.CodeMaster.OrderSubType.Normal + "";
     ProcedureSearchStatementModel procedureSearchStatementModel = PrepareSearchDetailStatement(command, searchModel, whereStatement);
     return PartialView(GetAjaxPageDataProcedure<ReceiptDetail>(procedureSearchStatementModel, command));
 }
        private SearchStatementModel PrepareSearchStatement(GridCommand command, ReceiptMasterSearchModel searchModel)
        {
            string whereStatement = " where r.OrderType =" + (int)com.Sconit.CodeMaster.OrderType.Production + "and exists(select 1 from ReceiptDetail as d where d.ReceiptNo=r.ReceiptNo";
            if (!string.IsNullOrEmpty(searchModel.OrderNo))
            {
                whereStatement += " and d.OrderNo='" + searchModel.OrderNo + "'";
            }
            else if (!string.IsNullOrEmpty(searchModel.Item))
                whereStatement += " and d.Item = '" + searchModel.Item + "'";
            whereStatement += ")";
            IList<object> param = new List<object>();

            HqlStatementHelper.AddLikeStatement("ReceiptNo", searchModel.ReceiptNo, HqlStatementHelper.LikeMatchMode.Anywhere, "r", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Status", searchModel.Status, "r", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Flow", searchModel.Flow, "r", ref whereStatement, param);
           // HqlStatementHelper.AddLikeStatement("OrderNo", searchModel.OrderNo, HqlStatementHelper.LikeMatchMode.Anywhere, "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 = "select count(*) from ReceiptMaster as r";
            searchStatementModel.SelectStatement = "select r from ReceiptMaster as r";
            searchStatementModel.WhereStatement = whereStatement;
            searchStatementModel.SortingStatement = sortingStatement;
            searchStatementModel.Parameters = param.ToArray<object>();

            return searchStatementModel;
        }
        public void ExportMstr(ReceiptMasterSearchModel searchModel)
        {
            int value = Convert.ToInt32(base.systemMgr.GetEntityPreferenceValue(EntityPreference.CodeEnum.MaxRowSizeOnPage));
            GridCommand command = new GridCommand();
            command.Page = 1;
            command.PageSize = !this.CheckSearchModelIsNull(searchModel) ? 0 : value;
            if (!this.CheckSearchModelIsNull(searchModel))
            {
                return;
            }

            string whereStatement = " ";
            ProcedureSearchStatementModel procedureSearchStatementModel = this.PrepareProcedureSearchStatement(command, searchModel, whereStatement);
            ExportToXLS<ReceiptMaster>("ProductionReceiptOrderMaster.xls", GetAjaxPageDataProcedure<ReceiptMaster>(procedureSearchStatementModel, command).Data.ToList());
        }
        public void ExportMstr(ReceiptMasterSearchModel searchModel)
        {
            int value = Convert.ToInt32(base.systemMgr.GetEntityPreferenceValue(EntityPreference.CodeEnum.MaxRowSizeOnPage));
            GridCommand command = new GridCommand();
            command.Page = 1;
            command.PageSize = !this.CheckSearchModelIsNull(searchModel) ? 0 : value;

            if (!this.CheckSearchModelIsNull(searchModel))
            {
                return ;
            }
            if (searchModel.OrderSubType == (int)com.Sconit.CodeMaster.OrderSubType.Return)
            {
                string centre = searchModel.PartyFrom;
                searchModel.PartyFrom = searchModel.PartyTo;
                searchModel.PartyTo = centre;
            }

            string whereStatement = string.Empty;
            ProcedureSearchStatementModel procedureSearchStatementModel = this.PrepareProcedureSearchStatement(command, searchModel, whereStatement);
            ExportToXLS<ReceiptMaster>("ReceiptOrderMaster.xls", GetAjaxPageDataProcedure<ReceiptMaster>(procedureSearchStatementModel, command).Data.ToList());
        }
 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));
 }
 public void ExportXLS(ReceiptMasterSearchModel searchModel)
 {
     int value = Convert.ToInt32(base.systemMgr.GetEntityPreferenceValue(EntityPreference.CodeEnum.MaxRowSizeOnPage));
     GridCommand command = new GridCommand();
     command.Page = 1;
     command.PageSize = !this.CheckSearchModelIsNull(searchModel) ? 0 : value;
     string whereStatement = null;
     ProcedureSearchStatementModel procedureSearchStatementModel = PrepareSearchDetailStatement(command, searchModel, whereStatement);
     var ReceiptDetailLists = GetAjaxPageDataProcedure<ReceiptDetail>(procedureSearchStatementModel, command);
     List<ReceiptDetail> ReceiptDetailList = ReceiptDetailLists.Data.ToList();
     ExportToXLS<ReceiptDetail>("DailsOfReceiptMaster.xls", ReceiptDetailList);
 }
        private ProcedureSearchStatementModel PrepareSearchDetailStatement(GridCommand command, ReceiptMasterSearchModel searchModel, string whereStatement)
        {
            searchModel.OrderTypes=string.IsNullOrWhiteSpace(searchModel.OrderTypes)?(int)com.Sconit.CodeMaster.OrderType.Procurement + "," + (int)com.Sconit.CodeMaster.OrderType.Transfer + ","
                 + (int)com.Sconit.CodeMaster.OrderType.ScheduleLine: searchModel.OrderTypes;
            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 = searchModel.OrderTypes,
                Type = NHibernate.NHibernateUtil.String
                // + (int)com.Sconit.CodeMaster.OrderType.SubContractTransfer + ","+ (int)com.Sconit.CodeMaster.OrderType.SubContract + ","+ (int)com.Sconit.CodeMaster.OrderType.CustomerGoods + ","
            });
            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 = false, 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)
            {
                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;
        }
        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 with(nolock) where r.RecNo=d.RecNo) ";
            if (!string.IsNullOrWhiteSpace(searchModel.OrderNo))
            {
                whereStatement += " and d.OrderNo='" + searchModel.OrderNo + "' ";
            }
            //string whereStatement = " where  i.Type = " + (int)com.Sconit.CodeMaster.OrderSubType.Normal + "";
            //ProcedureSearchStatementModel procedureSearchStatementModel = PrepareSearchDetailStatement(command, searchModel, whereStatement);
            //return PartialView(GetAjaxPageDataProcedure<ReceiptDetail>(procedureSearchStatementModel, command));
            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.ReceiptStatus, 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);
        }
 public ActionResult DetailList(GridCommand command, ReceiptMasterSearchModel searchModel)
 {
     SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
     ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
     if (!this.CheckSearchModelIsNull(searchModel))
     {
         SaveWarningMessage(Resources.ErrorMessage.Errors_NoConditions);
     }
     return View();
 }
        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.OrderSubType in (" + (int)com.Sconit.CodeMaster.OrderSubType.Return + ")"
                                     + "and  o.OrderType in (" + (int)com.Sconit.CodeMaster.OrderType.CustomerGoods + "," + (int)com.Sconit.CodeMaster.OrderType.Procurement
                                    + "," + (int)com.Sconit.CodeMaster.OrderType.SubContract + ")"
                                    + " and o.ReceiptNo=d.ReceiptNo ";

            Sb.Append(whereStatement);

            if (searchModel.Flow != null)
            {
                Sb.Append(string.Format(" and o.Flow = '{0}'", searchModel.Flow));
            }
            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", "PartyTo", com.Sconit.CodeMaster.OrderType.Procurement, true);
            SecurityHelper.AddPartyFromAndPartyToPermissionStatement(ref str, "o", "Type", "o", "PartyTo", "o", "PartyFrom", 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));

            }

            return Sb.ToString();
        }
        public void SaveToClientMulti(ReceiptMasterSearchModel searchModel)
        {
            if (!this.CheckSearchModelIsNull(searchModel))
            {
                return;
            }
            GridCommand command = new GridCommand();
            command.Page = 1;
            command.PageSize = 10000;
            string whereStatement = null;
            ProcedureSearchStatementModel procedureSearchStatementModel = PrepareSearchDetailStatement(command, searchModel, whereStatement);
            IList<ReceiptDetail> receiptDetailLists =  GetAjaxPageDataProcedure<ReceiptDetail>(procedureSearchStatementModel, command).Data.ToList();
            var receiptDetailSumLists = from p in receiptDetailLists
                                    group p by new
                                        {
                                            p.Item,
                                            p.ItemDescription,
                                            p.ReferenceItemCode,
                                            p.Uom,
                                            p.UnitCount,
                                        }
                                        into g
                                        select new ReceiptDetail
                                      {
                                          Item = g.Key.Item,
                                          ItemDescription = g.Key.ItemDescription,
                                          ReferenceItemCode = g.Key.ReferenceItemCode,
                                          Uom = g.Key.Uom,
                                          UnitCount = g.Key.UnitCount,
                                          ReceivedQty=g.Sum(p=>p.ReceivedQty)
                                      };
                                                                        
            IList<object> data = new List<object>();
            data.Add(receiptDetailSumLists.ToList());
            data.Add(CurrentUser.FullName);
            data.Add(searchModel.Flow);
            //2013/11/01 20:12:56 ~ 2013/11/12 12:33:34
            var timeSpan = (searchModel.StartDate == null ? "" : Convert.ToDateTime(searchModel.StartDate).ToString("yyyy/MM/dd HH:mm")) +
                           " ~  " + (searchModel.EndDate == null ? "" : Convert.ToDateTime(searchModel.EndDate).ToString("yyyy/MM/dd HH:mm"));
            data.Add(timeSpan);
            reportGen.WriteToClient("REC_TransferDetail.xls", data, string.Format("{0}{1}{2}","TransferDetailOfFlow", searchModel.Flow ,".xls"));

        }
        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;
        }
 public ActionResult _AjaxLogList(GridCommand command, ReceiptMasterSearchModel searchModel)
 {
    SearchStatementModel searchStatementModel = this.PrepareSearchStatement(command, searchModel);
    return PartialView(GetAjaxPageData<DistributionRequisition>(searchStatementModel, command));
 }
        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.OrderNo, Type = NHibernate.NHibernateUtil.String });
            paraList.Add(new ProcedureParameter { Parameter = searchModel.Status, Type = NHibernate.NHibernateUtil.Int16 });
            if (searchModel.GoodsReceiptOrderType.HasValue && searchModel.GoodsReceiptOrderType > 0)
            {
                paraList.Add(new ProcedureParameter { Parameter = searchModel.GoodsReceiptOrderType, Type = NHibernate.NHibernateUtil.String });
            }
            else
            {
                paraList.Add(new ProcedureParameter
                {
                    Parameter = (int)com.Sconit.CodeMaster.OrderType.CustomerGoods + "," + (int)com.Sconit.CodeMaster.OrderType.Procurement
                        + "," + (int)com.Sconit.CodeMaster.OrderType.SubContract + "," + (int)com.Sconit.CodeMaster.OrderType.Transfer + ","
                        + (int)com.Sconit.CodeMaster.OrderType.SubContractTransfer + "," + (int)com.Sconit.CodeMaster.OrderType.ScheduleLine,
                    Type = NHibernate.NHibernateUtil.String
                });

            }
            paraList.Add(new ProcedureParameter { Parameter = searchModel.OrderSubType, Type = NHibernate.NHibernateUtil.Int16 });
            paraList.Add(new ProcedureParameter { Parameter = searchModel.IpDetailType, Type = NHibernate.NHibernateUtil.Int16 });
            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.ExternalReceiptNo, 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 = false, 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)
            {
                if (command.SortDescriptors[0].Member == "StatusDescription")
                {
                    command.SortDescriptors[0].Member = "Status";
                }
            }
            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;
        }
        private StringBuilder StringBuilderPrepareSearchStatement(GridCommand command, ReceiptMasterSearchModel searchModel)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(@" select det.Id,det.OrderNo,det.ExtNo,det.ExtSeq,det.Item,det.ItemDesc,det.RefItemCode,det.Uom,det.UC,det.LocFrom,det.LocTo,det.OrderQty,det.RecQty,det.CreateDate,fm.Code,fm.Desc1,fm.PartyFrom,fm.PartyTo,fd.Container,fd.ContainerDesc
from ORD_OrderDet_3 as det
inner join ORD_OrderMstr_3 as om on det.OrderNo=om.OrderNo
inner join SCM_FlowDet as fd on det.Item=fd.Item
inner join  SCM_FlowMstr as fm on fm.Code=fd.Flow and fm.LocTo=det.LocFrom
inner join SCM_FlowStrategy as fs on fs.Flow=fm.Code
left join LOG_DistributionRequisition as ld on ld.OrderDetId=det.Id
left join LOG_DistributionRequisition as ld2 on ld2.ExtNo=det.ExtNo and ld2.ExtSeq=det.ExtSeq
where fm.Type=1 and fs.Strategy in(3,4) and ld.Id is null and ld2.Id is null and om.Status in(2,1) and det.OrderQty>det.RecQty ");

            if (!string.IsNullOrEmpty(searchModel.OrderNo))
            {
                sb.Append(string.Format(" and det.OrderNo = '{0}'", searchModel.OrderNo));
            }
            if (!string.IsNullOrEmpty(searchModel.LocFrom))
            {
                sb.Append(string.Format(" and det.LocFrom = '{0}'", searchModel.LocFrom));
            }
            if (!string.IsNullOrEmpty(searchModel.Item))
            {
                sb.Append(string.Format(" and det.Item='{0}'", searchModel.Item));
            }
            if (!string.IsNullOrEmpty(searchModel.ExtNo))
            {
                sb.Append(string.Format(" and det.ExtNo='{0}'", searchModel.ExtNo));
            }
            if (!string.IsNullOrEmpty(searchModel.ExtSeq))
            {
                sb.Append(string.Format(" and det.ExtSeq='{0}'", searchModel.ExtSeq));
            }
            if (searchModel.StartDate != null & searchModel.EndDate != null)
            {
                sb.Append(string.Format(" and  det.CreateDate between '{0}' and '{1}'", searchModel.StartDate, searchModel.EndDate));
            }
            else if (searchModel.StartDate != null & searchModel.EndDate == null)
            {
                sb.Append(string.Format(" and det.CreateDate >= '{0}'", searchModel.StartDate));
            }
            else if (searchModel.StartDate == null & searchModel.EndDate != null)
            {
                sb.Append(string.Format(" and det.CreateDate <= '{0}'", searchModel.EndDate));
            }
           
           
            if (command.SortDescriptors.Count == 0)
            {
                sb.Append(" order by CreateDate asc");
            }
            else
            {
                sb.Append(HqlStatementHelper.GetSortingStatement(command.SortDescriptors));
            }
            return sb;
        }
        public ActionResult _AjaxList(GridCommand command, ReceiptMasterSearchModel searchModel)
        {
            this.GetCommand(ref command, searchModel);
            if (!this.CheckSearchModelIsNull(searchModel))
            {
                return PartialView(new GridModel(new List<ReceiptMaster>()));
            }
            if (searchModel.OrderSubType == (int)com.Sconit.CodeMaster.OrderSubType.Return)
            {
                string centre = searchModel.PartyFrom;
                searchModel.PartyFrom = searchModel.PartyTo;
                searchModel.PartyTo = centre;
            }

            string whereStatement =string.Empty;
            ProcedureSearchStatementModel procedureSearchStatementModel = this.PrepareProcedureSearchStatement(command, searchModel, whereStatement);
            return PartialView(GetAjaxPageDataProcedure<ReceiptMaster>(procedureSearchStatementModel, command));
        }
        private SearchStatementModel PrepareSearchStatement(GridCommand command, ReceiptMasterSearchModel searchModel)
        {
            string whereStatement = string.Empty;

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

            HqlStatementHelper.AddEqStatement("OrderNo", searchModel.OrderNo, "d", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("ExternalOrderNo", searchModel.ExtNo, "d", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("LocationTo", searchModel.LocFrom, "d", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Item", searchModel.Item, "d", ref whereStatement, param);
            if (searchModel.StartDate != null & searchModel.EndDate != null)
            {
                HqlStatementHelper.AddBetweenStatement("CreateDate", searchModel.StartDate, searchModel.EndDate, "d", ref whereStatement, param);
            }
            else if (searchModel.StartDate != null & searchModel.EndDate == null)
            {
                HqlStatementHelper.AddGeStatement("CreateDate", searchModel.StartDate, "d", ref whereStatement, param);
            }
            else if (searchModel.StartDate == null & searchModel.EndDate != null)
            {
                HqlStatementHelper.AddLeStatement("CreateDate", searchModel.EndDate, "d", ref whereStatement, param);
            }
            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);

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

            return searchStatementModel;
        }
        private ProcedureSearchStatementModel PrepareProcedureSearchStatement(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.Production,
                Type = NHibernate.NHibernateUtil.String
            });

            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 = false, Type = NHibernate.NHibernateUtil.Boolean });
            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)
            {
                if (command.SortDescriptors[0].Member == "ReceiptMasterStatusDescription")
                {
                    command.SortDescriptors[0].Member = "Status";
                }
            }

            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_RecMstrCount";
            procedureSearchStatementModel.SelectProcedure = "USP_Search_RecMstr";

            return procedureSearchStatementModel;
        }
        public ActionResult DetailList(GridCommand command, ReceiptMasterSearchModel searchModel)
        {
            TempData["ReceiptMasterSearchModel"] = searchModel;
            if (this.CheckSearchModelIsNull(searchModel))
            {
                TempData["_AjaxMessage"] = "";

                IList<ReceiptDetail> list = base.genericMgr.FindAll<ReceiptDetail>(PrepareSearchDetailStatement(command, searchModel)); //GetPageData<OrderDetail>(searchStatementModel, command);

                int value = Convert.ToInt32(base.systemMgr.GetEntityPreferenceValue(EntityPreference.CodeEnum.MaxRowSizeOnPage));
                if (list.Count > value)
                {
                    SaveWarningMessage(string.Format("数据超过{0}行", value));
                }
                return View(list.Take(value));
            }
            else
            {
                SaveWarningMessage(Resources.ErrorMessage.Errors_NoConditions);
                return View(new List<ReceiptDetail>());
            }
        }