Exemplo n.º 1
0
        public void ExportProtocol(string filePath, CompanyOrder order)
        {
            var excelModel = new ExcelModel();

            var excelSheet = new ExcelSheetModel();

            excelSheet.Name = "Sheet1";

            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "公司名",
                RowIndex    = 2,
                ColumnIndex = 3,
                Value       = order.Company.CompanyName
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "公司地址",
                RowIndex    = 3,
                ColumnIndex = 3,
                Value       = order.Company.CompanyAddress
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "体检时间",
                RowIndex    = 10,
                ColumnIndex = 2,
                Value       = XL.Utilities.StringHelper.Join(order.SubOrders.Select(x => x.StartDate.Value.ToString("yyyy-MM-dd")).ToArray(), ";")
            });

            excelModel.Sheets.Add(excelSheet);
            _importExportService.ExportWithTemplate(filePath, excelModel);
        }
        /// <summary>
        /// Christian Lopez
        ///
        /// Created:
        /// 2017/04/13
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public static CompanyOrderWithLines RetrieveOrderWithLinesByOrderId(int orderId)
        {
            CompanyOrderWithLines order = null;

            try
            {
                CompanyOrder data = RetrieveOrderByOrderId(orderId);
                order = new CompanyOrderWithLines()
                {
                    CompanyOrderID = data.CompanyOrderID,
                    EmployeeId     = data.EmployeeId,
                    SupplierId     = data.SupplierId,
                    Amount         = data.Amount,
                    HasArrived     = data.HasArrived,
                    OrderDate      = data.OrderDate,
                    Active         = data.Active,
                    OrderLines     = RetrieveCompanyOrderLinesByOrderId(orderId)
                };
            }
            catch (Exception)
            {
                throw;
            }

            return(order);
        }
        public void DeleteCompanyOrder(CompanyOrder companyOrder)
        {
            if (companyOrder == null)
            {
                throw new ArgumentNullException(nameof(companyOrder));
            }

            _context.CompanyOrders.Remove(companyOrder);
        }
        public void AddCompanyOrder(CompanyOrder companyOrder)
        {
            if (companyOrder == null)
            {
                throw new ArgumentNullException(nameof(companyOrder));
            }

            _context.CompanyOrders.Add(companyOrder);
        }
Exemplo n.º 5
0
 public void Add(CompanyOrder order)
 {
     if (order != null)
     {
         _context.CompanyOrder.Add(order);
     }
     else
     {
         throw new ArgumentNullException();
     }
 }
Exemplo n.º 6
0
        public string SaveFirstStepInfo(Guid?orderId, string subOrdersString, string comment)
        {
            var returnObject = new AJAXReturnObject();

            using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
            {
                try
                {
                    var order = new CompanyOrder();
                    if (orderId == null)
                    {
                        var company = _companyService.GetById(WorkContext.CurrentMembershipUser.Company.Id);
                        order = new CompanyOrder
                        {
                            CreatedBy = WorkContext.CurrentMembershipUser.Username,
                            Company   = company,
                        };
                    }
                    else
                    {
                        order           = _companyOrderService.GetById(new Guid(orderId.ToString()));
                        order.UpdatedBy = WorkContext.CurrentMembershipUser.Username;
                    }


                    order.Comment = comment;
                    string[] subOrderIds = subOrdersString.Split(',');
                    if (subOrderIds.Length > 0)
                    {
                        foreach (var subOrderId in subOrderIds)
                        {
                            var subOrder = _companySubOrderService.GetById(new Guid(subOrderId));
                            order.SubOrders.Add(subOrder);
                        }
                    }
                    if (orderId == null)
                    {
                        _companyOrderService.Add(order);
                    }
                    unitOfWork.Commit();
                    orderId = order.Id;
                }
                catch (Exception ex)
                {
                    returnObject.Status  = AJAXReturnResult.Failed;
                    returnObject.Message = ex.Message;
                }
            }
            return("{\"Status\":\"0\",\"orderId\":\"" + orderId + "\"}");
        }
