Example #1
0
        private string exportexceleaction(JsonArrayParse jp)
        {
            JsonObjectCollection collection = new JsonObjectCollection();
            string flag     = "0";
            string pathName = "";

            try
            {
                pathName = "工单列表" + GetDate().ToString("yyMMddHHmmss") + getRandom(4) + ".xls";

                HSSFWorkbook workbook  = new HSSFWorkbook();
                HSSFSheet    sheet     = (HSSFSheet)workbook.CreateSheet("工单列表");
                HSSFRow      headerRow = (HSSFRow)sheet.CreateRow(0);
                headerRow.CreateCell(0).SetCellValue("工单编号");
                headerRow.CreateCell(1).SetCellValue("工单内容");
                headerRow.CreateCell(2).SetCellValue("工单日期");
                headerRow.CreateCell(3).SetCellValue("工单类型");
                headerRow.CreateCell(4).SetCellValue("要求服务时间");
                headerRow.CreateCell(5).SetCellValue("联系人");
                headerRow.CreateCell(6).SetCellValue("联系电话");
                headerRow.CreateCell(7).SetCellValue("地址");
                headerRow.CreateCell(8).SetCellValue("服务单号");
                headerRow.CreateCell(9).SetCellValue("执行部门");
                headerRow.CreateCell(10).SetCellValue("部门负责人");
                headerRow.CreateCell(11).SetCellValue("执行人");
                headerRow.CreateCell(12).SetCellValue("状态");
                headerRow.CreateCell(13).SetCellValue("是否挂起");
                headerRow.CreateCell(14).SetCellValue("是否退回");
                headerRow.CreateCell(15).SetCellValue("是否申请支援");
                headerRow.CreateCell(16).SetCellValue("响应时间");
                headerRow.CreateCell(17).SetCellValue("预约时间");
                headerRow.CreateCell(18).SetCellValue("签到时间");
                headerRow.CreateCell(19).SetCellValue("执行时间");
                headerRow.CreateCell(20).SetCellValue("完成时间");
                headerRow.CreateCell(21).SetCellValue("消单时间");
                headerRow.CreateCell(22).SetCellValue("确认消单时间");

                DateTime MinOrderDateS = default(DateTime);
                DateTime MaxOrderDateS = default(DateTime);
                if (jp.getValue("MinOrderDate") != "")
                {
                    MinOrderDateS = ParseDateForString(jp.getValue("MinOrderDate"));
                }
                if (jp.getValue("MaxOrderDate") != "")
                {
                    MaxOrderDateS = ParseDateForString(jp.getValue("MaxOrderDate"));
                }

                bool?IsBackS   = null;
                bool?IsHangUpS = null;
                if (jp.getValue("IsBackS") != "")
                {
                    IsBackS = bool.Parse(jp.getValue("IsBackS"));
                }
                if (jp.getValue("IsHangUpS") != "")
                {
                    IsHangUpS = bool.Parse(jp.getValue("IsHangUpS"));
                }

                string AlloUser = jp.getValue("AlloUserS");
                //非管理员登录,只能看到当前用户为部门负责人的单
                if (user.Entity.UserType.ToUpper() == "03" || user.Entity.UserType.ToUpper() == "07" || user.Entity.UserType.ToUpper() == "08")
                {
                    AlloUser = user.Entity.UserNo;
                }

                int rowIndex = 1;
                project.Business.Order.BusinessWorkOrder bc = new project.Business.Order.BusinessWorkOrder();
                foreach (project.Entity.Order.EntityWorkOrder it in bc.GetWorkOrderListQuery(
                             "A", jp.getValue("OrderNoS"), jp.getValue("OrderNameS"), MinOrderDateS, MaxOrderDateS, jp.getValue("StatusS"),
                             jp.getValue("SaleNoS"), jp.getValue("RegionS"), jp.getValue("AlloDeptS"), AlloUser,
                             jp.getValue("CustNoS"), jp.getValue("OrderTypeS"), IsBackS, IsHangUpS, false))
                {
                    HSSFRow dataRow = (HSSFRow)sheet.CreateRow(rowIndex);
                    dataRow.CreateCell(0).SetCellValue(it.OrderNo);
                    dataRow.CreateCell(1).SetCellValue(it.OrderName);
                    dataRow.CreateCell(2).SetCellValue(ParseStringForDateTime(it.OrderDate));
                    dataRow.CreateCell(3).SetCellValue(it.OrderTypeName);
                    dataRow.CreateCell(4).SetCellValue(ParseStringForDateTime(it.CustneedTime));
                    dataRow.CreateCell(5).SetCellValue(it.LinkMan);
                    dataRow.CreateCell(6).SetCellValue(it.LinkTel);
                    dataRow.CreateCell(7).SetCellValue(it.Addr);
                    dataRow.CreateCell(8).SetCellValue(it.SaleNo);
                    dataRow.CreateCell(9).SetCellValue(it.AlloDeptName);
                    dataRow.CreateCell(10).SetCellValue(it.AlloUserName);
                    dataRow.CreateCell(11).SetCellValue(it.PersonName);
                    dataRow.CreateCell(12).SetCellValue(it.StatusName);
                    dataRow.CreateCell(13).SetCellValue(it.IsHangUp?"是":"否");
                    dataRow.CreateCell(14).SetCellValue(it.IsBack?"是":"否");
                    dataRow.CreateCell(15).SetCellValue(it.IsApply?"是":"否");
                    dataRow.CreateCell(16).SetCellValue(ParseStringForDateTime(it.ResponseTime));
                    dataRow.CreateCell(17).SetCellValue(ParseStringForDateTime(it.AppoIntTime));
                    dataRow.CreateCell(18).SetCellValue(ParseStringForDateTime(it.SignTime));
                    dataRow.CreateCell(19).SetCellValue(ParseStringForDateTime(it.WorkTime));
                    dataRow.CreateCell(20).SetCellValue(ParseStringForDateTime(it.FinishTime));
                    dataRow.CreateCell(21).SetCellValue(ParseStringForDateTime(it.CloseTime));
                    dataRow.CreateCell(22).SetCellValue(ParseStringForDateTime(it.ConfirmTime));
                    dataRow = null;
                    rowIndex++;
                }

                MemoryStream ms = new MemoryStream();
                workbook.Write(ms);
                headerRow = null;
                sheet     = null;
                workbook  = null;
                FileStream   fs = new FileStream(localpath + pathName, FileMode.OpenOrCreate);
                BinaryWriter w  = new BinaryWriter(fs);
                w.Write(ms.ToArray());
                fs.Close();
                ms.Close();
                ms.Dispose();
            }
            catch (Exception ex)
            {
                flag = "2";
                collection.Add(new JsonStringValue("ex", ex.ToString()));
            }

            collection.Add(new JsonStringValue("type", "exportexcel"));
            collection.Add(new JsonStringValue("flag", flag));
            collection.Add(new JsonStringValue("path", pathName));
            return(collection.ToString());
        }
