Beispiel #1
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 #2
0
 public ActionResult DeleteConstractTemplateDtl(ConstractTemplateDtl dtl)
 {
     service.ConstractTemplateDtlDelete(dtl);
     return(Json(""));
 }