Exemplo n.º 7
0
 private void GenerateEmployees(CompanyOrder order, string[] employeeIds)
 {
     foreach (var employeeId in employeeIds)
     {
         if (string.IsNullOrEmpty(employeeId))
         {
             continue;
         }
         var employee = _companyEmployeeService.GetById(new Guid(employeeId));
         if (employee != null)
         {
             order.CompanyEmployees.Add(employee);
         }
     }
 }
Exemplo n.º 8
0
        private void GenerateOrderSubOrders(CompanyOrder order, string[] subOrderIds)
        {
            foreach (var subOrderId in subOrderIds)
            {
                if (string.IsNullOrEmpty(subOrderId))
                {
                    continue;
                }

                var subOrder = _companySubOrderService.GetById(new Guid(subOrderId));
                if (subOrder != null)
                {
                    order.SubOrders.Add(subOrder);
                }
            }
        }
        /// <summary>
        /// Christian Lopez
        ///
        /// Created:
        /// 2017/04/13
        ///
        /// Returns a list of company orders placed to a specified supplier Id
        /// </summary>
        /// <param name="supplierId"></param>
        /// <returns></returns>
        public static List <CompanyOrder> RetrieveCompanyOrdersBySupplierId(int supplierId)
        {
            List <CompanyOrder> orders = new List <CompanyOrder>();

            var conn    = DBConnection.GetConnection();
            var cmdText = @"sp_retrieve_company_order_list_by_supplier_id";
            var cmd     = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@SUPPLIER_ID", supplierId);

            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        CompanyOrder order = new CompanyOrder()
                        {
                            CompanyOrderID = reader.GetInt32(0),
                            EmployeeId     = reader.GetInt32(1),
                            SupplierId     = reader.GetInt32(2),
                            Amount         = reader.GetDecimal(3),
                            OrderDate      = reader.GetDateTime(4),
                            HasArrived     = reader.GetBoolean(5),
                            Active         = reader.GetBoolean(6)
                        };
                        orders.Add(order);
                    }
                }
                reader.Close();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }

            return(orders);
        }
        /// <summary>
        /// Christian Lopez
        ///
        /// Created:
        /// 2017/04/13
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public static CompanyOrder RetrieveOrderByOrderId(int orderId)
        {
            CompanyOrder order = null;

            var conn    = DBConnection.GetConnection();
            var cmdText = @"sp_retrieve_company_order_by_id";
            var cmd     = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@COMPANY_ORDER_ID", orderId);

            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    reader.Read();
                    order = new CompanyOrder()
                    {
                        CompanyOrderID = reader.GetInt32(0),
                        EmployeeId     = reader.GetInt32(1),
                        SupplierId     = reader.GetInt32(2),
                        Amount         = reader.GetDecimal(3),
                        OrderDate      = reader.GetDateTime(4),
                        HasArrived     = reader.GetBoolean(5),
                        Active         = reader.GetBoolean(6)
                    };
                }
                reader.Close();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }

            return(order);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objNewOrderViewModel"></param>
        /// <param name="frm"></param>
        private void SaveCommertialProperty(NewOrderViewModel objNewOrderViewModel,FormCollection frm)
        {
            #region Saving Commercial Photography

                    if ((objNewOrderViewModel.UserType == 1) || (objNewOrderViewModel.UserType == 2))
                    {
                        objNewOrderViewModel.CompanyID = Convert.ToInt32(frm["ddlCompanyCom"].ToString());
                    }

                    objNewOrderViewModel.OfficeContactName = (frm["txtOfficeContactNameCom"].ToString());
                    objNewOrderViewModel.Phone = (frm["txtPhone"].ToString());
                    objNewOrderViewModel.Email = (frm["txtEmailIdCom"].ToString());
                    objNewOrderViewModel.ProjectAddress = (frm["txtProjectAddress"].ToString());
                    objNewOrderViewModel.DetailedBrief = (frm["txtDetailedBrief"].ToString());

                    using (var OrderMangtDB = new OrderMgntEntities())
                    {
                        using (var transaction = new TransactionScope())
                        {
                            var EntityProperties = new Property
                            {
                                Company_Id = objNewOrderViewModel.CompanyID,
                                Name = objNewOrderViewModel.ProjectAddress,
                                Created = DateTime.Now,
                            };

                            // Add the Properties entity
                            OrderMangtDB.Properties.Add(EntityProperties);

                            OrderMangtDB.SaveChanges();
                            // Update the entity in the database

                            // Get the Row_Id generated by the database
                            objNewOrderViewModel.PropRowID = EntityProperties.Row_Id;

                            var EnityOrder = new Order
                            {
                                Property_Id = objNewOrderViewModel.PropRowID,
                                Description = objNewOrderViewModel.DetailedBrief,
                                OrderId = "DPI-" + DateTime.Now.ToString("yyyyMMddHHmmssf"),
                                Created = DateTime.Now,
                            };

                            // Add the Orders entity
                            OrderMangtDB.Orders.Add(EnityOrder);

                            OrderMangtDB.SaveChanges();
                            // Update the entity in the database

                            // Get the Row_Id generated by the database
                            objNewOrderViewModel.OrderRowID = EnityOrder.Row_Id;

                            // Logic for PhotoGrphy selected items

                            // End Logic for PhotoGrphy selected items

                            var EntityOrderItems = new OrderItem
                            {
                                Order_Id = objNewOrderViewModel.OrderRowID,
                                //Name = "Options Premium Package 2.1  Photography up to 8 day/dusk images Property Video /Floorplan + Siteplan",
                                Created = DateTime.Now,
                            };
                            // Add the OrderItems entity
                            OrderMangtDB.OrderItems.Add(EntityOrderItems);
                            // Update the entity in the database
                            OrderMangtDB.SaveChanges();
                            // Get the Row_Id generated by the database
                            objNewOrderViewModel.OrderItemRowID = EntityOrderItems.Row_Id;

                            // add entry in the CompanyOrdertable

                            var EntityCompanyOrder = new CompanyOrder
                            {
                                CompanyId = objNewOrderViewModel.CompanyID,
                                OrderId = objNewOrderViewModel.OrderRowID,
                                Created = DateTime.Now,
                            };

                            // Add the CompanyOrders entity
                            OrderMangtDB.CompanyOrders.Add(EntityCompanyOrder);
                            // Update the entity in the database
                            OrderMangtDB.SaveChanges();
                            // Get the Row_Id generated by the database
                            objNewOrderViewModel.CompanyOrderRowID = EntityCompanyOrder.Row_Id;

                            transaction.Complete();
                        }
                    }
                    #endregion
        }
