public void AddOperFunc(OperFunc func) { try { conn = ConnectionPool.BorrowConnection(); trans = conn.BeginTransaction(); EntityMapping.Create(func, trans); trans.Commit(); } catch (BusinessException bex) //业务异常 { //LogAdapter.WriteBusinessException(bex); trans.Rollback(); throw new BusinessException(bex.Type, bex.Message); } catch (SqlException sex) //数据库异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteDatabaseException(sex); throw new BusinessException("数据库异常", sex.Message); } catch (Exception ex) //其他异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteFeaturesException(ex); throw new BusinessException("其它异常", ex.Message); } finally { ConnectionPool.ReturnConnection(conn); } }
// 这里写你的代码 public static int GetOperID(SqlTransaction trans) { OperID operid = new OperID(); operid.cnvcFill = "1"; return(Convert.ToInt32(EntityMapping.Create(operid, trans))); }
public static decimal GetSerialNo(SqlConnection conn) { SerialNo serialNo = new SerialNo(); serialNo.cnvcFill = "0"; return(Convert.ToDecimal(EntityMapping.Create(serialNo, conn))); }
public void UpdateOrder(OrderBook order, OperLog operLog) //,BusiLog busiLog) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); OrderBook oldOrder = new OrderBook(); oldOrder.cnnOrderSerialNo = order.cnnOrderSerialNo; oldOrder = EntityMapping.Get(oldOrder, trans) as OrderBook; if (oldOrder == null) { throw new Exception("订单未找到"); } oldOrder.cnvcOrderOperID = order.cnvcOrderOperID; oldOrder.cnvcOrderType = order.cnvcOrderType; oldOrder.cnvcProduceDeptID = order.cnvcProduceDeptID; oldOrder.cnvcOrderDeptID = order.cnvcOrderDeptID; if (oldOrder.cnvcOrderType == "WDO") { oldOrder.cndArrivedDate = order.cndArrivedDate; oldOrder.cnvcLinkPhone = order.cnvcLinkPhone; oldOrder.cnvcShipAddress = order.cnvcShipAddress; oldOrder.cnvcCustomName = order.cnvcCustomName; } //order.cnnOrderSerialNo = decimal.Parse(txtOrderSerialNo.Text); oldOrder.cndShipDate = order.cndShipDate; EntityMapping.Update(oldOrder, trans); operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "订单流水:" + oldOrder.cnnOrderSerialNo; EntityMapping.Create(operLog, trans); //EntityMapping.Create(busiLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
public void UpdateAssignLog(AssignDetail detail, OperLog operLog) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { // // AssignDetail detail = new AssignDetail(); // detail.cnnAssignSerialNo = detailLog.cnnAssignSerialNo; // detail.cnnOrderSerialNo = detailLog.cnnOrderSerialNo; // detail.cnvcProductCode = detailLog.cnvcProductCode; AssignDetail detailOld = EntityMapping.Get(detail, trans) as AssignDetail; if (detail.cnnCount != detailOld.cnnCount) { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); OrderSerialNo serialNo = new OrderSerialNo(); serialNo.cnvcFill = "0"; serialNo.cnnSerialNo = Convert.ToDecimal(EntityMapping.Create(serialNo, trans)); detailOld.cnnCount = detail.cnnCount; detailOld.cnnSum = Math.Round(detail.cnnCount * detailOld.cnnPrice, 2); EntityMapping.Update(detailOld, trans); AssignDetailLog detailLog = new AssignDetailLog(detailOld.ToTable()); detailLog.cnvcOperID = operLog.cnvcOperID; detailLog.cndOperDate = dtSysTime; detailLog.cnnSerialNo = serialNo.cnnSerialNo; EntityMapping.Create(detailLog, trans); operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "生产流水:" + detail.cnnAssignSerialNo.ToString() + ",日志流水:" + serialNo.cnnSerialNo.ToString(); EntityMapping.Create(operLog, trans); } trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
/// <summary> /// 生成序列号 /// </summary> /// <param name="trans"></param> /// <returns></returns> public static decimal GetSerialNo(SqlTransaction trans) { SerialNo serialNo = new SerialNo(); serialNo.cnvcFill = "0"; return(Convert.ToDecimal(EntityMapping.Create(serialNo, trans))); }
public void UpdateBook(Book book, OperLog operLog) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); Entity.Book oldbook = new Book(); oldbook.cnnSerialNo = book.cnnSerialNo; oldbook = EntityMapping.Get(oldbook, trans) as Book; if (oldbook == null) { throw new Exception("未找到留言内容!"); } if (oldbook.cnvcState != "0") { throw new Exception("已确认的留言不能修改!"); } oldbook.cnvcBook = book.cnvcBook; oldbook.cmvcPublishID = book.cmvcPublishID; oldbook.cnvcPublishName = book.cnvcPublishName; oldbook.cndPublishDate = dtSysTime; oldbook.cnvcCheckDept = book.cnvcCheckDept; oldbook.cnvcCheckID = string.Empty; oldbook.cnvcCheckName = string.Empty; oldbook.cndcheckDate = DateTime.MinValue; EntityMapping.Update(oldbook, trans); operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "留言本流水号:" + oldbook.cnnSerialNo.ToString(); EntityMapping.Create(operLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
/// <summary> /// 展厅流水 /// </summary> /// <returns></returns> /// #region public static int getShowSerialNo() { int iSerialNo = 0; ShowSerialNo serial = new ShowSerialNo(); serial.cnvcFill = "0"; iSerialNo = (int)EntityMapping.Create(serial); return(iSerialNo); }
/// <summary> /// 操作流水 /// </summary> /// <returns></returns> /// #region public static decimal getSerialNo() { decimal dSerialNo = 0; SeqSerialNo serial = new SeqSerialNo(); serial.cnvcFill = "0"; dSerialNo = EntityMapping.Create(serial); return(dSerialNo); }
private void SyncGoods(Entity.Inventory inv, SqlTransaction trans) { //string strsql = "SELECT * FROM tbProductClass where cnvcproductclasscode='"+inv.cnvcInvCCode+"'"; //DataTable dtpc = SqlHelper.ExecuteDataTable(trans,CommandType.Text,strsql); // if(dtpc.Rows.Count>0) // { //Entity.ProductClass pc = new ProductClass(dtpc); // if(pc.cnvcProductType == "FINALPRODUCT") // { string strsql = "select * from tbGoods where vcGoodsID='" + inv.cnvcInvCode + "'"; DataTable dtGoods = SqlHelper.ExecuteDataTable(trans, CommandType.Text, strsql); if (inv.cnbSale) { if (dtGoods.Rows.Count == 0) { Entity.Goods gs = new Goods(); gs.vcGoodsID = inv.cnvcInvCode; gs.vcGoodsName = inv.cnvcInvName; gs.vcSpell = Helper.GetChineseSpell(inv.cnvcInvName); gs.nPrice = Convert.ToDecimal(inv.cnfRetailPrice); gs.nRate = 0; gs.iIgValue = -1; gs.cNewFlag = "0"; gs.vcComments = "存货档案添加同步"; EntityMapping.Create(gs, trans); } else { Entity.Goods gs = new Goods(dtGoods); if (gs.vcGoodsName != inv.cnvcInvName) { gs.vcGoodsName = inv.cnvcInvName; gs.vcSpell = Helper.GetChineseSpell(inv.cnvcInvName); } if (inv.cnfRetailPrice > 0) { gs.nPrice = Convert.ToDecimal(inv.cnfRetailPrice); } gs.vcComments = "存货档案修改同步"; EntityMapping.Update(gs, trans); } } else { if (dtGoods.Rows.Count > 0) { Entity.Goods gs = new Goods(dtGoods); EntityMapping.Delete(gs, trans); } } //} //} }
public static void AddProject(Project project, Oper oper) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); project.cnvcOperID = oper.cnvcOperID; project.cndOperDate = dtSysTime; //project.cndCreateDate = dtSysTime; project.cnnProjectID = Helper.GetSerialNo(trans); project.cnvcIsSucess = "0"; if (project.cnvcMgr == oper.cnvcOperID || project.cnvcTradeMgr == oper.cnvcOperID) { project.cnvcProjectState = "P002"; } else { project.cnvcProjectState = "P001"; } EntityMapping.Create(project, trans); BusiLog busiLog = new BusiLog(); busiLog.cndOperDate = dtSysTime; busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans); busiLog.cnvcComments = project.cnvcProjectName; busiLog.cnvcFuncCode = " 添加商机"; busiLog.cnvcOperID = oper.cnvcOperID; busiLog.cnvcIPAddress = ""; EntityMapping.Create(busiLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
public static void BatchCustInfo(DataTable dt, Oper oper) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); foreach (DataRow dr in dt.Rows) { Cust cu = new Cust(dr); cu.cnvcOperID = oper.cnvcOperID; cu.cndOperDate = dtSysTime; //newOper.cndCreateDate = dtSysTime; string strCount = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select count(*) from tbCust where cnnCustID = " + cu.cnnCustID + " or cnvcName='" + cu.cnvcName + "'").ToString(); if (Convert.ToInt32(strCount) > 0) { throw new Exception(cu.cnvcName + "已存在"); } EntityMapping.Create(cu, trans); BusiLog busiLog = new BusiLog(); busiLog.cndOperDate = dtSysTime; busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans); busiLog.cnvcComments = cu.cnvcName; busiLog.cnvcFuncCode = " 批量添加客户档案"; busiLog.cnvcOperID = oper.cnvcOperID; busiLog.cnvcIPAddress = ""; EntityMapping.Create(busiLog, trans); } trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
//减单 public void OrderReduce(string strOrderSerialNo, string strReduceType, string strAddComments, DataTable dtOrderReduce, OperLog operLog) //,BusiLog busiLog) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); OrderSerialNo serialNo = new OrderSerialNo(); serialNo.cnvcFill = "0"; serialNo.cnnSerialNo = Convert.ToDecimal(EntityMapping.Create(serialNo, trans)); foreach (DataRow drOrderReduce in dtOrderReduce.Rows) { OrderReduceLog orderReduce = new OrderReduceLog(drOrderReduce); orderReduce.cnnOrderSerialNo = decimal.Parse(strOrderSerialNo); orderReduce.cnnReduceSerialNo = serialNo.cnnSerialNo; orderReduce.cnvcReduceType = strReduceType; orderReduce.cnvcReduceComments = strAddComments; orderReduce.cndOperDate = dtSysTime; orderReduce.cnvcOperID = operLog.cnvcOperID; orderReduce.cnvcReduceState = "0"; orderReduce.cnnReduceCount = decimal.Parse(drOrderReduce["cnnOrderCount"].ToString()); EntityMapping.Create(orderReduce, trans); } operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "订单流水:" + strOrderSerialNo; EntityMapping.Create(operLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
public void AddProductLostSerial(ArrayList alLostSerial, OperLog operLog) //,BusiLog busiLog) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); SerialNo serialNo = new SerialNo(); serialNo.cnvcFill = "0"; serialNo.cnnSerialNo = Convert.ToInt32(EntityMapping.Create(serialNo, trans)); for (int i = 0; i < alLostSerial.Count; i++) { LostSerial ls = (LostSerial)alLostSerial[i]; ls.cnvcLostType = "0"; ls.cndOperDate = dtSysTime; ls.cnnLostSerialNo = serialNo.cnnSerialNo; EntityMapping.Create(ls, trans); // ProductLostSerialLog productLostSerialLog = new ProductLostSerialLog(productLostSerial.ToTable()); // //productSerialLog.cnnSerialNo = null; // productLostSerialLog.cnnProductLostSerialNo = serialNo.cnnSerialNo; // EntityMapping.Create(productLostSerialLog, trans); } operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "生产产品报损,报损流水:" + serialNo.cnnSerialNo.ToString(); EntityMapping.Create(operLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
public void AdjustProductLostSerial_Add(LostSerial ls, OperLog operLog) //,BusiLog busiLog) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); LostSerial oldls = EntityMapping.Get(ls, trans) as LostSerial; if (oldls == null) { throw new Exception("未找到对应报损流水的产品!"); } oldls.cnnAddCount = ls.cnnAddCount; oldls.cnnReduceCount = ls.cnnReduceCount; oldls.cnvcOperID = operLog.cnvcOperID; oldls.cndOperDate = dtSysTime; EntityMapping.Update(oldls, trans); // ProductLostSerialLog productLostSerialLog = new ProductLostSerialLog(oldProductLostSerial.ToTable()); // productLostSerialLog.cnnProductLostSerialNo = oldProductLostSerial.cnnSerialNo; // EntityMapping.Create(productLostSerialLog, trans); operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "生产产品报损调整,报损流水:" + oldls.cnnLostSerialNo.ToString() + ",产品编码:" + ls.cnvcInvCode; EntityMapping.Create(operLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
public int UpdateWareHouse(OperLog operLog, Entity.Warehouse wh) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); Entity.Warehouse oldwh = new AMSApp.zhenghua.Entity.Warehouse(); oldwh.cnvcWhCode = wh.cnvcWhCode; oldwh = EntityMapping.Get(oldwh, trans) as AMSApp.zhenghua.Entity.Warehouse; oldwh.cnvcWhName = wh.cnvcWhName; oldwh.cnvcDepCode = wh.cnvcDepCode; oldwh.cnvcWhAddress = wh.cnvcWhAddress; oldwh.cnvcWhPhone = wh.cnvcWhPhone; oldwh.cnvcWhPerson = wh.cnvcWhPerson; oldwh.cnvcWhValueStyle = wh.cnvcWhValueStyle; oldwh.cnbFreeze = wh.cnbFreeze; oldwh.cnnFrequency = wh.cnnFrequency; oldwh.cnvcFrequency = wh.cnvcFrequency; oldwh.cnvcWhProperty = wh.cnvcWhProperty; oldwh.cnbShop = wh.cnbShop; EntityMapping.Update(oldwh, trans); operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "仓库编码:" + oldwh.cnvcWhCode; EntityMapping.Create(operLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); return(-1); } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); return(-1); } finally { ConnectionPool.ReturnConnection(conn); } return(1); } }
public void BatchUpdateProduceCheck(ArrayList alCheck, string strProduceSerialNo, OperLog operLog) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); for (int i = 0; i < alCheck.Count; i++) { ProduceCheckLog check = alCheck[i] as ProduceCheckLog; ProduceCheckLog oldCheck = new ProduceCheckLog(); oldCheck.cnnProduceSerialNo = check.cnnProduceSerialNo; oldCheck.cnvcCode = check.cnvcCode; oldCheck = EntityMapping.Get(oldCheck, trans) as ProduceCheckLog; if (oldCheck == null) { throw new Exception("未找到指定产品生产库存"); } oldCheck.cnnCheckCount = check.cnnCheckCount; oldCheck.cnvcOperID = check.cnvcOperID; oldCheck.cndOperDate = dtSysTime; EntityMapping.Update(oldCheck, trans); } operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "生产流水:" + strProduceSerialNo; EntityMapping.Create(operLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
public void AddOrder(OrderBook orderBook, DataTable dtOrderBookDetail, OperLog operLog) //,BusiLog busiLog) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); OrderSerialNo serialNo = new OrderSerialNo(); serialNo.cnvcFill = "0"; serialNo.cnnSerialNo = Convert.ToDecimal(EntityMapping.Create(serialNo, trans)); orderBook.cnnOrderSerialNo = serialNo.cnnSerialNo; orderBook.cndOrderDate = dtSysTime; orderBook.cnvcOrderOperID = operLog.cnvcOperID; EntityMapping.Create(orderBook, trans); foreach (DataRow drOrderBookDetail in dtOrderBookDetail.Rows) { OrderBookDetail detail = new OrderBookDetail(drOrderBookDetail); detail.cnnOrderSerialNo = serialNo.cnnSerialNo; detail.cndOperDate = dtSysTime; detail.cnvcOperID = operLog.cnvcOperID; EntityMapping.Create(detail, trans); } operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "订单流水:" + orderBook.cnnOrderSerialNo; EntityMapping.Create(operLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
public void AdjustCheckSerial_Delete(CheckSerial CheckSerial, OperLog operLog) //,BusiLog busiLog) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); CheckSerial oldCheckSerial = EntityMapping.Get(CheckSerial, trans) as CheckSerial; if (oldCheckSerial == null) { throw new Exception("未找到对应盘点流水的产品!"); } oldCheckSerial.cnnReduceCount = CheckSerial.cnnReduceCount; oldCheckSerial.cnvcOperID = operLog.cnvcOperID; oldCheckSerial.cndOperDate = dtSysTime; EntityMapping.Delete(oldCheckSerial, trans); CheckSerialLog checkSerialLog = new CheckSerialLog(oldCheckSerial.ToTable()); checkSerialLog.cnnCheckSerialNo = oldCheckSerial.cnnSerialNo; EntityMapping.Create(checkSerialLog, trans); operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "盘点删除,盘点流水:" + oldCheckSerial.cnnSerialNo.ToString() + ",产品编码:" + CheckSerial.cnvcCode; EntityMapping.Create(operLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
public static void UpdatePwd(Oper oper) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); Oper oldOper = new Oper(); oldOper.cnvcOperID = oper.cnvcOperID; oldOper = EntityMapping.Get(oldOper, trans) as Oper; if (null == oldOper) { throw new Exception("无此用户"); } oldOper.cnvcOperPwd = oper.cnvcOperPwd; //DataSecurity.Encrypt(oper.cnvcOperPwd); EntityMapping.Update(oldOper, trans); BusiLog busiLog = new BusiLog(); busiLog.cndOperDate = dtSysTime; busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans); busiLog.cnvcComments = "修改密码"; busiLog.cnvcFuncCode = "修改密码"; busiLog.cnvcOperID = oper.cnvcOperID; busiLog.cnvcIPAddress = ""; EntityMapping.Create(busiLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
public int DeleteComputationUnit(OperLog operLog, Entity.ComputationUnit cu) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); Entity.ComputationUnit oldcu = new Entity.ComputationUnit(); oldcu.cnvcComunitCode = cu.cnvcComunitCode; oldcu = EntityMapping.Get(oldcu, trans) as Entity.ComputationUnit; if (oldcu == null) { throw new Exception("未找到记录单位"); } if (oldcu.cnbMainUnit) { throw new Exception("主计量单位不能删除"); } EntityMapping.Delete(oldcu, trans); operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "计量单位组编码:" + cu.cnvcComunitCode; EntityMapping.Create(operLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); return(-1); } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); return(-1); } finally { ConnectionPool.ReturnConnection(conn); } return(1); } }
public void LoginLog(OperLogin login) { try { conn = ConnectionPool.BorrowConnection(); trans = conn.BeginTransaction(); string strHostName = Environment.MachineName; IPHostEntry oIPHost = Dns.GetHostEntry(Environment.MachineName);//Dns.Resolve(Environment.MachineName); string strHostIP = ""; if (oIPHost.AddressList.Length > 0) { strHostIP = oIPHost.AddressList[0].ToString(); } login.cnvcHostName = strHostName; login.cnvcHostAddress = strHostIP; SeqSerialNo serialNo = new SeqSerialNo(); serialNo.cnvcFill = "0"; login.cnnSerialNp = EntityMapping.Create(serialNo, trans); EntityMapping.Create(login, trans); //折扣上限 trans.Commit(); } catch (BusinessException bex) //业务异常 { trans.Rollback(); //LogAdapter.WriteBusinessException(bex); throw new BusinessException(bex.Type, bex.Message); } catch (SqlException sex) //数据库异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteDatabaseException(sex); throw new BusinessException("数据库异常", sex.Message); } catch (Exception ex) //其他异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteFeaturesException(ex); throw new BusinessException("其它异常", ex.Message); } finally { ConnectionPool.ReturnConnection(conn); } }
/// <summary> /// 专供油合同修改 /// </summary> /// <param name="so">合同对象</param> /// <param name="bl">日志</param> public void SOMOD(Entity.SpecialOilDept so, Entity.BusiLog bl) { ConnectionPool.IsCenter = true; using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(IsolationLevel.ReadCommitted); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); Guid gd = Guid.NewGuid(); EntityMapping.Update(so, trans); //日志 bl.cnnSerial = gd; bl.cnvcComments = "专供油合同修改"; bl.cnvcOperType = OperType.OP205; bl.cndOperDate = dtSysTime; bl.cnvcSource = InSource.cs; EntityMapping.Create(bl, trans); trans.Commit(); } catch (BusinessException bex) { trans.Rollback(); LogAdapter.WriteBusinessException(bex); throw bex; } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
//订单更新产品 public void UpdateDetail(OrderBookDetail detail, OperLog operLog) //,BusiLog busiLog) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); OrderBookDetail oldDetail = new OrderBookDetail(); oldDetail.cnnOrderSerialNo = detail.cnnOrderSerialNo; oldDetail.cnvcProductCode = detail.cnvcProductCode; oldDetail = EntityMapping.Get(oldDetail, trans) as OrderBookDetail; oldDetail.cnnOrderCount = detail.cnnOrderCount; oldDetail.cnnSum = detail.cnnOrderCount * oldDetail.cnnPrice; oldDetail.cnvcOperID = detail.cnvcOperID; oldDetail.cndOperDate = dtSysTime; EntityMapping.Update(oldDetail, trans); operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "订单流水:" + detail.cnnOrderSerialNo.ToString(); EntityMapping.Create(operLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
public void AddOperFunc(ArrayList alOperFuncList, int iOperID) { try { conn = ConnectionPool.BorrowConnection(); trans = conn.BeginTransaction(); for (int i = 0; i < alOperFuncList.Count; i++) { string strFuncCode = alOperFuncList[i].ToString(); OperFunc func = new OperFunc(); func.cnnOperID = iOperID; func.cnvcFuncCode = strFuncCode; OperFunc oldFunc = EntityMapping.Get(func, trans) as OperFunc; if (null == oldFunc) { EntityMapping.Create(func, trans); } } trans.Commit(); } catch (BusinessException bex) //业务异常 { //LogAdapter.WriteBusinessException(bex); trans.Rollback(); throw new BusinessException(bex.Type, bex.Message); } catch (SqlException sex) //数据库异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteDatabaseException(sex); throw new BusinessException("数据库异常", sex.Message); } catch (Exception ex) //其他异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteFeaturesException(ex); throw new BusinessException("其它异常", ex.Message); } finally { ConnectionPool.ReturnConnection(conn); } }
public void InsertNT77(string strHardwareID, string strCardNo, string OperName) { NT77 nt77 = new NT77(); nt77.HardwareID = strHardwareID; nt77 = EntityMapping.Get(nt77) as NT77; if (nt77 == null) { nt77 = new NT77(); nt77.HardwareID = strHardwareID; nt77.CardNo = strCardNo; nt77.CreateDate = DateTime.Now; nt77.OperName = OperName; nt77.bIsUse = true; EntityMapping.Create(nt77); } }
public void UpdatePriority(Dept dept, OperLog operLog) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { Dept oldDept = new Dept(); oldDept.cnvcDeptID = dept.cnvcDeptID; oldDept = EntityMapping.Get(oldDept, trans) as Dept; if (oldDept == null) { throw new Exception("未找到相应的部门"); } oldDept.cnnPriority = dept.cnnPriority; EntityMapping.Update(oldDept, trans); string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "部门ID:" + dept.cnvcDeptID; EntityMapping.Create(operLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
public int UpdateProductClass(OperLog operLog, ProductClass pc) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); ProductClass oldpc = new ProductClass(); oldpc.cnvcProductClassCode = pc.cnvcProductClassCode; oldpc = EntityMapping.Get(oldpc, trans) as ProductClass; oldpc.cnvcComments = pc.cnvcComments; oldpc.cnvcProductClassName = pc.cnvcProductClassName; oldpc.cnvcProductType = pc.cnvcProductType; EntityMapping.Update(pc, trans); operLog.cndOperDate = dtSysTime; operLog.cnvcComments = "产品分类:" + pc.cnvcProductClassCode; EntityMapping.Create(operLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); return(-1); } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); return(-1); } finally { ConnectionPool.ReturnConnection(conn); } return(1); } }
public void ModifyOperFunc(List <FuncList> alOperFuncList, string iOperID) //,string strCardType) { try { conn = ConnectionPool.BorrowConnection(); trans = conn.BeginTransaction(); SqlHelper.ExecuteNonQuery(trans, CommandType.Text, "delete from tbOperFunc where cnnOperID = " + iOperID); //+" and cnvcCardType='"+strCardType+"'"); for (int i = 0; i < alOperFuncList.Count; i++) { //string strFuncCode = alOperFuncList[i]; FuncList fl = alOperFuncList[i] as FuncList; OperFunc func = new OperFunc(); func.cnnOperID = Convert.ToInt32(iOperID); func.cnvcFuncCode = fl.cnvcFuncCode; //strFuncCode; func.cnvcCardType = fl.cnvcCardType; //strCardType; EntityMapping.Create(func, trans); } trans.Commit(); } catch (BusinessException bex) //业务异常 { //LogAdapter.WriteBusinessException(bex); trans.Rollback(); throw new BusinessException(bex.Type, bex.Message); } catch (SqlException sex) //数据库异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteDatabaseException(sex); throw new BusinessException("数据库异常", sex.Message); } catch (Exception ex) //其他异常 { //事务回滚 trans.Rollback(); //LogAdapter.WriteFeaturesException(ex); throw new BusinessException("其它异常", ex.Message); } finally { ConnectionPool.ReturnConnection(conn); } }
public static void InitPwd(Oper oldOper, Oper oper) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); //EntityMapping.Delete(oldOper,trans); SqlHelper.ExecuteNonQuery(trans, CommandType.Text, "update tbOper set cnvcOperPwd='" + DataSecurity.Encrypt("123456") + "' where cnvcOperID='" + oldOper.cnvcOperID + "'"); BusiLog busiLog = new BusiLog(); busiLog.cndOperDate = dtSysTime; busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans); //busiLog.cnvcComments = oldOper.cnvcOperName; busiLog.cnvcFuncCode = "初始密码"; busiLog.cnvcOperID = oper.cnvcOperID; busiLog.cnvcIPAddress = ""; EntityMapping.Create(busiLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }