Beispiel #1
0
        public ActionResult SaveConstractTemplateDtl(ConstractTemplateDtl dtl, int isInsert)
        {
            dtl.InDateTime = DateTime.Now;
            dtl.InUserId   = UserInfo.UserId;
            if (dtl.ContentType == "图片")
            {
                if (Request.Files != null && Request.Files.Count > 0)
                {
                    HttpPostedFileBase fileBase = Request.Files.Get(0);
                    if (fileBase.ContentLength > 0)
                    {
                        string fileName = SaveFile(fileBase, dtl.ConstractTemplateId + "_" + dtl.SeqNO);
                        dtl.TemplateContent = fileName;
                    }
                }
            }
            if (isInsert == 1)
            {
                service.ConstractTemplateDtlInsert(dtl);
            }
            else
            {
                service.ConstractTemplateDtlSave(dtl);
            }

            return(RedirectToAction("Edit/" + dtl.ConstractTemplateId));
        }
Beispiel #2
0
        public static void Export(string id, string path, string userid)
        {
            MSExcelUtil msExcelUtil = new MSExcelUtil();
            Workbook    workbook    = msExcelUtil.OpenExcelByMSExcel(path);
            Worksheet   sheet       = workbook.ActiveSheet;

            try
            {
                service.ConstractTemplateDtlDelete(new ConstractTemplateDtl()
                {
                    ConstractTemplateId = int.Parse(id)
                });
                int maxRow        = 100000;
                int startRowIndex = 2;
                while (true)
                {
                    string type    = msExcelUtil.GetCellValue(sheet, 1, startRowIndex);
                    string content = msExcelUtil.GetCellValue(sheet, 2, startRowIndex);
                    if (string.IsNullOrWhiteSpace(type))
                    {
                        break;
                    }
                    type = type.Trim();
                    ConstractTemplateDtl constractTemplateDtl = new ConstractTemplateDtl();

                    constractTemplateDtl.ConstractTemplateId = int.Parse(id);
                    constractTemplateDtl.InDateTime          = DateTime.Now;
                    constractTemplateDtl.InUserId            = userid;
                    constractTemplateDtl.OrderNO             = 0;
                    if (fixContentArray.Contains(type))
                    {
                        constractTemplateDtl.ContentType  = "固定内容";
                        constractTemplateDtl.ContentType2 = type;
                    }
                    else
                    {
                        constractTemplateDtl.ContentType     = type;
                        constractTemplateDtl.TemplateContent = content;
                    }

                    service.ConstractTemplateDtlSave(constractTemplateDtl);

                    startRowIndex++;
                    if (startRowIndex > maxRow)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.log(ex.ToString());
            }

            msExcelUtil.dispose();
        }
Beispiel #3
0
 public ActionResult DeleteConstractTemplateDtl(ConstractTemplateDtl dtl)
 {
     service.ConstractTemplateDtlDelete(dtl);
     return(Json(""));
 }