Exemplo n.º 12
0
        public ActionResult Create([Bind(Include = "date, statusid, rate, deleted")] Order order)
        {
            try
            {
                ViewData["billtoid"] = EZDropDown.Companies(unitOfWork);

                if (Request["billtoid"].ToString() == "")
                {
                    ModelState.AddModelError("CompanyOrders", "Required");
                }

                if (Request["shiptoid"] != null && Request["shiptoid"].ToString() == "")
                {
                    ModelState.AddModelError("CompanyOrders", "Required");
                }

                //if (Request["hdnInventory"] == null)
                //{
                //
                //}
                if ((Request["inventoryid"] == null) ||
                    (Request["qty"] == null) ||
                    (Request["inventoryid"] != null && Request["inventoryid"].ToString() == "") ||
                    (Request["qty"] != null && Request["qty"].ToString() == ""))
                {
                    ModelState.AddModelError("OrderDetails", "Inventory and Quantity are required");
                }
                if (ModelState.IsValid)
                {
                    int billToID = int.Parse(Request["billtoid"].ToString());
                    int shipToID = int.Parse(Request["shiptoid"].ToString());

                    CompanyOrder co = new CompanyOrder();
                    co.type      = 1;//BillTo
                    co.companyid = billToID;
                    order.CompanyOrders.Add(co);

                    co           = new CompanyOrder();
                    co.type      = 2;//ShipTo
                    co.companyid = shipToID;
                    order.CompanyOrders.Add(co);

                    int inventoryID      = int.Parse(Request["inventoryid"].ToString());
                    int itemTotalQty     = int.Parse(Request["qty"].ToString());
                    int boxqty           = 0;
                    int itemQtyLocation  = 0;
                    var inventoryDetails = unitOfWork.InventoryDetailRepository.Get().Where(id => id.inventoryid == inventoryID).ToList();
                    foreach (InventoryDetail id in inventoryDetails)
                    {
                        int quantity = (int)id.boxqty * (int)id.itemperbox + (int)id.itemqty;
                        if (quantity < itemTotalQty)    //Items are stored in multiple locations
                        {
                            itemQtyLocation = quantity; //Partial quantity in a location
                        }
                        else
                        {
                            itemQtyLocation = itemTotalQty;//The entire quantity
                        }
                        boxqty = (int)Math.Ceiling((decimal)(itemQtyLocation) / (int)(id.itemperbox));

                        OrderDetail od = new OrderDetail();
                        od.inventoryid = inventoryID;
                        od.qty         = itemQtyLocation;
                        od.boxqty      = boxqty;
                        od.locationid  = id.locationid;
                        order.OrderDetails.Add(od);
                        if (quantity < itemTotalQty)//More items to ship so get it from a different location
                        {
                            itemTotalQty -= quantity;
                        }
                        else
                        {
                            break;
                        }
                    }



                    //TO DO: Subtract item and box quantity!
                    //db.Entry(inventoryDetail).State = EntityState.Modified;
                    //inventoryDetail.boxqty -= boxqty;
                    //inventoryDetail.itemqty -= itemqty;

                    if (Request["hdnInventory"] != null)
                    {
                        string   tmp   = Request["hdnInventory"].ToString();
                        string[] aInvs = tmp.Split(',');
                        foreach (string inv in aInvs)
                        {
                            string[] aInv = inv.Split(':');
                            //od = new OrderDetail();
                            //od.inventoryid = int.Parse(aInv[0]);
                            //od.qty = int.Parse(aInv[1]);
                            //boxqty = (int)Math.Ceiling(decimal.Parse(aInv[1]) / (int)(inventoryDetail.itemperbox));
                            //od.boxqty = boxqty;
                            inventoryID      = int.Parse(aInv[0]);
                            itemTotalQty     = int.Parse(aInv[1]);
                            inventoryDetails = unitOfWork.InventoryDetailRepository.Get().Where(id => id.inventoryid == inventoryID).ToList();
                            foreach (InventoryDetail id in inventoryDetails)
                            {
                                int quantity = (int)id.boxqty * (int)id.itemperbox + (int)id.itemqty;
                                if (quantity < itemTotalQty)    //Items are stored in multiple locations
                                {
                                    itemQtyLocation = quantity; //Partial quantity in a location
                                }
                                else
                                {
                                    itemQtyLocation = itemTotalQty;//The entire quantity
                                }
                                boxqty = (int)Math.Ceiling((decimal)(itemQtyLocation) / (int)(id.itemperbox));

                                OrderDetail od = new OrderDetail();
                                od.inventoryid = inventoryID;
                                od.qty         = itemQtyLocation;
                                od.boxqty      = boxqty;
                                od.locationid  = id.locationid;
                                order.OrderDetails.Add(od);
                                if (quantity < itemTotalQty)//More items to ship so get it from a different location
                                {
                                    itemTotalQty -= quantity;
                                }
                                else
                                {
                                    break;
                                }
                            }

                            //order.OrderDetails.Add(od);
                        }
                    }

                    db.Orders.Add(order);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.)
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
            }

            return(View(order));
        }
 public void UpdateCompanyOrder(CompanyOrder companyOrder)
 {
     // no implementation for now
 }
