public ActionResult Edit([DataSourceRequest] DataSourceRequest request, Fin_PurchaseRequestModel Contract)
        {

            if (ModelState.IsValid)
            {
                var service = new RestServiceClient<Fin_PurchaseRequestModel>(UserLogin);
                service.SetCookies(this.Request.Cookies, _hrm_Hr_Service);
                var result = service.Put(_hrm_Hr_Service, "api/Fin_PurchaseRequest/", Contract);
                ViewBag.MsgUpdate = "Update success";
            }
            return View();
        }
 public ActionResult Create(Fin_PurchaseRequestModel model)
 {
    
     if (ModelState.IsValid)
     {
         var service = new RestServiceClient<Fin_PurchaseRequestModel>(UserLogin);
         service.SetCookies(this.Request.Cookies, _hrm_Hr_Service);
         var result = service.Put(_hrm_Hr_Service, "api/Fin_PurchaseRequest/", model);
         ViewBag.MsgInsert = "Insert success";
     }
     return View();
 }
 /// <summary>
 /// [Chuc.Nguyen] - Lấy dữ liệu bảng Tai Nạn(Hre_Accident) theo Id
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Fin_PurchaseRequestModel GetById(Guid id)
 {
     string status = string.Empty;
     var model = new Fin_PurchaseRequestModel();
     ActionService service = new ActionService(UserLogin);
     var entity = service.GetByIdUseStore<FIN_PurchaseRequestEntity>(id, ConstantSql.hrm_hr_sp_get_PurchaseRequestById, ref status);
     if (entity != null)
     {
         model = entity.CopyData<Fin_PurchaseRequestModel>();
     }
     model.ActionStatus = status;
     return model;
 }
示例#4
0
        public ActionResult ExportPurchaseRequest(string purchaseID, Guid? exportID, bool isCreateTemplate, bool isCreateTemplateForDynamicGrid)
        {

            string status = string.Empty;
            var baseService = new BaseService();
            ExportFileType exportFileType = ExportFileType.Excel;
            var actionServices = new ActionService(UserLogin);
            var objs = new List<object>();
            objs.Add(Common.ConvertToGuid(purchaseID));
            var entityPR = actionServices.GetByIdUseStore<Fin_PurchaseRequestModel>(Common.ConvertToGuid(purchaseID), ConstantSql.hrm_hr_sp_get_PurchaseRequestById, ref status);
            var lstPRItem = actionServices.GetData<Fin_PurchaseRequestItemModel>(objs, ConstantSql.hrm_cat_sp_get_PRItemByPRID, ref status);
            DataTable table = new DataTable("Fin_PurchaseRequestModel");
            if (entityPR != null && lstPRItem != null)
            {

                table.Columns.Add("FunctionName");
                table.Columns.Add("BudgetOwnerName");
                table.Columns.Add("ChannelName");
                table.Columns.Add("BudgetChargedIn");
                table.Columns.Add("From");
                table.Columns.Add("To");
                table.Columns.Add("SupplierName");
                table.Columns.Add("Description");
                table.Columns.Add("Code");
                table.Columns.Add("CateCodeType");
                table.Columns.Add("Name");
                table.Columns.Add("ProjectName");
                table.Columns.Add("PurchaseItemName");
                table.Columns.Add("PurchaseItemCost");
                table.Columns.Add("Quantity", typeof(double));
                table.Columns.Add("UnitPrice", typeof(double));
                table.Columns.Add("Amount", typeof(double));

                foreach (var item in lstPRItem)
                {
                    DataRow dr = table.NewRow();

                    dr["FunctionName"] = entityPR.FunctionName;
                    dr["BudgetOwnerName"] = entityPR.BudgetOwnerName;
                    dr["ChannelName"] = entityPR.ChannelName;
                    dr["BudgetChargedIn"] = entityPR.BudgetChargedIn == null ? string.Empty : entityPR.BudgetChargedIn.Value.ToShortDateString();
                    dr["From"] = entityPR.From == null ? string.Empty : entityPR.From.Value.ToShortDateString(); ;
                    dr["To"] = entityPR.To == null ? string.Empty : entityPR.To.Value.ToShortDateString();
                    dr["SupplierName"] = entityPR.SupplierName;
                    dr["Description"] = entityPR.Description;

                    dr["Code"] = item.Code == null ? string.Empty : item.Code;
                    dr["CateCodeType"] = item.CateCodeType == null ? string.Empty : item.CateCodeType;
                    dr["Name"] = item.Name == null ? string.Empty : item.Name;
                    dr["ProjectName"] = item.ProjectName == null ? string.Empty : item.ProjectName;
                    dr["PurchaseItemName"] = item.PurchaseItemName == null ? string.Empty : item.PurchaseItemName;
                    dr["PurchaseItemCost"] = item.PurchaseItemCost == null ? string.Empty : item.PurchaseItemCost;
                    dr["Quantity"] = item.Quantity == null ? 0 : item.Quantity.Value;
                    dr["UnitPrice"] = item.UnitPrice == null ? 0 : item.UnitPrice.Value;
                    dr["Amount"] = item.Amount == null ? 0 : item.Amount.Value;
                    table.Rows.Add(dr);
                }
                var result = table;

                object obj = new Fin_PurchaseRequestModel();
                var isDataTable = false;

                if (isCreateTemplateForDynamicGrid)
                {
                    obj = result;
                    isDataTable = true;
                }
                if (isCreateTemplate)
                {
                    var path = Common.GetPath("Templates");
                    ExportService exportService = new ExportService();
                    ConfigExport cfgExport = new ConfigExport()
                    {
                        Object = obj,
                        FileName = "Fin_PurchaseRequestModel",
                        OutPutPath = path,
                        DownloadPath = Hrm_Main_Web + "Templates",
                        IsDataTable = isDataTable
                    };
                    var str = exportService.CreateTemplate(cfgExport);
                    return Json(str);
                }

            }
            if (exportID != null)
            {
                var fullPath = ExportService.Export((Guid)exportID, table, exportFileType);
                return Json(fullPath);
            }

            return null;
        }