Example #2
0
        private string createList(string OrderNo, string OrderName, string MinOrderDate, string MaxOrderDate, string Status,
                                  string SaleNo, string Region, string AlloDept, string AlloUser, string CustNo, string OrderType, string IsBack, string IsHangUp, int page)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder("");

            sb.Append("<table class=\"table table-border table-bordered table-hover table-bg table-sort\" id=\"tablelist\">");
            sb.Append("<thead>");
            sb.Append("<tr class=\"text-c\">");
            sb.Append("<th width=\"4%\">序号</th>");
            sb.Append("<th width='13%'>客户名称</th>");
            sb.Append("<th width='9%'>工单号</th>");
            sb.Append("<th width='18%'>工作内容</th>");
            sb.Append("<th width='10%'>工单日期</th>");
            sb.Append("<th width='9%'>工单类型</th>");
            sb.Append("<th width='7%'>联系人</th>");
            sb.Append("<th width='8%'>电话</th>");
            sb.Append("<th width='7%'>发起人</th>");
            sb.Append("<th width='5%'>状态</th>");
            sb.Append("<th width='5%'>挂起</th>");
            sb.Append("<th width='5%'>退回</th>");
            sb.Append("</tr>");
            sb.Append("</thead>");

            DateTime MinOrderDateS = default(DateTime);
            DateTime MaxOrderDateS = default(DateTime);

            if (MinOrderDate != "")
            {
                MinOrderDateS = ParseDateForString(MinOrderDate);
            }
            if (MinOrderDate != "")
            {
                MinOrderDateS = ParseDateForString(MinOrderDate);
            }

            bool?IsBackS   = null;
            bool?IsHangUpS = null;

            if (IsBack != "")
            {
                IsBackS = bool.Parse(IsBack);
            }
            if (IsHangUp != "")
            {
                IsHangUpS = bool.Parse(IsHangUp);
            }

            //非管理员登录,只能看到当前用户为部门负责人的单
            if (user.Entity.UserType.ToUpper() == "03" || user.Entity.UserType.ToUpper() == "07" || user.Entity.UserType.ToUpper() == "08")
            {
                AlloUser = user.Entity.UserNo;
            }

            int r = 1;

            sb.Append("<tbody>");
            Business.Order.BusinessWorkOrder bc = new project.Business.Order.BusinessWorkOrder();
            foreach (Entity.Order.EntityWorkOrder it in bc.GetWorkOrderListQuery(user.Entity.AccID, OrderNo, OrderName, MinOrderDateS, MaxOrderDateS, Status,
                                                                                 SaleNo, Region, AlloDept, AlloUser, CustNo, OrderType, IsBackS, IsHangUpS, false, page, 15))
            {
                sb.Append("<tr class=\"text-c\" id=\"" + it.InnerEntityOID + "\">");
                sb.Append("<td align='center'>" + r.ToString() + "</td>");
                sb.Append("<td>" + it.CustName + "</td>");
                sb.Append("<td>" + it.OrderNo + "</td>");
                sb.Append("<td>" + it.OrderName + "</td>");
                sb.Append("<td>" + it.OrderDate.ToString("yyyy-MM-dd HH:mm") + "</td>");
                sb.Append("<td>" + it.OrderTypeName + "</td>");
                sb.Append("<td>" + it.LinkMan + "</td>");
                sb.Append("<td>" + it.LinkTel + "</td>");
                sb.Append("<td>" + it.CreateUserName + "</td>");
                sb.Append("<td>" + it.StatusName + "</td>");
                sb.Append("<td class=\"td-status\"><span class=\"label " + (it.IsHangUp ? "" : "label-success") + " radius\">" + (it.IsHangUp ? "挂起" : "正常") + "</span></td>");
                sb.Append("<td class=\"td-status\"><span class=\"label " + (it.IsBack ? "" : "label-success") + " radius\">" + (it.IsBack ? "退回" : "正常") + "</span></td>");
                sb.Append("</tr>");

                r++;
            }
            sb.Append("</tbody>");
            sb.Append("</table>");

            sb.Append(Paginat(bc.GetWorkOrderListCount(user.Entity.AccID, OrderNo, OrderName, MinOrderDateS, MaxOrderDateS, Status,
                                                       SaleNo, Region, AlloDept, AlloUser, CustNo, OrderType, IsBackS, IsHangUpS, false), pageSize, page, 7));
            return(sb.ToString());
        }