public ActionResult DeleteConfirmed(string id, int seq) { CSCOAR cSCOAR = db.CSCOARs.Find(MyHtmlHelpers.ConvertByteStrToId(id), seq); try { db.CSCOARs.Remove(cSCOAR); db.SaveChanges(); //return RedirectToAction("Details", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOAR.CONO) }); return(new RedirectResult(Url.Action("Details", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOAR.CONO) }) + "#Annual")); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { //string message = string.Format("{0}:{1}", // validationErrors.Entry.Entity.ToString(), // validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException ModelState.AddModelError(validationError.PropertyName, validationError.ErrorMessage); } } } catch (DbUpdateException ex) { UpdateException updateException = (UpdateException)ex.InnerException; if (updateException != null) { if (updateException.InnerException != null) { var sqlException = (FirebirdSql.Data.FirebirdClient.FbException)updateException.InnerException; foreach (var error in sqlException.Errors) { if (error.Message != null) { ModelState.AddModelError(string.Empty, error.Message); } } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); } cSCOAR.CSCOMSTR = db.CSCOMSTRs.Find(cSCOAR.CONO); return(View(cSCOAR)); }
private CSCOAR createNextYearRecord(CSCOAR curRec) { string sid = curRec.CONO; CSCOMSTR cSCOMSTR = db.CSCOMSTRs.Find(sid); DateTime indate = cSCOMSTR.INCDATE; // get incorporate date to determine AR due int yy = indate.Year; int mm = indate.Month; int dd = indate.Day; CSCOAR newRec = new CSCOAR(); newRec.ARNO = (short)(curRec.ARNO + 1); // WARNING assuming the next ARNO is available newRec.LASTAR = curRec.FILEDAR; newRec.CONO = curRec.CONO; int lyy = newRec.LASTAR?.Year ?? yy; lyy = lyy + 1; // add 1 year to last year File AR Date newRec.ARTOFILE = new DateTime(lyy, mm, dd); dd = 1; // reminder is set to 1 month prior to AR Due Date and on the 1st if (mm == 1) { mm = 12; lyy = lyy - 1; } else { mm = mm - 1; }; newRec.REMINDER1 = new DateTime(lyy, mm, dd); newRec.STAMP = 1; return(newRec); }
public ActionResult DeleteConfirmed(string id, int seq) { CSCOAR cSCOAR = db.CSCOARs.Find(MyHtmlHelpers.ConvertByteStrToId(id), seq); db.CSCOARs.Remove(cSCOAR); db.SaveChanges(); //return RedirectToAction("Details", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOAR.CONO) }); return(new RedirectResult(Url.Action("Details", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOAR.CONO) }) + "#Annual")); }
// GET: CSCOARs/Delete/5 public ActionResult Delete(string id, int seq) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CSCOAR cSCOAR = db.CSCOARs.Find(MyHtmlHelpers.ConvertByteStrToId(id), seq); if (cSCOAR == null) { return(HttpNotFound()); } return(View(cSCOAR)); }
public ActionResult Edit([Bind(Include = "CONO,ARNO,LASTAR,ARTOFILE,FILEDAR,REMINDER1,REM,STAMP")] CSCOAR cSCOAR) { if (ModelState.IsValid) { ASIDBConnection newdb = new ASIDBConnection(); try { CSCOAR curRec = newdb.CSCOARs.Find(cSCOAR.CONO, cSCOAR.ARNO); if (curRec.STAMP == cSCOAR.STAMP) { cSCOAR.STAMP = cSCOAR.STAMP + 1; db.Entry(cSCOAR).State = EntityState.Modified; if (cSCOAR.FILEDAR != null) // create next year record if AR is filed { string sid = cSCOAR.CONO; CSCOAR lastRec = db.CSCOARs.Where(m => m.CONO == sid).OrderByDescending(n => n.ARNO).FirstOrDefault(); if (cSCOAR.ARNO == lastRec.ARNO) // add next year record only if editing the last record { CSCOAR csRec = createNextYearRecord(cSCOAR); db.CSCOARs.Add(csRec); } } db.SaveChanges(); //return RedirectToAction("Details", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOAR.CONO) }); return(new RedirectResult(Url.Action("Details", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOAR.CONO) }) + "#Annual")); } else { ModelState.AddModelError(string.Empty, "Record is modified"); } } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); } finally { newdb.Dispose(); } } return(View(cSCOAR)); }
public ActionResult Create([Bind(Include = "CONO,ARNO,LASTAR,ARTOFILE,FILEDAR,REMINDER1,REM,STAMP")] CSCOAR cSCOAR) { if (ModelState.IsValid) { if (cSCOAR.FILEDAR != null) // create next year record if AR is filed { CSCOAR csRec = createNextYearRecord(cSCOAR); db.CSCOARs.Add(csRec); } db.CSCOARs.Add(cSCOAR); db.SaveChanges(); //return RedirectToAction("Details", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOAR.CONO) }); return(new RedirectResult(Url.Action("Details", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOAR.CONO) }) + "#Annual")); } return(View(cSCOAR)); }
// GET: CSCOARs/Create public ActionResult Create(string id) { ViewBag.Parent = MyHtmlHelpers.ConvertByteStrToId(id); string sid = ViewBag.Parent; CSCOAR lastRec = db.CSCOARs.Where(m => m.CONO == sid).OrderByDescending(n => n.ARNO).FirstOrDefault(); CSCOAR curRec = null; if (lastRec != null) { curRec = createNextYearRecord(lastRec); } else { curRec = new CSCOAR(); curRec.ARNO = 1; curRec.CONO = sid; curRec.STAMP = 0; }; curRec.CSCOMSTR = db.CSCOMSTRs.Find(curRec.CONO); return(View(curRec)); // return View(); }
public ActionResult Create([Bind(Include = "CONO,ARNO,LASTAR,ARTOFILE,FILEDAR,REMINDER1,REM,STAMP,SUBMITAR")] CSCOAR cSCOAR) { if (ModelState.IsValid) { try { if (cSCOAR.FILEDAR != null) // create next year record if AR is filed { CSCOAR csRec = createNextYearRecord(cSCOAR); db.CSCOARs.Add(csRec); } db.CSCOARs.Add(cSCOAR); db.SaveChanges(); //return RedirectToAction("Details", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOAR.CONO) }); return(new RedirectResult(Url.Action("Details", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOAR.CONO) }) + "#Annual")); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { //string message = string.Format("{0}:{1}", // validationErrors.Entry.Entity.ToString(), // validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException ModelState.AddModelError(validationError.PropertyName, validationError.ErrorMessage); } } } catch (DbUpdateException ex) { UpdateException updateException = (UpdateException)ex.InnerException; if (updateException != null) { if (updateException.InnerException != null) { var sqlException = (FirebirdSql.Data.FirebirdClient.FbException)updateException.InnerException; foreach (var error in sqlException.Errors) { if (error.Message != null) { ModelState.AddModelError(string.Empty, error.Message); } } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); } } cSCOAR.CSCOMSTR = db.CSCOMSTRs.Find(cSCOAR.CONO); return(View(cSCOAR)); }
public ActionResult Edit([Bind(Include = "CONO,ARNO,LASTAR,ARTOFILE,FILEDAR,REMINDER1,REM,STAMP,SUBMITAR")] CSCOAR cSCOAR) { if (ModelState.IsValid) { ASIDBConnection newdb = new ASIDBConnection(); try { CSCOAR curRec = newdb.CSCOARs.Find(cSCOAR.CONO, cSCOAR.ARNO); if (curRec.STAMP == cSCOAR.STAMP) { cSCOAR.STAMP = cSCOAR.STAMP + 1; db.Entry(cSCOAR).State = EntityState.Modified; if (cSCOAR.FILEDAR != null) // create next year record if AR is filed { string sid = cSCOAR.CONO; CSCOAR lastRec = db.CSCOARs.Where(m => m.CONO == sid).OrderByDescending(n => n.ARNO).FirstOrDefault(); if (cSCOAR.ARNO == lastRec.ARNO) // add next year record only if editing the last record { CSCOAR csRec = createNextYearRecord(cSCOAR); db.CSCOARs.Add(csRec); } } db.SaveChanges(); //return RedirectToAction("Details", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOAR.CONO) }); return(new RedirectResult(Url.Action("Details", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOAR.CONO) }) + "#Annual")); } else { ModelState.AddModelError(string.Empty, "Record is modified"); } } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { //string message = string.Format("{0}:{1}", // validationErrors.Entry.Entity.ToString(), // validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException ModelState.AddModelError(validationError.PropertyName, validationError.ErrorMessage); } } } catch (DbUpdateException ex) { UpdateException updateException = (UpdateException)ex.InnerException; if (updateException != null) { if (updateException.InnerException != null) { var sqlException = (FirebirdSql.Data.FirebirdClient.FbException)updateException.InnerException; foreach (var error in sqlException.Errors) { if (error.Message != null) { ModelState.AddModelError(string.Empty, error.Message); } } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } catch (Exception e) { ModelState.AddModelError(string.Empty, e.Message); } finally { newdb.Dispose(); } } cSCOAR.CSCOMSTR = db.CSCOMSTRs.Find(cSCOAR.CONO); return(View(cSCOAR)); }
public ActionResult Index(HttpPostedFileBase postedFile, string dbTableName, string dbKey, string localKey) { string filePath = string.Empty; if (postedFile != null) { string path = Server.MapPath("~/Uploads/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } filePath = path + Path.GetFileName(postedFile.FileName); string extension = Path.GetExtension(postedFile.FileName); string keyId = ""; string templine = ""; postedFile.SaveAs(filePath); IEnumerable <dynamic> csRecs = null; DataTable refTable; string usefile = ""; if (dbTableName == "CSCOMSTR") { csRecs = db.CSCOMSTRs.ToList(); //whereFunc = item => item.CONO == $"{keyId}"; //orderByFunc = item => item.CONAME; } else if (dbTableName == "CSCOSTAT") { csRecs = db.CSCOSTATs.ToList(); usefile = path + "cs_company1.csv"; } else if (dbTableName == "CSCOAR") { csRecs = db.CSCOARs.ToList(); usefile = path + "cs_company1.csv"; } //Create a DataTable. DataTable dt = new DataTable(); //addColumns(dt, companycol); //dt.Columns.AddRange(new DataColumn[3] { new DataColumn("CaseFeeId", typeof(int)), // new DataColumn("CaseFeeCode", typeof(string)), // new DataColumn("CaseFeeDesc",typeof(string)) }); //Read the contents of CSV file. string csvData = System.IO.File.ReadAllText(filePath); //Execute a loop over the rows. bool IsHeader = true; int rowcnt = 0; DataRow curRow = null; foreach (string row in csvData.Split('\n')) { if ((!IsHeader) && (!string.IsNullOrEmpty(row))) { curRow = dt.Rows.Add(); rowcnt++; int i = 1; //Execute a loop over the columns. //foreach (string cell in row.Split('\t')) foreach (string cell in row.Split('|')) { try { dt.Rows[dt.Rows.Count - 1][i] = cell ?? ""; } catch (Exception e) { Console.WriteLine(rowcnt.ToString() + " | " + e.Message); } finally { i++; } } if ((dbTableName == "CSCOSTAT") || (dbTableName == "CSCOAR")) { string myDateStr = (string)curRow["status_date"]; string mySortStr = myDateStr.Split('/')[2] + myDateStr.Split('/')[1] + myDateStr.Split('/')[0]; curRow["sort_date"] = mySortStr; } if ((localKey.Length > 0) && (DBNull.Value != curRow[localKey])) { keyId = (string)curRow[localKey] ?? ""; if (dbTableName == "CSCOMSTR") { CSCOMSTR csRec = null; Func <CSCOMSTR, bool> whereFunc = item => item.CONO == $"{keyId}"; Func <CSCOMSTR, Object> orderByFunc = item => item.CONAME; //csRec = ((List<CSCOMSTR>) csRecs).Where(whereFunc).FirstOrDefault(); csRec = ((List <CSCOMSTR>)csRecs).Where(item => item.CONO == keyId).FirstOrDefault(); if (csRec == null) { curRow["New"] = "***"; } else if (csRec.CONAME != (string)curRow["company_name"]) { curRow["New"] = "**"; } else if (csRec.INTYPE != (string)curRow["company_intype"]) { curRow["New"] = "*"; } else if (csRec.CONSTCODE != (string)curRow["company_constitution"]) { curRow["New"] = "*"; } if (DBNull.Value != curRow["company_staffid"]) { curRow["company_staffid"] = convertStaff((string)curRow["company_staffid"]); } if (DBNull.Value != curRow["company_constitution"]) { curRow["company_constitution"] = convertConst((string)curRow["company_constitution"]); } if (DBNull.Value != curRow["company_country"]) { curRow["company_country"] = convertCountry((string)curRow["company_country"]); } } //SortOrder sortOrder = SortOrder.Descending; //if (sortOrder == SortOrder.Ascending) // orderByFunc = item => item.CONO; //else if (sortOrder == SortOrder.Descending) // orderByFunc = item => item.CONAME; //db.CSCOMSTRs.OrderBy(orderByFunc); } } else { if (IsHeader) { IsHeader = false; List <string> myCol = new List <string>(); myCol.Add("New"); foreach (string cell in row.Split('|')) { try { myCol.Add(cell); } catch (Exception e) { Console.WriteLine(rowcnt.ToString() + " | " + e.Message); } finally { } } if ((dbTableName == "CSCOSTAT") || (dbTableName == "CSCOAR")) { myCol.Add("sort_date"); } string[] myArray = new string[myCol.Count]; for (int c = 0; c < myCol.Count; c++) { myArray[c] = myCol[c]; } addColumns(dt, myArray); } } } var datarow = dt.AsEnumerable(); if (dbTableName == "CSCOAR") { datarow = datarow.OrderBy(x => x.Field <string>("company_id")).ThenBy(n => n.Field <int>("ar_id")).Select(x => x); refTable = OpenTable(usefile); var csRefs = refTable.AsEnumerable(); int idx = 0; int coid = 0; string cono = ""; DateTime sdate; CSCOAR csRec = null; foreach (DataRow row in datarow) { templine = (string)row["company_id"]; coid = int.Parse(templine); cono = null; try { var corec = csRefs.Where(x => x.Field <int?>("company_id") == coid).FirstOrDefault(); if (corec != null) { cono = (string)corec["company_no"]; } else { cono = null; } if (cono != null) { datarow.ElementAt(idx)["New"] = cono; sdate = DateTime.Parse((string)(datarow.ElementAt(idx)["ar_date"])); csRec = ((List <CSCOAR>)csRecs).Where(item => item.CONO == cono && item.ARTOFILE == sdate).FirstOrDefault(); if (csRec != null) { datarow.ElementAt(idx)[7] = "Exist"; } else { CSCOAR cSCOAR = new CSCOAR(); try { ModelState.Clear(); cSCOAR.STAMP = 999; cSCOAR.CONO = cono; cSCOAR.ARTOFILE = sdate; // cSCOAR.SUBMITDATE = DateTime.Parse((string)row["ar_submissiondate"]); cSCOAR.REMINDER1 = DateTime.Parse((string)row["ar_reminderdate"]); cSCOAR.FILEDAR = DateTime.Parse((string)row["ar_fileddate"]); if (ModelState.IsValid) { int?lastRowNo = 0; try { lastRowNo = db.CSCOARs.Where(m => m.CONO == cSCOAR.CONO).Max(n => n.ARNO); } catch (Exception e) { lastRowNo = -1; } finally { }; cSCOAR.ARNO = (short)((lastRowNo ?? 0) + 1); datarow.ElementAt(idx)[6] = cSCOAR.ARNO.ToString(); db.CSCOARs.Add(cSCOAR); if (cSCOAR.FILEDAR != null) // create next year record if AR is filed { string sid = cSCOAR.CONO; CSCOAR lastRec = db.CSCOARs.Where(m => m.CONO == sid).OrderByDescending(n => n.ARNO).FirstOrDefault(); if (cSCOAR.ARNO == lastRec.ARNO) // add next year record only if editing the last record { CSCOAR csRec1 = createNextYearAR(cSCOAR); db.CSCOARs.Add(csRec1); } } db.SaveChanges(); } } catch (Exception e) { datarow.ElementAt(idx)[6] = e.Message + "!!!"; db.CSCOARs.Remove(cSCOAR); } finally {; }; }; } } catch (Exception e) { datarow.ElementAt(idx)["New"] = e.Message; } finally { idx++; } } datarow = datarow.Where(y => y.Field <string>(7) != "Exist").OrderBy(x => x.Field <string>("New")).ThenBy(y => y.Field <int>("status_id")); } else if (dbTableName == "CSCOMSTR") { datarow = datarow.Where(x => x.Field <string>("New") == "***" && x.Field <string>("company_no") != ""); datarow = datarow.OrderBy(x => x.Field <int?>("company_id")).Select(x => x); int idx = 0; foreach (DataRow row in datarow) { templine = (string)row["company_no"]; CSCOMSTR cSCOMSTR = new CSCOMSTR(); try { ModelState.Clear(); cSCOMSTR.STAMP = 999; cSCOMSTR.ARRE = "N"; cSCOMSTR.SPECIALRE = "N"; cSCOMSTR.SEQNO = 1; // set inital seqno cSCOMSTR.CONO = (string)row["company_no"]; cSCOMSTR.CONAME = (string)row["company_name"]; cSCOMSTR.INTYPE = (string)row["company_intype"]; cSCOMSTR.CONSTCODE = (string)row["company_constitution"]; cSCOMSTR.COSTATD = DateTime.Now; cSCOMSTR.INCDATE = DateTime.Parse((string)(row["company_incorporation"])); cSCOMSTR.PRINOBJStr = (string)row["company_objectives"] ?? ""; cSCOMSTR.PINDCODE = (string)row["company_industrya"] ?? ""; cSCOMSTR.SINDCODE = (string)row["company_industryb"] ?? ""; cSCOMSTR.WEB = (string)row["company_website"] ?? ""; cSCOMSTR.STAFFCODE = (string)row["company_staffid"]; cSCOMSTR.CMMTStr = (string)row["company_comment"] ?? ""; cSCOMSTR.INCCTRY = "MY"; cSCOMSTR.COSTAT = "Active"; if (DBNull.Value != row["company_remark"]) { cSCOMSTR.REM = (string)row["company_remark"] ?? ""; } if (DBNull.Value != row["company_country"]) { cSCOMSTR.INCCTRY = (string)row["company_country"]; } ; if (row["company_activate"] != DBNull.Value) { cSCOMSTR.COSTAT = (string)row["company_activate"] == "t" ? "Active" : "NotActive"; } ; if (ModelState.IsValid) { db.CSCOMSTRs.Add(cSCOMSTR); db.SaveChanges(); } } catch (Exception e) { datarow.ElementAt(idx)["company_industryb"] = "!!!"; db.CSCOMSTRs.Remove(cSCOMSTR); } finally { // db.CSCOMSTRs.Add(cSCOMSTR); idx++; } // Console.WriteLine( templine); } //db.SaveChanges(); } else if (dbTableName == "CSCOSTAT") { datarow = datarow.OrderBy(x => x.Field <string>("company_id")).ThenBy(n => n.Field <string>("sort_date")).Select(x => x); refTable = OpenTable(usefile); var csRefs = refTable.AsEnumerable(); int idx = 0; int coid = 0; string cono = ""; DateTime sdate; CSCOSTAT csRec = null; foreach (DataRow row in datarow) { templine = (string)row["company_id"]; coid = int.Parse(templine); cono = null; try { var corec = csRefs.Where(x => x.Field <int?>("company_id") == coid).FirstOrDefault(); if (corec != null) { cono = (string)corec["company_no"]; } else { cono = null; } if (cono != null) { datarow.ElementAt(idx)["New"] = cono; sdate = DateTime.Parse((string)(datarow.ElementAt(idx)["status_date"])); csRec = ((List <CSCOSTAT>)csRecs).Where(item => item.CONO == cono && item.SDATE == sdate).FirstOrDefault(); if (csRec != null) { datarow.ElementAt(idx)[7] = "Exist"; } else { CSCOSTAT cSCOSTAT = new CSCOSTAT(); try { ModelState.Clear(); cSCOSTAT.STAMP = 999; cSCOSTAT.CONO = cono; cSCOSTAT.SDATE = sdate; cSCOSTAT.FILETYPE = "A"; cSCOSTAT.COSTAT = (string)row["status_status"]; cSCOSTAT.FILELOC = (string)row["status_fileno"]; cSCOSTAT.SEALLOC = (string)row["status_sealno"]; if (ModelState.IsValid) { int?lastRowNo = 0; try { lastRowNo = db.CSCOSTATs.Where(m => m.CONO == cSCOSTAT.CONO).Max(n => n.ROWNO); } catch (Exception e) { lastRowNo = -1; } finally { }; cSCOSTAT.EDATE = cSCOSTAT.SDATE.AddDays(30000); cSCOSTAT.ROWNO = (lastRowNo ?? 0) + 1; datarow.ElementAt(idx)[6] = cSCOSTAT.ROWNO.ToString(); db.CSCOSTATs.Add(cSCOSTAT); UpdatePreviousRow(cSCOSTAT); db.SaveChanges(); } } catch (Exception e) { datarow.ElementAt(idx)[6] = e.Message + "!!!"; db.CSCOSTATs.Remove(cSCOSTAT); } finally { } } } } catch (Exception e) { datarow.ElementAt(idx)["New"] = e.Message; } finally { idx++; } } datarow = datarow.Where(y => y.Field <string>(7) != "Exist").OrderBy(x => x.Field <string>("New")).ThenBy(y => y.Field <int>("status_id")); } DataTable ndt = datarow.CopyToDataTable <DataRow>(); return(View(ndt)); string conString = ConfigurationManager.ConnectionStrings["SirisCS"].ConnectionString; using (FbConnection con = new FbConnection(conString)) { //datarow = dt.AsEnumerable(); //newrow = datarow.Where(x => x.Field<int>("Id") == 2); }; //using (SqlConnection con = new SqlConnection(conString)) //{ // using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy(con)) // { // //Set the database table name. // sqlBulkCopy.DestinationTableName = "dbo.Customers"; // //[OPTIONAL]: Map the DataTable columns with that of the database table // sqlBulkCopy.ColumnMappings.Add("Id", "CustomerId"); // sqlBulkCopy.ColumnMappings.Add("Name", "Name"); // sqlBulkCopy.ColumnMappings.Add("Country", "Country"); // con.Open(); // sqlBulkCopy.WriteToServer(dt); // con.Close(); // } // } } return(View()); }