Exemplo n.º 14
0
        public void ExportCompanyOrderForms(string webRootPath, CompanyOrder order)
        {
            var folder = webRootPath + @"Content\ExportFiles\Orders\" + order.Id.ToString();

            //如果有同名文件夹,删除
            if (Directory.Exists(folder))
            {
                Directory.Delete(folder, true);
            }
            //创建文件夹
            Directory.CreateDirectory(folder);

            if (order.CompanyEmployees.Count > 0)
            {
                //导出检查表
                List <string> checkForms = new List <string>();
                foreach (var emp in order.CompanyEmployees)
                {
                    var templateFilePath = webRootPath + @"\Content\Templates\" + "上海市职业健康检查表.xlsx";
                    var targetFilePath   = folder + @"\上海市职业健康检查表_" + emp.EmployeeBaseInfo.UserName + ".xlsx";
                    File.Copy(templateFilePath, targetFilePath);
                    ExportCheckForm(targetFilePath, emp, webRootPath);
                    checkForms.Add(targetFilePath);
                }

                //压缩检查表
                //ZipHelper.CompressFiles(folder + @"\上海市职业健康检查表.zip", checkForms);

                //删除检查表
                //foreach (var path in checkForms)
                //{
                //    File.Delete(path);
                //}

                //导出告知书
                List <string> adverseFactorNoticeForms = new List <string>();
                foreach (var emp in order.CompanyEmployees)
                {
                    var templateFilePath = webRootPath + @"\Content\Templates\" + "职业病危害因素告知书.xlsx";
                    var targetFilePath   = folder + @"\职业病危害因素告知书_" + emp.EmployeeBaseInfo.UserName + ".xlsx";
                    File.Copy(templateFilePath, targetFilePath);
                    ExportAdverseFactorNoticeForm(targetFilePath, emp);
                    adverseFactorNoticeForms.Add(targetFilePath);
                }

                //压缩告知书
                //ZipHelper.CompressFiles(folder + @"\职业病危害因素告知书.zip", adverseFactorNoticeForms);

                //删除告知书
                //foreach (var path in adverseFactorNoticeForms)
                //{
                //    File.Delete(path);
                //}
            }

            //导出登记表
            var templateFilePath1 = webRootPath + @"\Content\Templates\" + "上海市职业健康检查应检者登记表.xlsx";
            var targetFilePath1   = folder + @"\上海市职业健康检查应检者登记表.xlsx";

            File.Copy(templateFilePath1, targetFilePath1);
            ExportCheckerRegistrationForm(targetFilePath1, order);

            //导出造册表
            var templateFilePath2 = webRootPath + @"\Content\Templates\" + "上海市作业人员职业病危害因素接触情况造册表.xlsx";
            var targetFilePath2   = folder + @"\上海市作业人员职业病危害因素接触情况造册表.xlsx";

            File.Copy(templateFilePath2, targetFilePath2);
            ExportAdverseFactorContactSituationRegistrationForm(targetFilePath2, order);

            //导出协议书
            var templateFilePath3 = webRootPath + @"\Content\Templates\" + "协议书.xlsx";
            var targetFilePath3   = folder + @"\协议书.xlsx";

            File.Copy(templateFilePath3, targetFilePath3);
            ExportProtocol(targetFilePath3, order);
        }
