public ActionResult export_report() { BDModel db = new BDModel(); ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Reports"), "CrystalReport.rpt")); rd.SetDataSource(db.Employee.ToList()); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); try { Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", "Employee_List.pdf")); } catch { throw; } // return View(db.Employee.ToList()); }
public ActionResult ViewEmployees() { BDModel db = new BDModel(); var data = db.Database.SqlQuery <Employee>("exec select_employee"); return(View(data)); }
public ActionResult ViewDepartments() { BDModel db = new BDModel(); var data = db.Database.SqlQuery <Department>("exec select_Department"); return(View(data)); }
// GET: Home/Delete/5 public ActionResult Delete(int id) { BDModel db = new BDModel(); SqlParameter param1 = new SqlParameter("@id", id); var data = db.Database.SqlQuery <Employee>("exec select_employee_by_id @id", param1).First(); return(View(data)); }
// GET: Home/Edit/5 public ActionResult Edit(int id) { BDModel db = new BDModel(); SqlParameter param1 = new SqlParameter("@id", id); var data = db.Database.SqlQuery <Department>("exec select_department_by_id @id", param1).First(); return(View(data)); }
/// <summary> /// 自建库 获取 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnZjk_Click(object sender, RoutedEventArgs e) { var ss = this.tbSs.Text.Trim(); if (string.IsNullOrWhiteSpace(ss)) { this.tbSs.IsError = true; this.tbSs.ErrorStr = "请输入SS号"; return; } var localList = IsExist(ss); if (localList?.Count > 0) { this.tbZjk.IsError = true; this.tbZjk.ErrorStr = "本地已存在该分享链接"; BtnSearch_Click(null, null); return; } Task.Factory.StartNew(() => { var response = HttpUtil.UpdateSource(AppData.UserName, AppData.Password, ss, AppData.Token); if (response?.code == "1") { Application.Current.Dispatcher?.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => { this.tbjf.Text = string.IsNullOrWhiteSpace(response.total) ? "0" : response.total; // var shareLinkInfo = response?.plist; if (shareLinkInfo != null) { BDModel model = new BDModel(); model.fno = shareLinkInfo.id; model.fid = shareLinkInfo.ss; model.slink = shareLinkInfo.link.Trim().Split('提')[0]; model.scode = shareLinkInfo.link.Trim().Split('提')[1].Split(':')[1].Trim(); BDService db = new BDService(); db.AddBDFile(model); var list = db.Query(" and fid = '" + ss + "';"); this.dataGrid.ItemsSource = list; } })); } }); }
public ActionResult Delete(int id, Employee collection) { try { BDModel db = new BDModel(); SqlParameter param1 = new SqlParameter("@id", collection.EmployeeID); var output = db.Database.SqlQuery <Employee>("exec delete_employee @id", param1).SingleOrDefaultAsync(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult CreateEmployee(Employee collection) { try { BDModel db = new BDModel(); SqlParameter param1 = new SqlParameter("@name", collection.Name); SqlParameter param2 = new SqlParameter("@position", collection.Position); SqlParameter param3 = new SqlParameter("@age", collection.Age); SqlParameter param4 = new SqlParameter("@salary", collection.Salary); var output = db.Database.SqlQuery <Employee>("exec insert_employee @name, @position, @age, @salary", param1, param2, param3, param4).SingleOrDefaultAsync(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult CreateDepartment(Department collection) { try { BDModel db = new BDModel(); SqlParameter param1 = new SqlParameter("@name", collection.Name); SqlParameter param2 = new SqlParameter("@description", collection.Description); var output = db.Database.SqlQuery <Employee>("exec insert_department @name, @description", param1, param2).SingleOrDefaultAsync(); //return View("Employee/Index"); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, Department collection) { try { BDModel db = new BDModel(); SqlParameter param1 = new SqlParameter("@id", collection.DepartmentID); SqlParameter param2 = new SqlParameter("@name", collection.Name); SqlParameter param3 = new SqlParameter("@description", collection.Description); var output = db.Database.SqlQuery <Department>("exec update_department @id, @name, @description", param1, param2, param3).SingleOrDefaultAsync(); return(RedirectToAction("Index")); } catch { return(View()); } }
/// <summary> /// 全字段更新 /// </summary> /// <param name="model"></param> /// <param name="where"></param> /// <returns></returns> public int UpdateFile(BDModel model, string where) { var sql = @"update FInfo set fno=@fno, fid=@fid, fname=@fname, slink=@slink, scode=@scode, remark=@remark where 1=1 "; return(SqliteHelper.ExcuteSql(sql, model)); }
/// <summary> /// 插入 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddBDFile(BDModel model) { var sql = @"insert into FInfo(fno, fid, fname, slink, scode, remarks) values(@fno, @fid, @fname, @slink, @scode, @remarks)"; return(SqliteHelper.ExcuteSql(sql, model)); }