public JsonResult RefundsProductSearchGridDataRequested(DateTime?refundsReportDate) { if (!refundsReportDate.HasValue) { refundsReportDate = DateTime.Now; } // Get both the grid Model and the data Model // The data model in our case is an autogenerated linq2sql database based on Northwind. var gridModel = new SkladJqGridModel(); var datacontextModel = new SkladDataContext(); SetUpRefundsProductLineColumns(gridModel.ProductLineGrid); SetUpRefundsProductLineGroupingGrandTotal(gridModel.ProductLineGrid); // customize the default grid model with our custom settings //JQGridState gridState = gridModel.ProductLineGrid.GetState(); // Need this to enable ExportToExcelRefundsByDay // Session["refundsProductLinesGridState"] = gridState; int contractorId = 0; if (Request.Params["contractorId"] != null) { Int32.TryParse(Request.Params["contractorId"].ToString(), out contractorId); } int managerId = 0; if (Request.Params["managerId"] != null) { Int32.TryParse(Request.Params["managerId"].ToString(), out managerId); } return(gridModel.ProductLineGrid.DataBind(GetRefundsProductLines(datacontextModel, refundsReportDate.Value, contractorId, managerId))); }
public ActionResult ProductEditRows(Product editedItem) { // Get the grid and database models var gridModel = new SkladJqGridModel(); var datacontextModel = new SkladDataContext(); // If we are in "Edit" mode if (gridModel.WarehouseGrid.AjaxCallBackMode == AjaxCallBackMode.EditRow) { // Get the data from and find the item corresponding to the edited row Product item = (from x in datacontextModel.Products where x.ProductId == editedItem.ProductId select x).First <Product>(); // update the item information UpdateProduct(item, editedItem); datacontextModel.SaveChanges(); } if (gridModel.WarehouseGrid.AjaxCallBackMode == AjaxCallBackMode.DeleteRow) { Product item = (from x in datacontextModel.Products where x.ProductId == editedItem.ProductId select x) .First <Product>(); // delete the record datacontextModel.Products.Remove(item); datacontextModel.SaveChanges(); } return(RedirectToAction("Product", "Reference")); }
// This method is called when the grid requests data public JsonResult ProductSearchGridDataRequested() { // Get both the grid Model and the data Model // The data model in our case is an autogenerated linq2sql database based on Northwind. var gridModel = new SkladJqGridModel(); var datacontextModel = new SkladDataContext(); // customize the default grid model with our custom settings ProductSetupGrid(gridModel.ProductGrid); string contractorIdStr = Request.QueryString["ContractorId"]; if (!String.IsNullOrEmpty(contractorIdStr)) { var contractor = datacontextModel.Contractors.Where(x => x.Code.ToLower() == contractorIdStr.ToLower()).FirstOrDefault(); if (contractor != null) { return(gridModel.ProductGrid.DataBind(datacontextModel .Products.Where(x => x.ContractorId == contractor.ContractorId).Include(x => x.Supplier))); } } // return the result of the DataBind method, passing the datasource as a parameter // jqGrid for ASP.NET MVC automatically takes care of paging, sorting, filtering/searching, etc return(gridModel.ProductGrid.DataBind(datacontextModel.Products.Include(x => x.Supplier))); }
// This method is called when the grid requests data public JsonResult CustomerOrdersSearchGridDataRequested() { //// Get both the grid Model and the data Model var gridModel = new SkladJqGridModel(); var datacontextModel = new SkladDataContext(); // customize the default grid model with our custom settings CustomerOrdersSetupGrid(gridModel.DocumentGrid); return(GetDocumentList(gridModel, datacontextModel, EntityEnum.DocumentTypeEnum.CustomerOrders)); }
// This method is called when the grid requests data public JsonResult RefundsSearchGridDataRequested() { // Get both the grid Model and the data Model // The data model in our case is an autogenerated linq2sql database based on Northwind. var gridModel = new SkladJqGridModel(); var datacontextModel = new SkladDataContext(); // customize the default grid model with our custom settings RefundsSetupGrid(gridModel.DocumentGrid); return(GetDocumentList(gridModel, datacontextModel, EntityEnum.DocumentTypeEnum.Refunds)); }
// This method is called when the grid requests data public JsonResult CancellationSearchGridDataRequested() { // Get both the grid Model and the data Model // The data model in our case is an autogenerated linq2sql database based on Northwind. var gridModel = new SkladJqGridModel(); var datacontextModel = new SkladDataContext(); // customize the default grid model with our custom settings CancellationSetupGrid(gridModel.DocumentGrid); return(gridModel.DocumentGrid.DataBind(datacontextModel.Documents.Where(x => x.DocumentTypeId == (int)EntityEnum.DocumentTypeEnum.Cancellation))); }
public ActionResult Shipment() { ViewBag.Title = "Отгрузки"; // Get the model (setup) of the grid defined in the /Models folder. var gridModel = new SkladJqGridModel(); var grid = gridModel.DocumentGrid; //// NOTE: you need to call this method in the action that fetches the data as well, //// so that the models match ShipmentSetupGrid(grid); // Pass the custmomized grid model to the View return(View(gridModel)); }
// This method is called when the grid requests data public JsonResult ContractorSearchGridDataRequested() { // Get both the grid Model and the data Model // The data model in our case is an autogenerated linq2sql database based on Northwind. var gridModel = new SkladJqGridModel(); var datacontextModel = new SkladDataContext(); // customize the default grid model with our custom settings ContractorSetupGrid(gridModel.ContractorGrid); // return the result of the DataBind method, passing the datasource as a parameter // jqGrid for ASP.NET MVC automatically takes care of paging, sorting, filtering/searching, etc return(gridModel.ContractorGrid.DataBind(datacontextModel.Contractors)); }
//#region Region //public ActionResult Region() //{ // ViewBag.Title = "Регион"; // // Get the model (setup) of the grid defined in the /Models folder. // var gridModel = new SkladJqGridModel(); // var grid = gridModel.RegionGrid; // // NOTE: you need to call this method in the action that fetches the data as well, // // so that the models match // RegionSetupGrid(grid); // // Pass the custmomized grid model to the View // return View(gridModel); //} //// This method is called when the grid requests data //public JsonResult RegionSearchGridDataRequested() //{ // // Get both the grid Model and the data Model // // The data model in our case is an autogenerated linq2sql database based on Northwind. // var gridModel = new SkladJqGridModel(); // var datacontextModel = new SkladDataContext(); // // customize the default grid model with our custom settings // RegionSetupGrid(gridModel.RegionGrid); // // return the result of the DataBind method, passing the datasource as a parameter // // jqGrid for ASP.NET MVC automatically takes care of paging, sorting, filtering/searching, etc // return gridModel.RegionGrid.DataBind(datacontextModel.Regions); //} //private void RegionSetupGrid(JQGrid grid) //{ // SetUpGrid(grid, "RegionGrid1", // Url.Action("RegionSearchGridDataRequested"), // Url.Action("RegionEditRows")); //} //public ActionResult RegionEditRows(Region editedItem) //{ // // Get the grid and database models // var gridModel = new SkladJqGridModel(); // var datacontextModel = new SkladDataContext(); // // If we are in "Edit" mode // if (gridModel.RegionGrid.AjaxCallBackMode == AjaxCallBackMode.EditRow) // { // // Get the data from and find the item corresponding to the edited row // Region item = (from x in datacontextModel.Regions // where x.RegionId == editedItem.RegionId // select x).First<Region>(); // // update the item information // UpdateRegion(item, editedItem); // datacontextModel.SaveChanges(); // } // if (gridModel.RegionGrid.AjaxCallBackMode == AjaxCallBackMode.AddRow) // { // // since we are adding a new item, create a new istance // Region item = new Region(); // // set the new item information // UpdateRegion(item, editedItem); // datacontextModel.Regions.Add(item); // datacontextModel.SaveChanges(); // } // if (gridModel.RegionGrid.AjaxCallBackMode == AjaxCallBackMode.DeleteRow) // { // Region item = (from x in datacontextModel.Regions // where x.RegionId == editedItem.RegionId // select x) // .First<Region>(); // // delete the record // datacontextModel.Regions.Remove(item); // datacontextModel.SaveChanges(); // } // return RedirectToAction("Region", "Reference"); //} //private void UpdateRegion(Region item, Region editedItem) //{ // item.Name = editedItem.Name; //} //#endregion #region Contractor public ActionResult Contractor() { ViewBag.Title = "Контрагент"; // Get the model (setup) of the grid defined in the /Models folder. var gridModel = new SkladJqGridModel(); var grid = gridModel.ContractorGrid; // NOTE: you need to call this method in the action that fetches the data as well, // so that the models match ContractorSetupGrid(grid); // Pass the custmomized grid model to the View return(View(gridModel)); }
public ActionResult CustomerOrders() { ViewBag.Title = "Заказы покупателя"; // Get the model (setup) of the grid defined in the /Models folder. var gridModel = new SkladJqGridModel(); var grid = gridModel.DocumentGrid; //// NOTE: you need to call this method in the action that fetches the data as well, //// so that the models match CustomerOrdersSetupGrid(grid); /* * public int? ContractId { get; set; } * public int? EmployeeId { get; set; } */ // Pass the custmomized grid model to the View return(View(gridModel)); }
private JsonResult GetDocumentList(SkladJqGridModel gridModel, SkladDataContext datacontextModel, EntityEnum.DocumentTypeEnum docType) { string contractorIdStr = Request.QueryString["ContractorId"]; if (!String.IsNullOrEmpty(contractorIdStr)) { var contractor = datacontextModel.Contractors.Where(x => x.Code.ToLower() == contractorIdStr.ToLower()).FirstOrDefault(); if (contractor != null) { // ContractorName return(gridModel.DocumentGrid.DataBind(datacontextModel .Documents.Include("Contractor").Where(x => x.ContractorId == contractor.ContractorId && x.DocumentTypeId == (int)docType))); } } return(gridModel.DocumentGrid.DataBind(datacontextModel.Documents.Include("Contractor").Where(x => x.DocumentTypeId == (int)docType))); }
public ActionResult ExportToExcelRefundsByDay(DateTime?refundsReportDate) { if (!refundsReportDate.HasValue) { refundsReportDate = DateTime.Now; } var gridModel = new SkladJqGridModel(); var skladModel = new SkladDataContext(); var grid = gridModel.ProductLineGrid; // Get the last grid state the we saved before in Session in the DataRequested action JQGridState gridState = Session["refundsProductLinesGridState"] as JQGridState; // Need to set grid options again SetUpRefundsProductLineColumns(grid); SetUpRefundsProductLineGroupingGrandTotal(grid); //if (String.IsNullOrEmpty(exportType)) // exportType = "1"; // refundsReportDate //switch (exportType) //{ // case "1": // grid.ExportToExcel(GetRefundsProductLines(skladModel, refundsReportDate.Value), "refundsByDateGrid.xls", gridState); //break; // case "2": // grid.ExportSettings.ExportDataRange = ExportDataRange.Filtered; // grid.ExportToExcel(northWindModel.Orders, "grid.xls", gridState); // break; // case "3": // grid.ExportSettings.ExportDataRange = ExportDataRange.FilteredAndPaged; // grid.ExportToExcel(northWindModel.Orders, "grid.xls", gridState); // break; //} return(View()); }
public ActionResult Refunds() { ViewBag.Title = "Возвраты покупателя"; // Get the model (setup) of the grid defined in the /Models folder. var gridModel = new SkladJqGridModel(); var grid = gridModel.DocumentGrid; //// NOTE: you need to call this method in the action that fetches the data as well, //// so that the models match RefundsSetupGrid(grid); // Создать grid со списком товаров с возвратом за определённый день // Можно сделать просто полный список всех товаров из проведённых // документов возвратов var gridProducts = gridModel.ProductLineGrid; RefundsProductSetupGrid(gridProducts); ViewBag.GridProducts = gridProducts; // Pass the custmomized grid model to the View return(View(gridModel)); }
public ActionResult ContractorEditRows(Contractor editedItem) { // Get the grid and database models var gridModel = new SkladJqGridModel(); var datacontextModel = new SkladDataContext(); // If we are in "Edit" mode if (gridModel.ContractorGrid.AjaxCallBackMode == AjaxCallBackMode.EditRow) { PrepareContractorData(editedItem); string validationMessage = ValidateContractorData(datacontextModel.Contractors, editedItem, false); if (!String.IsNullOrEmpty(validationMessage)) { return(gridModel.ContractorGrid.ShowEditValidationMessage(validationMessage)); } // Get the data from and find the item corresponding to the edited row Contractor item = (from x in datacontextModel.Contractors where x.ContractorId == editedItem.ContractorId select x).First <Contractor>(); // update the item information UpdateContractor(item, editedItem); datacontextModel.SaveChanges(); logger.InfoFormat("контрагент изменён {0}", item.Code); } if (gridModel.ContractorGrid.AjaxCallBackMode == AjaxCallBackMode.AddRow) { PrepareContractorData(editedItem); string validationMessage = ValidateContractorData(datacontextModel.Contractors, editedItem, true); if (!String.IsNullOrEmpty(validationMessage)) { return(gridModel.ContractorGrid.ShowEditValidationMessage(validationMessage)); } // since we are adding a new item, create a new istance Contractor item = new Contractor() { IsArchived = false, CreatedAt = DateTime.Now }; // set the new item information UpdateContractor(item, editedItem); datacontextModel.Contractors.Add(item); datacontextModel.SaveChanges(); logger.InfoFormat("контрагент добавлен {0}", item.Code); } if (gridModel.ContractorGrid.AjaxCallBackMode == AjaxCallBackMode.DeleteRow) { Contractor item = (from x in datacontextModel.Contractors where x.ContractorId == editedItem.ContractorId select x) .First <Contractor>(); // delete the record datacontextModel.Contractors.Remove(item); datacontextModel.SaveChanges(); logger.InfoFormat("контрагент удалён {0}", item.Code); } return(RedirectToAction("Contractor", "Reference")); }