Exemplo n.º 15
0
 public void Add(CompanyOrder order)
 {
     _companyOrderRepository.Add(order);
 }
Exemplo n.º 16
0
        public void ExportAdverseFactorContactSituationRegistrationForm(string filePath, CompanyOrder order)
        {
            var excelModel = new ExcelModel();

            var excelSheet = new ExcelSheetModel();

            excelSheet.Name = "Sheet1";

            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "单位名称",
                RowIndex    = 3,
                ColumnIndex = 3,
                Value       = order.Company.CompanyName
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "单位地址",
                RowIndex    = 4,
                ColumnIndex = 3,
                Value       = order.Company.CompanyAddress
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "邮编",
                RowIndex    = 4,
                ColumnIndex = 10,
                Value       = order.Company.ZipCode
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "法人",
                RowIndex    = 5,
                ColumnIndex = 3,
                Value       = order.Company.LegalPerson
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "联系人",
                RowIndex    = 5,
                ColumnIndex = 7,
                Value       = order.Company.ContactPerson
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "联系电话",
                RowIndex    = 5,
                ColumnIndex = 10,
                Value       = order.Company.ContactPhone
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "休息日",
                RowIndex    = 6,
                ColumnIndex = 3,
                Value       = order.Company.RestDay
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "企业注册类型",
                RowIndex    = 6,
                ColumnIndex = 7,
                Value       = order.Company.CompanyRegisterType == null ? string.Empty : order.Company.CompanyRegisterType.Name
            });

            if (order.CompanyEmployees != null && order.CompanyEmployees.Count > 0)
            {
                var row = 9;
                foreach (var emp in order.CompanyEmployees)
                {
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "序号",
                        RowIndex    = row,
                        ColumnIndex = 1,
                        Value       = (row - 8).ToString()
                    });
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "姓名",
                        RowIndex    = row,
                        ColumnIndex = 2,
                        Value       = emp.EmployeeBaseInfo.UserName
                    });
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "性别",
                        RowIndex    = row,
                        ColumnIndex = 3,
                        Value       = emp.EmployeeBaseInfo.Sex
                    });
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "年龄",
                        RowIndex    = row,
                        ColumnIndex = 4,
                        Value       = IDCardHelper.GetAge(emp.EmployeeBaseInfo.IDCard).ToString()
                    });
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "民工",
                        RowIndex    = row,
                        ColumnIndex = 5,
                        Value       = emp.MigrantWorker.Name
                    });
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "车间部门",
                        RowIndex    = row,
                        ColumnIndex = 6,
                        Value       = emp.Department
                    });
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "工种",
                        RowIndex    = row,
                        ColumnIndex = 7,
                        Value       = emp.WorkType
                    });
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "危害因素",
                        RowIndex    = row,
                        ColumnIndex = 8,
                        Value       = emp.AdverseFactor
                    });
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "接触工龄",
                        RowIndex    = row,
                        ColumnIndex = 9,
                        Value       = emp.AdverseMonthes.HasValue ? emp.AdverseMonthes.ToString() : ""
                    });
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "检查类别",
                        RowIndex    = row,
                        ColumnIndex = 10,
                        Value       = emp.HealthStatus.Name
                    });
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "备注",
                        RowIndex    = row,
                        ColumnIndex = 11,
                        Value       = emp.Comment
                    });

                    row++;
                }
            }

            excelModel.Sheets.Add(excelSheet);

            _importExportService.ExportWithTemplate(filePath, excelModel);
        }
