public AscmUserInfo TryGet(string id) { AscmUserInfo ascmUserInfo = null; try { string sql = "from AscmUserInfo where userId='" + id + "' or userName='******'"; IList <AscmUserInfo> ilist = YnDaoHelper.GetInstance().nHibernateHelper.FindTop <AscmUserInfo>(sql, 1); if (ilist != null && ilist.Count > 0) { ascmUserInfo = ilist[0]; } if (ascmUserInfo == null) { //判断是否erp用户 ascmUserInfo = YnDaoHelper.GetInstance().nHibernateHelper.Get <AscmUserInfo>("erp_" + id); } } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Get AscmUserInfo)", ex); throw ex; } return(ascmUserInfo); }
public void SetSupplier(AscmUserInfo ascmUserInfo) { if (ascmUserInfo != null) { //string sql = "from AscmSupplier where id in (select numberValue from AscmAkWebUserSecAttrValues where attributeCode='" + MideaAscm.Dal.FromErp.Entities.AscmAkWebUserSecAttrValues.AttributeCodeDefine.supplierUser + "' and id=" + ascmUserInfo.extExpandId + ")"; string sql = "from AscmSupplier where id in (select numberValue from AscmAkWebUserSecAttrValues where attributeCode='" + MideaAscm.Dal.FromErp.Entities.AscmAkWebUserSecAttrValues.AttributeCodeDefine.supplierUser + "' and webUserId=" + ascmUserInfo.extExpandId + ")"; //sql = "from AscmEmployee where id in (" + sql + ")"; IList <AscmSupplier> ilistAscmSupplier = YnDaoHelper.GetInstance().nHibernateHelper.Find <AscmSupplier>(sql); if (ilistAscmSupplier != null && ilistAscmSupplier.Count > 0) { ascmUserInfo.ascmSupplier = ilistAscmSupplier[0]; } } }
public AscmUserInfo Get(string id) { AscmUserInfo ascmUserInfo = null; try { ascmUserInfo = YnDaoHelper.GetInstance().nHibernateHelper.Get <AscmUserInfo>(id); } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Get AscmUserInfo)", ex); throw ex; } return(ascmUserInfo); }
public void Update(AscmUserInfo ascmUserInfo) { using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { YnDaoHelper.GetInstance().nHibernateHelper.Update <AscmUserInfo>(ascmUserInfo); tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmUserInfo)", ex); throw ex; } } }
/// <summary>手持登录</summary> public AscmUserInfo TryGet2(string userId) { AscmUserInfo ascmUserInfo = null; try { string sql = "from AscmUserInfo where extExpandId='" + userId + "'"; IList <AscmUserInfo> ilist = YnDaoHelper.GetInstance().nHibernateHelper.FindTop <AscmUserInfo>(sql, 1); if (ilist != null && ilist.Count > 0) { ascmUserInfo = ilist[0]; } } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Get AscmUserInfo)", ex); throw ex; } return(ascmUserInfo); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //提取数据 string queryWord = ""; string whereOther = "", whereMain = ""; string whereSupplier = "", whereWarehouse = "", whereMaterialItem = ""; string whereStartDeliveryTime = "", whereEndDeliveryTime = "", whereStatus = "", whereWipEntity = ""; YnFrame.Dal.Entities.YnUser ynUser = YnFrame.Web.FormsAuthenticationService.GetInstance().GetTicketUserData(); if (ynUser == null) { throw new Exception("用户错误!"); } AscmUserInfo ascmUserInfo = AscmUserInfoService.GetInstance().Get(ynUser.userId); if (ascmUserInfo.extExpandType != "erp") { throw new Exception("供应商用户错误!"); } AscmUserInfoService.GetInstance().SetSupplier(ascmUserInfo); if (ascmUserInfo.ascmSupplier == null) { throw new Exception("供应商用户错误!"); } if (Request.QueryString["queryWord"] != null && Request.QueryString["queryWord"].ToString().Trim() != "" && Request.QueryString["queryWord"].ToString().Trim() != "null") { queryWord = Request.QueryString["queryWord"].ToString(); } if (Request.QueryString["materialItem"] != null && Request.QueryString["materialItem"].ToString().Trim() != "" && Request.QueryString["materialItem"].ToString().Trim() != "null") { whereMaterialItem = "materialId = " + Request.QueryString["materialItem"].ToString(); } whereSupplier = "supplierId = " + ascmUserInfo.ascmSupplier.id + ""; if (Request.QueryString["warehouse"] != null && Request.QueryString["warehouse"].ToString().Trim() != "" && Request.QueryString["warehouse"].ToString().Trim() != "null") { whereWarehouse = "warehouseId = '" + Request.QueryString["warehouse"].ToString() + "'"; } if (Request.QueryString["status"] != null && Request.QueryString["status"].ToString().Trim() != "" && Request.QueryString["status"].ToString().Trim() != "null") { whereStatus = "status = '" + Request.QueryString["status"].ToString() + "'"; } DateTime dtStartDeliveryTime, dtEndDeliveryTime; if (Request.QueryString["startDeliveryTime"] != null && Request.QueryString["startDeliveryTime"].ToString().Trim() != "" && Request.QueryString["startDeliveryTime"].ToString().Trim() != "null" && DateTime.TryParse(Request.QueryString["startDeliveryTime"].ToString().Trim(), out dtStartDeliveryTime)) { whereStartDeliveryTime = "deliveryTime>='" + dtStartDeliveryTime.ToString("yyyy-MM-dd 00:00:00") + "'"; } if (Request.QueryString["endCreateTime"] != null && Request.QueryString["endCreateTime"].ToString().Trim() != "" && Request.QueryString["endCreateTime"].ToString().Trim() != "null" && DateTime.TryParse(Request.QueryString["endCreateTime"].ToString().Trim(), out dtEndDeliveryTime)) { whereEndDeliveryTime = "deliveryTime<'" + dtEndDeliveryTime.AddDays(1).ToString("yyyy-MM-dd 00:00:00") + "'"; } if (Request.QueryString["wipEntityId"] != null && Request.QueryString["wipEntityId"].ToString().Trim() != "" && Request.QueryString["wipEntityId"].ToString().Trim() != "null") { whereStatus = "wipEntityId = " + Request.QueryString["wipEntityId"]; } whereMain = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereMain, whereSupplier); whereMain = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereMain, whereWarehouse); whereMain = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereMain, whereStatus); whereMain = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereMain, whereStartDeliveryTime); whereMain = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereMain, whereEndDeliveryTime); whereMain = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereMain, whereWipEntity); whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereMaterialItem); if (!string.IsNullOrEmpty(whereMain)) { whereMain = "mainId in (select id from AscmDeliveryOrderMain where " + whereMain + ")"; } whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereMain); YnBaseDal.YnPage ynPage = new YnBaseDal.YnPage(); ynPage.SetPageSize(500); //pageRows; ynPage.SetCurrentPage(1); //pageNumber; List <AscmDeliveryOrderDetail> listAscmDeliveryOrderDetail = AscmDeliveryOrderDetailService.GetInstance().GetList(ynPage, "", "", queryWord, whereOther); ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("SupplierDeliveryOrderDetailReport.rdlc"); ReportDataSource rds1 = new ReportDataSource(); rds1.Name = "DataSet1"; rds1.Value = listAscmDeliveryOrderDetail; ReportViewer1.LocalReport.DataSources.Clear();//好像不clear也可以 ReportViewer1.LocalReport.DataSources.Add(rds1); //string companpyTitle = YnParameterService.GetInstance().GetValue(MyParameter.companpyTitle); string companpyTitle = "美的中央空调"; string title = companpyTitle + "送货单明细统计报表"; ReportParameter[] reportParameters = new ReportParameter[] { new ReportParameter("ReportParameter_Title", title), new ReportParameter("ReportParameter_ReportTime", "打印时间:" + DateTime.Now.ToString("yyyy-MM-dd")), new ReportParameter("ReportParameter_SupplierName", "供应商:" + ascmUserInfo.ascmSupplier.name) }; ReportViewer1.LocalReport.SetParameters(reportParameters); ReportViewer1.LocalReport.Refresh(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { YnFrame.Dal.Entities.YnUser ynUser = YnFrame.Web.FormsAuthenticationService.GetInstance().GetTicketUserData(); if (ynUser == null) { throw new Exception("用户错误!"); } AscmUserInfo ascmUserInfo = AscmUserInfoService.GetInstance().Get(ynUser.userId); string supplierName = ""; if (ascmUserInfo.extExpandType == "erp") { AscmUserInfoService.GetInstance().SetSupplier(ascmUserInfo); if (ascmUserInfo.ascmSupplier != null) { supplierName = ascmUserInfo.ascmSupplier.name; } } //if (ascmUserInfo.extExpandType != "erp") // throw new Exception("供应商用户错误!"); //AscmUserInfoService.GetInstance().SetSupplier(ascmUserInfo); //if (ascmUserInfo.ascmSupplier == null) // throw new Exception("供应商用户错误!"); //提取数据 int id = 0; List <AscmMaterialItem> list = new List <AscmMaterialItem>(); if (!string.IsNullOrEmpty(Request.QueryString["id"]) && int.TryParse(Request.QueryString["id"], out id)) { AscmMaterialItem ascmMaterialItem = AscmMaterialItemService.GetInstance().Get(id); if (ascmMaterialItem != null) { //条码 System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); if (ascmMaterialItem.docNumber != null) { #region Code128 MideaAscm.Code.BarCode128 barCode128 = new Code.BarCode128(); barCode128.TitleFont = new System.Drawing.Font("宋体", 10); barCode128.HeightImage = 50; System.Drawing.Bitmap bitmap = barCode128.GetCodeImage(ascmMaterialItem.docNumber, ascmMaterialItem.docNumber, Code.BarCode128.Encode.Code128B); bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Gif); bitmap.Dispose(); #endregion } ascmMaterialItem.materialBarcode = memoryStream.ToArray(); list.Add(ascmMaterialItem); } } ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("MaterialReport.rdlc"); ReportDataSource rds1 = new ReportDataSource(); rds1.Name = "DataSet1"; rds1.Value = list; ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(rds1); string companpyTitle = "美的中央空调"; string title = companpyTitle + "供应商送货物料条码"; ReportParameter[] reportParameters = new ReportParameter[] { new ReportParameter("ReportParameter_SupplierName", supplierName) }; ReportViewer1.LocalReport.SetParameters(reportParameters); ReportViewer1.LocalReport.Refresh(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { YnFrame.Dal.Entities.YnUser ynUser = YnFrame.Web.FormsAuthenticationService.GetInstance().GetTicketUserData(); if (ynUser == null) { throw new Exception("用户错误!"); } AscmUserInfo ascmUserInfo = AscmUserInfoService.GetInstance().Get(ynUser.userId); string supplierName = ""; if (ascmUserInfo.extExpandType == "erp") { AscmUserInfoService.GetInstance().SetSupplier(ascmUserInfo); if (ascmUserInfo.ascmSupplier != null) { supplierName = ascmUserInfo.ascmSupplier.name; } } //提取数据 List <AscmMaterialItem> sumList = new List <AscmMaterialItem>(); //最后一个装箱 AscmMaterialItem lastDetail = new AscmMaterialItem(); string ids = Request.QueryString["ids"]; string unitQuantitys = Request.QueryString["unitQuantitys"]; string totalNumbers = Request.QueryString["totalNumbers"]; bool isUnitPrint = Boolean.Parse(Request.QueryString["isUnitPrint"]); string[] listId = ids.Split(','); string[] listUnitQuantity = unitQuantitys.Split(','); string[] listTotalNumber = totalNumbers.Split(','); List <AscmMaterialItem> list = new List <AscmMaterialItem>(); for (int i = 0; i < listId.Count(); i++) { AscmMaterialItem ascmMaterialItem = AscmMaterialItemService.GetInstance().Get(Int32.Parse(listId[i])); AscmContainerUnitQuantity ascmContainerUnitQuantity = AscmContainerUnitQuantityService.GetInstance().Get(Int32.Parse(listUnitQuantity[i])); ascmMaterialItem.container = ascmContainerUnitQuantity.container; ascmMaterialItem.unitQuantity = ascmContainerUnitQuantity.unitQuantity; ascmMaterialItem.containerUnitQuantityId = ascmContainerUnitQuantity.id; ascmMaterialItem.totalNumber = Decimal.Parse(listTotalNumber[i]); list.Add(ascmMaterialItem); } if (!string.IsNullOrEmpty(ids)) { if (list != null && list.Count() > 0) { foreach (AscmMaterialItem ascmMaterialItem in list) { //条码 System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); if (ascmMaterialItem.docNumber != null) { #region Code128 MideaAscm.Code.BarCode128 barCode128 = new Code.BarCode128(); barCode128.TitleFont = new System.Drawing.Font("宋体", 10); barCode128.HeightImage = 50; System.Drawing.Bitmap bitmap = barCode128.GetCodeImage(ascmMaterialItem.docNumber, ascmMaterialItem.docNumber, Code.BarCode128.Encode.Code128B); bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Gif); bitmap.Dispose(); #endregion } ascmMaterialItem.materialBarcode = memoryStream.ToArray(); //如果是总数打印,单元数=总数 if (!isUnitPrint) { ascmMaterialItem.unitQuantity = ascmMaterialItem.totalNumber; } decimal totalNumber = ascmMaterialItem.totalNumber; //总数量 decimal unitQuantity = ascmMaterialItem.unitQuantity; //单元数 //decimal unitQuantity = 10; decimal count = decimal.Truncate(totalNumber / unitQuantity); //箱数量>=0 decimal rest = totalNumber % unitQuantity; //剩余数量>=0 //设置装箱数 2015.3.26 //总数 < 单元数 ,仅有一个箱子,总数 = 剩余数量 if (count == 0) { count = 1; } else { //有剩余数量,多出一箱 if (rest != 0) { count = count + 1; } } for (int i = 0; i < count; i++) { //最后一个为剩余数量 if (i == count - 1 && rest != 0) { lastDetail.materialBarcode = ascmMaterialItem.materialBarcode; lastDetail.docNumber = ascmMaterialItem.docNumber; lastDetail.description = ascmMaterialItem.description; lastDetail.unit = ascmMaterialItem.unit; lastDetail.unitQuantity = rest; sumList.Add(lastDetail); } else { sumList.Add(ascmMaterialItem); } } } } } ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("SupplierMaterialReport.rdlc"); ReportDataSource rds1 = new ReportDataSource(); rds1.Name = "DataSet1"; rds1.Value = sumList; ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(rds1); string companpyTitle = "美的中央空调"; string title = companpyTitle + "供应商送货物料条码"; ReportParameter[] reportParameters = new ReportParameter[] { new ReportParameter("ReportParameter_SupplierName", supplierName) }; ReportViewer1.LocalReport.SetParameters(reportParameters); ReportViewer1.LocalReport.Refresh(); } }
/*[AcceptVerbs(HttpVerbs.Post)]*/ public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { try { YnUser ynUser = AscmUserInfoService.GetInstance().TryGet(model.UserName); /* * YnUser ynUser = YnUserService.GetInstance().Get(model.UserName); * if (ynUser == null) * { * //throw new Exception("用户不存在"); * //判断是否erp用户 * ynUser = YnUserService.GetInstance().Get("erp_"+model.UserName); * if (ynUser == null) * { * //判断是否mes用户 * } * } */ if (ynUser == null) { throw new Exception("用户不存在"); } if (!string.IsNullOrEmpty(ynUser.extExpandType)) { if (ynUser.extExpandType.Trim() == "erp") { //供应商登录显示供应商名称 AscmUserInfo ascmUserInfo = (AscmUserInfo)ynUser; AscmUserInfoService.GetInstance().SetSupplier(ascmUserInfo); if (ascmUserInfo.ascmSupplier != null) { ascmUserInfo.userName1 = ascmUserInfo.ascmSupplier.name; } if (!MembershipService.ValidateUser(ynUser.userId, model.Password)) { if (Request.IsAjaxRequest()) { return(Content("用户密码错误!")); } //ModelState.AddModelError("", "提供的用户名或密码不正确。"); throw new Exception("提供的用户名或密码不正确。"); } } else if (ynUser.extExpandType.Trim() == "mes") { cn.com.midea.mespda.TransferService service = new cn.com.midea.mespda.TransferService(); cn.com.midea.mespda.OutputWebMessage message = service.UserLogin(model.UserName, model.Password); if (!message.IsSuccess) { throw new Exception(message.ErrorMessage); } } } else { if (!MembershipService.ValidateUser(ynUser.userId, model.Password)) { if (Request.IsAjaxRequest()) { return(Content("用户密码错误!")); } //ModelState.AddModelError("", "提供的用户名或密码不正确。"); throw new Exception("提供的用户名或密码不正确。"); } } //HttpCookie cookie = Request.Cookies.Get("userName"); //Response.Cookies["userName"].Value = model.UserName; string _userName = HttpUtility.UrlEncode(model.UserName); Response.Cookies["userName"].Value = _userName; Response.Cookies["userName"].Expires = DateTime.MaxValue; int days = 0; int iExpires = 0; if (days > 0) { iExpires = 60 * 60 * 24 * days;//保存天数 } //YnUser ynUser = YnUserService.GetInstance().Get(model.UserName); FormsAuthenticationService.GetInstance().SignIn(ynUser.userId, 0, ynUser, true); PageInit(null); //this.ynSite.systemUser = true;//是系统用户 //this.ynSite.siteAdmin = YnUserService.GetInstance().IsSuperAdministrator(ynUser.userId) || YnUserService.GetInstance().IsAdministrator(ynUser.userId); //this.ynSite.userName = ynUser.userName;//是系统用户 if (Request.IsAjaxRequest()) { return(JavaScript("document.location.href='';")); } if (!String.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } else { //return RedirectToAction("Index", "Home"); return(RedirectToAction("YnFrame", "YnPublic")); } } catch (Exception ex) { //throw ex; ModelState.AddModelError("", ex.Message); } } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return(View(model)); }
/// <summary>手持登录</summary> public AscmUserInfo MobileLogin(string userId, string userPwd, string connString, ref string errorMsg) { AscmUserInfo ascmUserInfo = null; errorMsg = string.Empty; using (Oracle.DataAccess.Client.OracleConnection conn = new Oracle.DataAccess.Client.OracleConnection(connString)) { if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); } Oracle.DataAccess.Client.OracleCommand cmd = new Oracle.DataAccess.Client.OracleCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT userId,userName,password,employeeId,extExpandType,extExpandId FROM ynUser WHERE extExpandId = :extExpandId"; cmd.CommandType = System.Data.CommandType.Text; Oracle.DataAccess.Client.OracleParameter parm = new Oracle.DataAccess.Client.OracleParameter(); parm.ParameterName = ":extExpandId"; parm.OracleDbType = Oracle.DataAccess.Client.OracleDbType.NVarchar2; parm.Size = 20; parm.Value = userId; parm.Direction = System.Data.ParameterDirection.Input; cmd.Parameters.Add(parm); using (Oracle.DataAccess.Client.OracleDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { cmd.Parameters.Clear(); if (reader.Read()) { ascmUserInfo = new AscmUserInfo(); ascmUserInfo.userId = reader["userId"].ToString(); ascmUserInfo.userName = reader["userName"].ToString(); ascmUserInfo.password = reader["password"].ToString(); int employeeId = 0; int.TryParse(reader["employeeId"].ToString(), out employeeId); ascmUserInfo.employeeId = employeeId; ascmUserInfo.extExpandType = reader["extExpandType"].ToString(); ascmUserInfo.extExpandId = reader["extExpandId"].ToString(); if (ascmUserInfo.extExpandType == "erp") { byte[] result = Encoding.Default.GetBytes(userPwd); System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); userPwd = BitConverter.ToString(md5.ComputeHash(result)).Replace("-", ""); if (ascmUserInfo.password != userPwd) { errorMsg = "密码不正确"; } else if (!string.IsNullOrEmpty(ascmUserInfo.userName)) { Oracle.DataAccess.Client.OracleCommand cmd2 = new Oracle.DataAccess.Client.OracleCommand(); cmd2.Connection = conn; cmd2.CommandText = "SELECT id,name FROM ascm_supplier WHERE docNumber = :docNumber"; cmd2.CommandType = System.Data.CommandType.Text; cmd2.Parameters.Add(new Oracle.DataAccess.Client.OracleParameter { ParameterName = ":docNumber", OracleDbType = Oracle.DataAccess.Client.OracleDbType.NVarchar2, Size = 20, Value = ascmUserInfo.userName, Direction = System.Data.ParameterDirection.Input }); using (Oracle.DataAccess.Client.OracleDataReader reader2 = cmd2.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { cmd2.Parameters.Clear(); if (reader2.Read()) { int id = 0; if (int.TryParse(reader2["id"].ToString(), out id)) { AscmSupplier ascmSupplier = new AscmSupplier(); ascmSupplier.id = id; ascmSupplier.name = reader2["name"].ToString(); ascmUserInfo.ascmSupplier = ascmSupplier; } } } } } } } } return(ascmUserInfo); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { YnFrame.Dal.Entities.YnUser ynUser = YnFrame.Web.FormsAuthenticationService.GetInstance().GetTicketUserData(); if (ynUser == null) { throw new Exception("用户错误!"); } AscmUserInfo ascmUserInfo = AscmUserInfoService.GetInstance().Get(ynUser.userId); if (ascmUserInfo.extExpandType != "erp") { throw new Exception("供应商用户错误!"); } AscmUserInfoService.GetInstance().SetSupplier(ascmUserInfo); if (ascmUserInfo.ascmSupplier == null) { throw new Exception("供应商用户错误!"); } //提取数据 List <AscmDeliBatSumDetail> list = new List <AscmDeliBatSumDetail>(); string ids = Request.QueryString["ids"]; if (!string.IsNullOrEmpty(ids)) { YnBaseDal.YnPage ynPage = new YnBaseDal.YnPage(); ynPage.SetPageSize(500); //pageRows; ynPage.SetCurrentPage(1); //pageNumber; list = AscmDeliBatSumDetailService.GetInstance().GetList("from AscmDeliBatSumDetail where id in(" + ids + ")"); AscmDeliBatSumDetailService.GetInstance().SetMaterial(list); AscmDeliBatSumDetailService.GetInstance().SetDeliveryOrderBatch(list); List <AscmDeliveryOrderBatch> listDeliveryOrderBatch = new List <AscmDeliveryOrderBatch>(); list.ForEach(P => listDeliveryOrderBatch.Add( new AscmDeliveryOrderBatch { id = P.batchId })); //获取货位分配 AscmDeliveryOrderBatchService.GetInstance().SetAssignWarelocation(listDeliveryOrderBatch); list.ForEach(P => P.assignWarelocation = listDeliveryOrderBatch.Find(T => T.id == P.batchId).assignWarelocation); //条码 foreach (AscmDeliBatSumDetail ascmDeliBatSumDetail in list) { System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); if (ascmDeliBatSumDetail.ascmMaterialItem != null && ascmDeliBatSumDetail.ascmMaterialItem.docNumber != null) { #region Code128 MideaAscm.Code.BarCode128 barCode128 = new Code.BarCode128(); barCode128.TitleFont = new Font("宋体", 10); barCode128.HeightImage = 50; Bitmap bitmap = barCode128.GetCodeImage(ascmDeliBatSumDetail.ascmMaterialItem.docNumber, ascmDeliBatSumDetail.ascmMaterialItem.docNumber, Code.BarCode128.Encode.Code128B); bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Gif); bitmap.Dispose(); #endregion #region Code39 //YnBaseClass2.Helper.BarCode39 barCode39 = new YnBaseClass2.Helper.BarCode39(); //barCode39.WidthCU = 10; //barCode39.WidthXI = 3; //System.Drawing.Bitmap bitmap = barCode39.CreateBarCode(ascmDeliBatSumDetail.ascmMaterialItem.docNumber, ascmDeliBatSumDetail.ascmMaterialItem.docNumber, 0, 0); ////生成图片 ////System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); //bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Gif); //bitmap.Dispose(); #endregion } ascmDeliBatSumDetail.materialBarcode = memoryStream.ToArray(); } } ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("SupplierDriverDeliveryBarCodeReport.rdlc"); ReportDataSource rds1 = new ReportDataSource(); rds1.Name = "DataSet1"; rds1.Value = list; ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(rds1); string companpyTitle = "美的中央空调"; string title = companpyTitle + "供应商送货合单条码"; ReportParameter[] reportParameters = new ReportParameter[] { new ReportParameter("ReportParameter_SupplierName", ascmUserInfo.ascmSupplier.name) }; ReportViewer1.LocalReport.SetParameters(reportParameters); ReportViewer1.LocalReport.Refresh(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { YnFrame.Dal.Entities.YnUser ynUser = YnFrame.Web.FormsAuthenticationService.GetInstance().GetTicketUserData(); if (ynUser == null) { throw new Exception("用户错误!"); } AscmUserInfo ascmUserInfo = AscmUserInfoService.GetInstance().Get(ynUser.userId); if (ascmUserInfo.extExpandType != "erp") { throw new Exception("供应商用户错误!"); } AscmUserInfoService.GetInstance().SetSupplier(ascmUserInfo); if (ascmUserInfo.ascmSupplier == null) { throw new Exception("供应商用户错误!"); } //打印的数据 List <AscmDeliBatSumDetail> sumList = new List <AscmDeliBatSumDetail>(); //最后一个装箱 AscmDeliBatSumDetail lastDetail = new AscmDeliBatSumDetail(); string ids = Request.QueryString["ids"]; string unitIds = Request.QueryString["unitIds"]; string[] listId = ids.Split(','); string[] listUnitId = unitIds.Split(','); if (!string.IsNullOrEmpty(ids)) { List <AscmDeliBatSumDetail> list = new List <AscmDeliBatSumDetail>(); for (int i = 0; i < listId.Count(); i++) { AscmDeliBatSumDetail ascmDeliBatSumDetail = AscmDeliBatSumDetailService.GetInstance().Get(Int32.Parse(listId[i])); AscmContainerUnitQuantity ascmContainerUnitQuantity = AscmContainerUnitQuantityService.GetInstance().Get(Int32.Parse(listUnitId[i])); ascmDeliBatSumDetail.container = ascmContainerUnitQuantity.container; ascmDeliBatSumDetail.materialUnitQuantity = ascmContainerUnitQuantity.unitQuantity; ascmDeliBatSumDetail.containerUnitQuantityId = ascmContainerUnitQuantity.id; list.Add(ascmDeliBatSumDetail); } if (list != null) { AscmDeliBatSumDetailService.GetInstance().SetMaterial(list); AscmDeliBatSumDetailService.GetInstance().SetDeliveryOrderBatch(list); List <AscmDeliveryOrderBatch> listDeliveryOrderBatch = new List <AscmDeliveryOrderBatch>(); list.ForEach(P => listDeliveryOrderBatch.Add( new AscmDeliveryOrderBatch { id = P.batchId })); //获取货位分配 AscmDeliveryOrderBatchService.GetInstance().SetAssignWarelocation(listDeliveryOrderBatch); list.ForEach(P => P.assignWarelocation = listDeliveryOrderBatch.Find(T => T.id == P.batchId).assignWarelocation); foreach (AscmDeliBatSumDetail ascmDeliBatSumDetail in list) { //条码 System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); if (ascmDeliBatSumDetail.ascmMaterialItem.docNumber != null) { #region Code128 MideaAscm.Code.BarCode128 barCode128 = new Code.BarCode128(); barCode128.TitleFont = new System.Drawing.Font("宋体", 10); barCode128.HeightImage = 50; System.Drawing.Bitmap bitmap = barCode128.GetCodeImage(ascmDeliBatSumDetail.batchBarCode, ascmDeliBatSumDetail.batchBarCode, Code.BarCode128.Encode.Code128B); bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Gif); bitmap.Dispose(); #endregion #region Code39 //YnBaseClass2.Helper.BarCode39 barCode39 = new YnBaseClass2.Helper.BarCode39(); //barCode39.WidthCU = 10; //barCode39.WidthXI = 3; //System.Drawing.Bitmap bitmap = barCode39.CreateBarCode(ascmDeliBatSumDetail.ascmMaterialItem.docNumber, ascmDeliBatSumDetail.ascmMaterialItem.docNumber, 0, 0); ////生成图片 ////System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); //bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Gif); //bitmap.Dispose(); #endregion } ascmDeliBatSumDetail.materialBarcode = memoryStream.ToArray(); decimal totalNumber = ascmDeliBatSumDetail.totalNumber; //总数量 decimal unitQuantity = ascmDeliBatSumDetail.materialUnitQuantity; //单元数 //decimal unitQuantity = 10; decimal count = decimal.Truncate(totalNumber / unitQuantity); //箱数量>=0 decimal rest = totalNumber % unitQuantity; //剩余数量>=0 //设置装箱数 2015.3.26 //总数 < 单元数 ,仅有一个箱子,总数 = 剩余数量 if (count == 0) { count = 1; } else { //有剩余数量,多出一箱 if (rest != 0) { count = count + 1; } } for (int i = 0; i < count; i++) { //最后一个为剩余数量 if (i == count - 1 && rest != 0) { lastDetail.ascmDeliveryOrderBatch = ascmDeliBatSumDetail.ascmDeliveryOrderBatch; lastDetail.ascmMaterialItem = ascmDeliBatSumDetail.ascmMaterialItem; lastDetail.assignWarelocation = ascmDeliBatSumDetail.assignWarelocation; lastDetail.materialUnitQuantity = rest; sumList.Add(lastDetail); } else { sumList.Add(ascmDeliBatSumDetail); } } } } } ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("SupplierDriverDeliveryDetialBarCodeReport.rdlc"); ReportDataSource rds1 = new ReportDataSource(); rds1.Name = "DataSet1"; rds1.Value = sumList; ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(rds1); string companpyTitle = "美的中央空调"; string title = companpyTitle + "供应商送货批单条码"; ReportParameter[] reportParameters = new ReportParameter[] { new ReportParameter("ReportParameter_SupplierName", ascmUserInfo.ascmSupplier.name) }; ReportViewer1.LocalReport.SetParameters(reportParameters); ReportViewer1.LocalReport.Refresh(); } }