public List <SelectListItem> Proposals() { using (FoxOfficeEntities ofc = new FoxOfficeEntities()) { List <SelectListItem> pros = ofc.PROPOSAL.Select(m => new SelectListItem { Text = SqlFunctions.StringConvert((double)m.PRONO), Value = SqlFunctions.StringConvert((double)m.PRONO) }).Distinct().ToList(); return(pros); } }
public ActionResult ppopost(Dashboard_New.Models.custom.ppo v4, string grid, string export) { if (string.IsNullOrEmpty(v4.from_dt)) { ModelState.AddModelError("From Date", "Year Required"); } if (string.IsNullOrEmpty(v4.to_dt)) { ModelState.AddModelError("To Date", "Year Required"); } if (ModelState.IsValid) { if (string.Equals("Export To Excel", export)) { FoxOfficeEntities entities = new FoxOfficeEntities(); DataTable dt = new DataTable("Grid"); dt.Columns.AddRange(new DataColumn[8] { new DataColumn("INDENT NUMBER"), new DataColumn("INDENT DATE"), new DataColumn("NAME"), new DataColumn("CURRENCY"), new DataColumn("INDENT VALUE"), new DataColumn("DEPARTMENT"), new DataColumn("STATUS"), new DataColumn("REMARKS") }); DateTime fromdt = DateTime.ParseExact(v4.from_dt, "dd/MM/yyyy", CultureInfo.InvariantCulture); DateTime todt = DateTime.ParseExact(v4.to_dt, "dd/MM/yyyy", CultureInfo.InvariantCulture); var disp = entities.Database.SqlQuery <Dashboard_New.Models.custom.ppo>(string.Format("select indent_no,indent_date,[name],currency,indent_value,dept,[status],remarks from indent_master where indent_date>= '{0}' AND indent_date<= '{1}'", fromdt.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), todt.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture))).ToList(); dt.Columns[4].DataType = typeof(Int32); foreach (var x in disp) { dt.Rows.Add(x.indent_no, x.indent_date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture), x.name, x.currency, x.indent_value, x.dept, x.status, x.remarks); } using (XLWorkbook wb = new XLWorkbook()) { wb.Worksheets.Add("Pending_Purchase_Order"); wb.Worksheet(1).Cell(3, 1).InsertTable(dt); wb.Worksheet(1).Cell(1, 7).Value = "Pending Indent : " + v4.from_dt + " To " + v4.to_dt; wb.Worksheet(1).Cell(1, 7).Style.Font.Bold = true; var wbs = wb.Worksheets.FirstOrDefault(); wbs.Tables.FirstOrDefault().ShowAutoFilter = false; wb.Properties.Title = "Pending Purchase Order Report"; using (MemoryStream stream = new MemoryStream()) { wb.SaveAs(stream); return(File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Pending_Indent.xlsx")); } } } if (string.Equals("Submit", grid)) { string from_dt = v4.from_dt; string to_dt = v4.to_dt; DateTime fromdt = DateTime.ParseExact(v4.from_dt, "dd/MM/yyyy", CultureInfo.InvariantCulture); DateTime todt = DateTime.ParseExact(v4.to_dt, "dd/MM/yyyy", CultureInfo.InvariantCulture); List <ppo> records = new List <ppo>(); try { FoxOfficeEntities vcobj = new FoxOfficeEntities(); records = vcobj.Database.SqlQuery <ppo>(string.Format("select indent_no,indent_date,[name],currency,indent_value,dept,[status],remarks from indent_master where indent_date>= '{0}' AND indent_date<= '{1}'", fromdt.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), todt.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture))).ToList(); Dashboard_New.Models.VModel dv = new VModel(); dv.ppoo = records; return(View("Ppo", dv)); } catch (Exception e) { Console.WriteLine("Erorrr : " + e); } VModel vd = new VModel(); vd.ppoo = records; return(View("Ppo", vd)); } } else { return(View("Ppo", v4)); } return(null); }