Exemplo n.º 17
0
        public void ExportCheckerRegistrationForm(string filePath, CompanyOrder order)
        {
            var excelModel = new ExcelModel();

            var excelSheet = new ExcelSheetModel();

            excelSheet.Name = "Sheet1";

            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "单位",
                RowIndex    = 3,
                ColumnIndex = 2,
                Value       = order.Company.CompanyName
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "地址",
                RowIndex    = 5,
                ColumnIndex = 2,
                Value       = order.Company.CompanyAddress
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "邮编",
                RowIndex    = 5,
                ColumnIndex = 5,
                Value       = order.Company.ZipCode
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "电话",
                RowIndex    = 7,
                ColumnIndex = 2,
                Value       = order.Company.ContactPhone
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "传真",
                RowIndex    = 7,
                ColumnIndex = 5,
                Value       = order.Company.Fax
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "双休日",
                RowIndex    = 9,
                ColumnIndex = 2,
                Value       = order.Company.RestDay
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "法定代表人",
                RowIndex    = 9,
                ColumnIndex = 5,
                Value       = order.Company.LegalPerson
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "登记日期",
                RowIndex    = 11,
                ColumnIndex = 2,
                Value       = order.Company.CreatedDate.HasValue ? order.Company.CreatedDate.Value.ToString("yyyy年MM月dd日") : ""
            });
            excelSheet.Cells.Add(new ExcelSheetCellModel()
            {
                Title       = "单位性质",
                RowIndex    = 11,
                ColumnIndex = 5,
                Value       = order.Company.CompanyType == null ? string.Empty : order.Company.CompanyType.Name
            });
            if (order.CompanyEmployees != null && order.CompanyEmployees.Count > 0)
            {
                var emps = order.CompanyEmployees.GroupBy(e => new { e.Department, e.WorkType, e.HealthStatus, e.AdverseFactor })
                           .Select(g => (new { key = g.Key, count = g.Count() }));

                var startRow = 14;
                foreach (var emp in emps)
                {
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "车间",
                        RowIndex    = startRow,
                        ColumnIndex = 1,
                        Value       = emp.key.Department
                    });
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "工种",
                        RowIndex    = startRow,
                        ColumnIndex = 2,
                        Value       = emp.key.WorkType
                    });
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "体检类别",
                        RowIndex    = startRow,
                        ColumnIndex = 3,
                        Value       = emp.key.HealthStatus.Name
                    });
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "职业危害因素",
                        RowIndex    = startRow,
                        ColumnIndex = 4,
                        Value       = emp.key.AdverseFactor
                    });
                    excelSheet.Cells.Add(new ExcelSheetCellModel()
                    {
                        Title       = "接触人数",
                        RowIndex    = startRow,
                        ColumnIndex = 5,
                        Value       = emp.count.ToString()
                    });
                    startRow++;
                }
            }

            excelModel.Sheets.Add(excelSheet);

            _importExportService.ExportWithTemplate(filePath, excelModel);
        }
