public AscmSupplier Get(int id, string sessionKey = null) { AscmSupplier ascmSupplier = null; try { ascmSupplier = YnDaoHelper.GetInstance().nHibernateHelper.Get <AscmSupplier>(id, sessionKey); } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Get AscmSupplier)", ex); throw ex; } return(ascmSupplier); }
public void Update(AscmSupplier ascmSupplier) { using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { YnDaoHelper.GetInstance().nHibernateHelper.Update <AscmSupplier>(ascmSupplier); tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmSupplier)", ex); throw ex; } } }
private void SetSupplier(List <AscmDeliveryOrderBatch> list) { if (list != null && list.Count > 0) { var supplierIds = list.Select(P => P.supplierId).Distinct(); var count = supplierIds.Count(); string ids = string.Empty; for (int i = 0; i < count; i++) { if (!string.IsNullOrEmpty(ids)) { ids += ","; } ids += supplierIds.ElementAt(i); if ((i + 1) % 500 == 0 || (i + 1) == count) { if (!string.IsNullOrEmpty(ids)) { string sql = "from AscmSupplier where id in (" + ids + ")"; List <AscmSupplier> listAscmSupplier = null; IList <AscmSupplier> ilistAscmSupplier = YnDaoHelper.GetInstance().nHibernateHelper.Find <AscmSupplier>(sql); if (ilistAscmSupplier != null) { listAscmSupplier = YnBaseClass2.Helper.ConvertHelper.ConvertIListToList <AscmSupplier>(ilistAscmSupplier); } if (listAscmSupplier != null && listAscmSupplier.Count > 0) { MideaAscm.Services.Base.AscmSupplierService.GetInstance().SetSupplierAddress(listAscmSupplier); foreach (AscmDeliveryOrderBatch deliveryOrderBatch in list) { AscmSupplier ascmSupplier = listAscmSupplier.Find(P => P.id == deliveryOrderBatch.supplierId); if (ascmSupplier != null) { deliveryOrderBatch.ascmSupplier = ascmSupplier; } } } } ids = string.Empty; } } } }
/// <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); }