//添加写入信息//修改我写入的信息 public ActionResult AddEditData(T_FGJHtmlData tfhd) { if (tfhd.ID > 0)//修改 { if (T_FGJHtmlDataService.EditEntity(tfhd)) { return(Json(new { ret = "ok", msg = "修改成功" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { ret = "no", msg = "在修改过程中出现未知错误,请联系管理员!" }, JsonRequestBehavior.AllowGet)); } } else { tfhd.AddItemsUserID = LoginUser.ID; tfhd.Laiyuan = "AddDAT"; tfhd.Pingmi_int = decimal.Parse(Request["FwMianji"]); tfhd.Money_int = decimal.Parse(Request["Smoney"]); tfhd.FwSumMoney = Request["Amoney"] + "万(单价" + tfhd.Money_int + "元/㎡)"; tfhd.FwHuXing = Request["HXs"] + "室" + Request["HXt"] + "厅" + Request["HXw"] + "卫"; tfhd.SumMoneyID = AllClass.GetMoney(Request["Smoney"].ToString()); tfhd.MianjiID = AllClass.GeiMinji(tfhd.FwMianji); tfhd.HuXingID = AllClass.GetHuxing(tfhd.FwHuXing); tfhd.AddUserTiem = MvcApplication.GetT_time(); tfhd.HLhref = ""; tfhd.Image_str = tfhd.Image_str != null?tfhd.Image_str.Trim().Length > 0 ? "有---" + tfhd.Image_str : tfhd.Image_str : tfhd.Image_str; var DisctD = T_FGJHtmlDataService.LoadEntities(x => x.photo == tfhd.photo && x.HLName == tfhd.HLName).FirstOrDefault(); if (DisctD != null) { return(Json(new { ret = "no", msg = "要新增的信息中电话与信息名称在数据库中的有重复,请核对信息在添加!" }, JsonRequestBehavior.AllowGet)); } T_FGJHtmlDataService.AddEntity(tfhd); return(Json(new { ret = "ok", msg = "添加成功!" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Te() { int Tempoid = 1; DateTime CurrentDate = new DateTime(); CurrentDate = GetCurrentSession.CurrentDateTime(); #region Print string joindata = string.Join(", ", "1,2,3"); SqlParameter param1 = new SqlParameter("@Var", joindata); List <rptCustomer> rptCustomerList = db.Database.SqlQuery <rptCustomer>("SP_PickUpboy @Var", param1).ToList(); var LoginList = db.Logins.ToList(); string PrintBy = string.Empty; int CurrentUser = (int)GetCurrentSession.CurrentUser(); var login = LoginList.FirstOrDefault(t => t.LoginID == CurrentUser); if (login != null) { PrintBy = login.FirstName + " " + login.LastName; } //List<rptCustomer> rptCustomerList = context.Database.SqlQuery<rptCustomer>("SP_PickUpboy @Var", param1).ToList<rptCustomer>(); DataTable dtBoyName = new DataTable(); dtBoyName.Columns.Add("Name", typeof(string)); var boy = db.PickUpBoys.FirstOrDefault(t => t.PickUpBoyID == Tempoid); if (boy != null) { dtBoyName.Rows.Add("Delivery Boy:- " + boy.PickUpBoyName + "\t Print By:- " + PrintBy); } else { dtBoyName.Rows.Add(""); } DataTable dtCustomer = new DataTable(); dtCustomer.Columns.Add("LRNo", typeof(string)); dtCustomer.Columns.Add("CustomerName", typeof(string)); dtCustomer.Columns.Add("PayTypeStatus", typeof(string)); dtCustomer.Columns.Add("Amount", typeof(decimal)); dtCustomer.Columns.Add("Total", typeof(decimal)); dtCustomer.Columns.Add("Damrage", typeof(decimal)); dtCustomer.Columns.Add("Hamali", typeof(decimal)); dtCustomer.Columns.Add("NoOfParcel", typeof(int)); dtCustomer.Columns.Add("CustomerNumber", typeof(string)); foreach (var item in rptCustomerList) { dtCustomer.Rows.Add(item.LRNo, item.CustomerName, item.PayTypeStatus, item.Amount, item.Total, item.Damrage, item.Hamali * item.NoOfParcel, item.NoOfParcel, item.CustomerNumber); } DataSet1 myds = new DataSet1(); myds.Tables["DtPickupBoy"].Merge(dtCustomer); myds.Tables["DtBoyName"].Merge(dtBoyName); ReportDocument rptH = new ReportDocument(); rptH.Load(Server.MapPath("~/Reports/rptPickUpboy.rpt")); rptH.SetDataSource(myds); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); string htmlfilename = DateTime.Now.ToString("yyyyMMddHHmmssfff"); string path = Server.MapPath("~/PDF"); AllClass.CreateDirectory(path); string fileName = path + "/" + htmlfilename + ".pdf"; string fileName2 = htmlfilename + ".pdf"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } rptH.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, fileName); JsonResult result = new JsonResult(); result.Data = fileName2; return(result); #endregion }