示例#1
0
        public ActionResult Download(Company_Code model)
        {
            try
            {
                XLWorkbook xlWorkBook  = new XLWorkbook();
                var        xlWorkSheet = xlWorkBook.Worksheets.Add("Master CompanyCode");// xlWorkSheet;

                xlWorkSheet.Cell(1, 1).Value = "CompanyCode";
                xlWorkSheet.Cell(1, 2).Value = "CompanyName";

                ICompanyCodeService svc = new CompanyCodeService();
                var Data = svc.GetAll();
                int Row  = 2;
                if (Data.Count > 0)
                {
                    for (int i = 0; i < Data.Count; i++)
                    {
                        xlWorkSheet.Cell(Row + i, 1).Value = Data[i].companyCode;
                        xlWorkSheet.Cell(Row + i, 2).Value = Data[i].companyName;
                    }
                    xlWorkSheet.Columns().AdjustToContents();
                    var path = Server.MapPath("..") + "\\Master-CompanyCode.xlsx";
                    xlWorkBook.SaveAs(path);
                    xlWorkBook.Dispose();
                    return(File(path, "application/vnd.ms-excel", "Master-CompanyCode.xlsx"));
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                general.AddLogError("CompanyCode Download", ex.Message, ex.StackTrace);
                return(View("~/Views/Master/CompanyCode/Index.cshtml", model));
            }
        }
        public Company_Code Add(Company_Code model)
        {
            var dc = new eprocdbDataContext();

            dc.Company_Codes.InsertOnSubmit(model);
            dc.SubmitChanges();
            return(model);
        }
示例#3
0
 public ActionResult Edit(string companyCode, Company_Code model)
 {
     try
     {
         ICompanyCodeService svc = new CompanyCodeService();
         var result = svc.Edit(companyCode, model);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         general.AddLogError("CompanyCode Edit", ex.Message, ex.StackTrace);
         return(View("~/Views/Master/CompanyCode/Index.cshtml", model));
     }
 }
        public Company_Code Edit(string companyCode, Company_Code model)
        {
            var dc = new eprocdbDataContext();
            var md = (from c in dc.Company_Codes where c.companyCode == companyCode select c).SingleOrDefault();

            md.companyName = model.companyName;
            if (model.status == null)
            {
                md.status = md.status;
            }
            else
            {
                md.status = model.status;
            }
            dc.SubmitChanges();
            return(model);
        }
示例#5
0
 public ActionResult Add(Company_Code model)
 {
     try
     {
         ICompanyCodeService svc = new CompanyCodeService();
         var result = svc.Add(model);
         this.ViewBag.Status = new SelectList(this.GetStatus(), "Key", "Value");
         this.AddNotification("Your Data Has Been Successfully Saved. ", NotificationType.SUCCESS);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         general.AddLogError("CompanyCode Add", ex.Message, ex.StackTrace);
         this.AddNotification("ID exist", NotificationType.ERROR);
         this.ViewBag.Status = new SelectList(this.GetStatus(), "Key", "Value");
         return(View("~/Views/Master/CompanyCode/Add.cshtml"));
     }
 }