public bool Add(fpcore.Model.Delivery delivery, System.Data.Common.DbTransaction transaction) { IFPObjectDAO fpObjectDAO = DAOFactory.getInstance().createFPObjectDAO(); fpObjectDAO.add(delivery, transaction); SqlTransaction trans = (SqlTransaction)transaction; String sql = "insert into delivery(ObjectId, number, non_order_num,part_no,length,width,height,weight,delivery_type,requested_by,handled_by,notes,assigned_by,deadline,status,contact,remarks,cid,goods_type) values " + "(@ObjectId,@number, @non_order_num,@part_no,@length,@width,@height,@weight,@delivery_type,@requested_by,@handled_by,@notes,@assigned_by,@deadline,@status,@contact,@remarks,@cid,@goods_type)"; SqlCommand cmd = new SqlCommand(); cmd.CommandText = sql; cmd.Transaction = trans; cmd.Connection = trans.Connection; cmd.Parameters.Add(genSqlParameter("ObjectId", SqlDbType.Int, 10, delivery.objectId)); cmd.Parameters.Add(genSqlParameter("number", SqlDbType.NVarChar, 50, delivery.number)); cmd.Parameters.Add(genSqlParameter("non_order_num", SqlDbType.NVarChar, 50, delivery.non_order)); cmd.Parameters.Add(genSqlParameter("part_no", SqlDbType.VarChar, 50, delivery.part_no)); cmd.Parameters.Add(genSqlParameter("length", SqlDbType.NVarChar, 50, delivery.length)); cmd.Parameters.Add(genSqlParameter("width", SqlDbType.NVarChar, 50, delivery.width)); cmd.Parameters.Add(genSqlParameter("remarks", SqlDbType.NVarChar, 1000, delivery.remarks)); cmd.Parameters.Add(genSqlParameter("height", SqlDbType.VarChar, 50, delivery.height)); cmd.Parameters.Add(genSqlParameter("weight", SqlDbType.NVarChar, 50, delivery.weight)); cmd.Parameters.Add(genSqlParameter("delivery_type", SqlDbType.NVarChar, 50, delivery.delivery_type)); int? requested_by = null; if (delivery.requested_by != null) requested_by = delivery.requested_by.objectId; int? handled_by = null; if (delivery.handled_by != null) handled_by = delivery.handled_by.objectId; int? assigned_by = null; if (delivery.assigned_by != null) assigned_by = delivery.assigned_by.objectId; int? contact = null; if (delivery.contact != null) contact = delivery.contact.objectId; int? cid = null; if (delivery.customer != null) cid = delivery.customer.objectId; cmd.Parameters.Add(genSqlParameter("requested_by", SqlDbType.Int, 10, requested_by)); cmd.Parameters.Add(genSqlParameter("handled_by", SqlDbType.Int, 50, handled_by)); cmd.Parameters.Add(genSqlParameter("notes", SqlDbType.NVarChar, 50, delivery.notes)); cmd.Parameters.Add(genSqlParameter("assigned_by", SqlDbType.Int, 10, assigned_by)); cmd.Parameters.Add(genSqlParameter("contact", SqlDbType.Int, 10, contact)); cmd.Parameters.Add(genSqlParameter("status", SqlDbType.NVarChar, 50, delivery.status)); cmd.Parameters.Add(genSqlParameter("cid", SqlDbType.Int, 10, cid)); cmd.Parameters.Add(genSqlParameter("deadline", SqlDbType.DateTime, 0, delivery.deadline)); cmd.Parameters.Add(genSqlParameter("goods_type", SqlDbType.NVarChar, 50, delivery.goods_type)); cmd.ExecuteNonQuery(); cmd.Dispose(); return true; }
public bool delete(fpcore.Model.FPObject obj, System.Data.Common.DbTransaction transaction) { SqlTransaction trans = (SqlTransaction)transaction; String sql = "update FPObject set UpdateDate = getDate(), UpdateBy = @UpdateBy , IsDeleted = 1 where ObjectId = @ObjectId"; SqlCommand cmd = new SqlCommand(); cmd.CommandText = sql; cmd.Transaction = trans; cmd.Connection = trans.Connection; cmd.Parameters.Add(genSqlParameter("ObjectId", SqlDbType.Int, 10, obj.objectId)); cmd.Parameters.Add(genSqlParameter("UpdateBy", SqlDbType.NVarChar, 50, obj.updateBy)); cmd.ExecuteNonQuery(); cmd.Dispose(); FPObject objNew = get(obj.objectId, trans); obj.objectId = objNew.objectId; obj.createDate = objNew.createDate; obj.isDeleted = objNew.isDeleted; obj.updateBy = objNew.updateBy; obj.updateDate = objNew.updateDate; return true; }
public bool add(fpcore.Model.Consumption consumption, DbTransaction transaction) { IFPObjectDAO fpObjectDAO = DAOFactory.getInstance().createFPObjectDAO(); fpObjectDAO.add(consumption, transaction); SqlTransaction trans = (SqlTransaction)transaction; String sql = "insert into Consumption(ObjectId,total,totalunit,store,storeunit,used,usedunit,inventoryid,asdate,subtotal,substore,subused) values " + "(@ObjectId,@total,@totalunit,@store,@storeunit,@used,@usedunit,@inventoryid,@asdate,@subtotal,@substore,@subused)"; SqlCommand cmd = new SqlCommand(); cmd.CommandText = sql; cmd.Transaction = trans; cmd.Connection = trans.Connection; int? reid = null; if (consumption.inventory != null) reid = consumption.inventory.objectId; cmd.Parameters.Add(genSqlParameter("ObjectId", SqlDbType.Int, 10, consumption.objectId)); cmd.Parameters.Add(genSqlParameter("total", SqlDbType.VarChar, 50, consumption.total)); cmd.Parameters.Add(genSqlParameter("totalunit", SqlDbType.VarChar, 50, consumption.totalunit)); cmd.Parameters.Add(genSqlParameter("store", SqlDbType.VarChar, 50, consumption.store)); cmd.Parameters.Add(genSqlParameter("storeunit", SqlDbType.VarChar, 50, consumption.storeunit)); cmd.Parameters.Add(genSqlParameter("used", SqlDbType.VarChar, 50, consumption.used)); cmd.Parameters.Add(genSqlParameter("usedunit", SqlDbType.VarChar, 50, consumption.usedunit)); cmd.Parameters.Add(genSqlParameter("inventoryid", SqlDbType.Int, 10, reid)); cmd.Parameters.Add(genSqlParameter("asdate", SqlDbType.DateTime, 0, consumption.asdate)); cmd.Parameters.Add(genSqlParameter("subtotal", SqlDbType.Decimal, 18, consumption.subtotal)); cmd.Parameters.Add(genSqlParameter("substore", SqlDbType.Decimal, 18, consumption.substore)); cmd.Parameters.Add(genSqlParameter("subused", SqlDbType.Decimal, 18, consumption.subused)); cmd.ExecuteNonQuery(); cmd.Dispose(); return true; }
public bool delete(fpcore.Model.Consumption consumption, DbTransaction transaction) { IFPObjectDAO objDAO = DAOFactory.getInstance().createFPObjectDAO(); objDAO.delete(consumption, transaction); return true; }
public bool Update(fpcore.Model.Inventory inventory, DbTransaction transaction) { IFPObjectDAO fpObjectDAO = DAOFactory.getInstance().createFPObjectDAO(); fpObjectDAO.update(inventory, transaction); SqlTransaction trans = (SqlTransaction)transaction; String sql = "update Inventory set orderno=@orderno, assetno=@assetno,category=@category,receiveddate=@receiveddate,receivedby=@receivedby,orderdeadline=@orderdeadline,remark=@remark,contactperson=@contactperson,tel=@tel,productno=@productno,productnameen=@productnameen,productnamecn=@productnamecn,description=@description,dimension=@dimension,unit=@unit,unitcost=@unitcost,quantity=@quantity,stored =@stored,status=@status where ObjectId = @ObjectId"; SqlCommand cmd = new SqlCommand(); cmd.CommandText = sql; cmd.Transaction = trans; cmd.Connection = trans.Connection; int? reid = null; if (inventory.receivedby != null) reid = inventory.receivedby.objectId; cmd.Parameters.Add(genSqlParameter("ObjectId", SqlDbType.Int, 10, inventory.objectId)); cmd.Parameters.Add(genSqlParameter("orderno", SqlDbType.NVarChar, 50, inventory.orderno)); cmd.Parameters.Add(genSqlParameter("assetno", SqlDbType.NVarChar, 50, inventory.assetno)); cmd.Parameters.Add(genSqlParameter("category", SqlDbType.VarChar, 50, inventory.category)); cmd.Parameters.Add(genSqlParameter("receiveddate", SqlDbType.DateTime, 50, inventory.receiveddate)); cmd.Parameters.Add(genSqlParameter("receivedby", SqlDbType.Int, 10, reid)); cmd.Parameters.Add(genSqlParameter("orderdeadline", SqlDbType.VarChar, 50, inventory.orderdeadline)); cmd.Parameters.Add(genSqlParameter("remark", SqlDbType.NVarChar, 255, inventory.remark)); cmd.Parameters.Add(genSqlParameter("contactperson", SqlDbType.NVarChar, 50, inventory.contactperson)); cmd.Parameters.Add(genSqlParameter("tel", SqlDbType.NVarChar, 50, inventory.Tel)); cmd.Parameters.Add(genSqlParameter("productno", SqlDbType.NVarChar, 50, inventory.productno)); cmd.Parameters.Add(genSqlParameter("productnameen", SqlDbType.NVarChar, 50, inventory.productnameen)); cmd.Parameters.Add(genSqlParameter("productnamecn", SqlDbType.NVarChar, 10, inventory.productnamecn)); cmd.Parameters.Add(genSqlParameter("description", SqlDbType.NVarChar, 255, inventory.description)); cmd.Parameters.Add(genSqlParameter("dimension", SqlDbType.NVarChar, 50, inventory.dimension)); cmd.Parameters.Add(genSqlParameter("unit", SqlDbType.NVarChar, 50, inventory.unit)); cmd.Parameters.Add(genSqlParameter("unitcost", SqlDbType.NVarChar, 50, inventory.unitcost)); cmd.Parameters.Add(genSqlParameter("quantity", SqlDbType.NVarChar, 50, inventory.quantity)); cmd.Parameters.Add(genSqlParameter("stored", SqlDbType.NVarChar, 50, inventory.stored)); cmd.Parameters.Add(genSqlParameter("status", SqlDbType.NVarChar, 50, inventory.status)); cmd.ExecuteNonQuery(); cmd.Dispose(); return true; }
public bool delete(fpcore.Model.Inventory inventory, DbTransaction transaction) { IFPObjectDAO fpObjectDAO = DAOFactory.getInstance().createFPObjectDAO(); return fpObjectDAO.delete(inventory, transaction); }