Пример #1
0
        public ActionResult UploadProjectPlan(HttpPostedFileBase UploadPlan)
        {
            //HttpFileCollectionBase UploadPlans = Request.Files;
            //HttpPostedFileBase UploadPlan = null;
            //if (UploadPlans.Count > 0)
            //{
            //    UploadPlan = UploadPlans[0];
            //    //var tst = Request.Form["UploadPlan"];
            //}

            dbDataTable            ddt        = new dbDataTable();
            DataTable              FileRecord = ddt.Tb_ImportProjectPlant();
            dbDataTable            dbdt       = new dbDataTable();
            DataTable              dtPlan     = new DataTable();
            PM_ImportProjectPlanDL dd         = new PM_ImportProjectPlanDL();

            var model = new List <PM_ImportProjectPlan>();

            try
            {
                if (UploadPlan != null && UploadPlan.ContentLength > 0)
                {
                    if (UploadPlan.FileName.EndsWith(".csv") || UploadPlan.FileName.EndsWith(".CSV"))
                    {
                        Stream stream = UploadPlan.InputStream;
                        using (CsvReader csvPlanReader = new CsvReader(new StreamReader(stream), true))
                        {
                            FileRecord.Load(csvPlanReader);
                        }
                        List <PM_ImportProjectPlan> plan = FileRecord.ToList <PM_ImportProjectPlan>();
                        DataTable dt = dbdt.PM_ImportList();
                        foreach (var p in plan)
                        {
                            myDataTable.AddRow(dt, "Value1", p.FACode, "Value2", p.Milestone, "Value3", p.Stage, "Value4", p.Plan, "Value5", p.Forecast, "Value6", p.Target, "Value7", p.Actual,
                                               "Value8", p.Status      //, "Value9", p.OldPlan, "Value10", p.OldForecast, "Value11", p.OldTarget, "Value12", p.OldActual, "Value13", p.OldStatus
                                               );
                        }
                        dtPlan = dd.GetDataTable("Import_Project_Plan", "0", dt);
                        model  = dtPlan.ToList <PM_ImportProjectPlan>();
                    }
                    else
                    {
                        TempData["msg_error"] = "Select .csv File";
                    }
                }
                else
                {
                    TempData["msg_error"] = "No file selected";
                }
            }
            catch (Exception ex)
            {
                TempData["msg_error"] = ex.Message;
            }
            return(PartialView("~/Areas/Project/Views/ImportProjectPlan/_ProjectPlan.cshtml", model));
        }
Пример #2
0
        //public bool ManageImports(string Filter, string value, DataTable dt)
        //{
        //    try
        //    {
        //        return pdl.ManageImports(Filter, value, dt);
        //    }
        //    catch (Exception)
        //    {
        //        throw;
        //    }
        //}



        public List <PM_ImportProjectPlan> ToList(string Filter, string value = null, DataTable List = null)  //string Filter, string value, DataTable List
        {
            DataTable dt = pdl.GetDataTable(Filter, value, List);

            return(dt.ToList <PM_ImportProjectPlan>());
        }