Exemplo n.º 18
0
 public void Delete(CompanyOrder entity)
 {
     _context.CompanyOrder.Remove(entity);
 }
Exemplo n.º 19
0
        public ActionResult Create(CompanyOrderCreateViewModel model, FormCollection form)
        {
            try
            {
                var  company   = WorkContext.CurrentMembershipUser.Company;
                Guid companyId = company.Id;

                using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
                {
                    var order = new CompanyOrder();

                    if (model.OrderId == null)
                    {
                        order.Comment = model.Comment;
                        if (!string.IsNullOrEmpty(model.AssignedSubOrderString))
                        {
                            var subOrderIds = model.AssignedSubOrderString.Split(',');
                            GenerateOrderSubOrders(order, subOrderIds);
                        }
                        if (!string.IsNullOrEmpty(model.AssignedEmployeesString))
                        {
                            var employeeIds = model.AssignedEmployeesString.Split(',');
                            GenerateEmployees(order, employeeIds);
                        }
                        order.Company          = _companyService.GetById(companyId);
                        order.IsBuildCompleted = false;
                        order.Locked           = false;
                        order.CreatedBy        = WorkContext.CurrentMembershipUser.Username;
                        order.CreatedDate      = DateTime.Now;
                        _companyOrderService.Add(order);
                    }
                    else
                    {
                        order         = _companyOrderService.GetById(new Guid(model.OrderId.ToString()));
                        order.Comment = model.Comment;
                        order.SubOrders.Clear();
                        if (!string.IsNullOrEmpty(model.AssignedSubOrderString))
                        {
                            var subOrderIds = model.AssignedSubOrderString.Split(',');
                            GenerateOrderSubOrders(order, subOrderIds);
                        }
                        order.CompanyEmployees.Clear();
                        if (!string.IsNullOrEmpty(model.AssignedEmployeesString))
                        {
                            var employeeIds = model.AssignedEmployeesString.Split(',');
                            GenerateEmployees(order, employeeIds);
                        }
                        order.Company          = _companyService.GetById(companyId);
                        order.IsBuildCompleted = false;
                        order.Locked           = model.IsLocked;
                        order.UpdatedBy        = WorkContext.CurrentMembershipUser.Username;
                        order.UpdatedDate      = DateTime.Now;
                    }
                    model.AssignedSubOrders = order.SubOrders;
                    model.AssignedEmployees = order.CompanyEmployees;
                    model.OrderId           = order.Id;
                    unitOfWork.Commit();

                    SuccessNotification("保存成功");
                }
            }
            catch (Exception e)
            {
                ErrorNotification(e);
            }
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                InitModelSubOrders(model);
                InitModelEmployees(model);
            }
            return(View(model));
        }