public bool DeleteData(ArrayList arrData) { bool ret = true; OracleDBObj obj = new OracleDBObj(); obj.CreateConnection(); obj.CreateTransaction(); try { StockOutItemDAL itemDAL = new StockOutItemDAL(); for (int i = 0; i < arrData.Count; i++) { DALObj.GetDataByLOID(Convert.ToDouble(arrData[i]), obj.zTrans); itemDAL.DeleteDataByStockOut(Convert.ToDouble(arrData[i]), obj.zTrans); ret = DALObj.DeleteCurrentData(obj.zTrans); if (!ret) throw new ApplicationException(DALObj.ErrorMessage); } obj.zTrans.Commit(); obj.CloseConnection(); } catch (Exception ex) { obj.zTrans.Rollback(); obj.CloseConnection(); ret = false; _error = ex.Message; } return ret; }
public bool NewStockOut(string userID, double requisition, double warehouse) { bool ret = true; OracleDBObj obj = new OracleDBObj(); obj.CreateConnection(); obj.CreateTransaction(); try { RequisitionDAL reqDAL = new RequisitionDAL(); reqDAL.GetDataByLOID(requisition, obj.zTrans); ReqMaterialDAL reqItemDAL = new ReqMaterialDAL(); DataTable dt = CompareLot(reqItemDAL.GetDataByRequisition(requisition, obj.zTrans),warehouse); DocTypeDAL docDAL = new DocTypeDAL(); docDAL.GetDataByRequisitionType(reqDAL.REQUISITIONTYPE, obj.zTrans); StockOutDAL _DAL = new StockOutDAL(); _DAL.OnDB = false; _DAL.ACTIVE = Constz.ActiveStatus.Active; _DAL.DOCTYPE = docDAL.LOID; _DAL.RECEIVER = (reqDAL.CUSTOMER != 0 ? reqDAL.CUSTOMER : reqDAL.WAREHOUSE); _DAL.REFLOID = reqDAL.LOID; _DAL.REFTABLE = reqDAL.TableName; _DAL.REQDATE = reqDAL.REQDATE; _DAL.SENDER = warehouse; _DAL.STATUS = Constz.Requisition.Status.Waiting.Code; _DAL.PRODUCTREF = "PDPRODUCT"; _DAL.PRODUCTLOID = reqDAL.REFLOID; ret = _DAL.InsertCurrentData(userID, obj.zTrans); if (!ret) { throw new ApplicationException(_DAL.ErrorMessage); } StockOutItemDAL _DALItem = new StockOutItemDAL(); foreach (DataRow dRow in dt.Rows) { _DALItem.OnDB = false; _DALItem.LOTNO = dRow["LOTNO"].ToString(); _DALItem.PRODUCT = Convert.ToDouble(dRow["PRODUCT"]); _DALItem.QTY = Convert.ToDouble(dRow["MASTER"]); _DALItem.REFLOID = Convert.ToDouble(dRow["LOID"]); _DALItem.REFTABLE = "REQUISITIONITEM"; _DALItem.STATUS = Constz.Requisition.Status.Waiting.Code; _DALItem.STOCKOUT = _DAL.LOID; _DALItem.UNIT = Convert.ToDouble(dRow["UNIT"]); _DALItem.ACTIVE = Constz.ActiveStatus.Active; _DALItem.REMAIN = Convert.ToDouble(dRow["REMAINQTY"]); ret = _DALItem.InsertCurrentData(userID, obj.zTrans); if (!ret) { throw new ApplicationException(_DALItem.ErrorMessage); } } _LOID = _DAL.LOID; obj.zTrans.Commit(); obj.CloseConnection(); } catch (Exception ex) { obj.zTrans.Rollback(); obj.CloseConnection(); ret = false; _error = ex.Message; } return ret; }
//public DataTable GetRequisitionItem(double requisition) //{ // StockOutItemDAL itemDAL = new StockOutItemDAL(); // return SearchDAL.GetPurchaseItemList(requisition); //} //public DataTable GetRequisitionItemBlank() //{ // StockOutItemDAL itemDAL = new StockOutItemDAL(); // return SearchDAL.GetPurchaseItemListBlank(); //} //public bool ValidateData(ProductReserveData data) //{ // bool ret = true; // if (data.CUSTOMER == 0) // { // ret = false; // _error = "¡ÃسÒÃкØÅÙ¡¤éÒ"; // } // else if (data.DUEDATE.Year == 1) // { // ret = false; // _error = "¡ÃسҡÓ˹´Çѹ·ÕèÊè§ÊÔ¹¤éÒ"; // } // else if (data.ITEM.Count == 0) // { // ret = false; // _error = "¡ÃسÒÃкØÃÒ¡ÒÃÊÔ¹¤éÒ"; // } // return ret; //} private void UpdateData(string userID, StockoutWHData data, System.Data.OracleClient.OracleTransaction zTrans) { bool ret = true; DALObj.GetDataByLOID(data.LOID, zTrans); DALObj.ACTIVE = data.ACTIVE; DALObj.CADDRESS = data.CADDRESS; DALObj.REFTABLE = data.REFTABLE; DALObj.CFAX = data.CFAX; DALObj.CLASTNAME = data.CLASTNAME; DALObj.CNAME = data.CNAME; DALObj.CTEL = data.CTEL; DALObj.CTITLE = data.CTITLE; DALObj.RECEIVER = data.CUSTOMER; DALObj.DELIVERYDATE = data.DUEDATE; DALObj.REMARK = data.REMARK; DALObj.REQDATE = data.REQDATE; DALObj.DOCTYPE = data.REQUISITIONTYPE; DALObj.STATUS = data.STATUS; DALObj.REFLOID = data.REFLOID; DALObj.PRODUCTLOID = data.REFPROD; DALObj.PRODUCTREF = data.PRODUCTREF; DALObj.INVCODE = data.INVCODE; if (DALObj.OnDB) ret = DALObj.UpdateCurrentData(userID, zTrans); else ret = DALObj.InsertCurrentData(userID, zTrans); _LOID = DALObj.LOID; if (!ret) { throw new ApplicationException(DALObj.ErrorMessage); } StockOutItemDAL itemDAL = new StockOutItemDAL(); itemDAL.DeleteDataByStockOut(data.LOID, zTrans); for (int i = 0; i < data.STOCKOUTITEM.Rows.Count; i++) { itemDAL.PRODUCT = Convert.ToDouble(data.STOCKOUTITEM.Rows[i]["PRODUCT"]); itemDAL.LOTNO = data.STOCKOUTITEM.Rows[i]["LOTNO"].ToString(); itemDAL.QTY = Convert.ToDouble(data.STOCKOUTITEM.Rows[i]["QTY"]); itemDAL.REFLOID = Convert.ToDouble(data.STOCKOUTITEM.Rows[i]["LOID"]); itemDAL.PRICE = Convert.ToDouble(data.STOCKOUTITEM.Rows[i]["PRICE"]); itemDAL.ACTIVE = Constz.ActiveStatus.Active; itemDAL.STATUS = Constz.Requisition.Status.Waiting.Code; itemDAL.UNIT = Convert.ToDouble(data.STOCKOUTITEM.Rows[i]["UNIT"]); if (data.REQUISITIONTYPE == Constz.DocType.ReqRawPO.LOID) itemDAL.REFTABLE = "BOM"; else itemDAL.REFTABLE = "REQMATERIAL"; itemDAL.STOCKOUT = data.LOID; itemDAL.OnDB = false; ret = itemDAL.InsertCurrentData(userID, zTrans); if (!ret) throw new ApplicationException(itemDAL.ErrorMessage); } }
public bool NewStockOut(string userID, double requisition, double warehouse) { bool ret = true; OracleDBObj obj = new OracleDBObj(); obj.CreateConnection(); obj.CreateTransaction(); try { RequisitionDAL reqDAL = new RequisitionDAL(); reqDAL.GetDataByLOID(requisition, obj.zTrans); RequisitionItemDAL reqItemDAL = new RequisitionItemDAL(); DataTable dt = reqItemDAL.GetDataByRequisition(requisition, obj.zTrans); DocTypeDAL docDAL = new DocTypeDAL(); docDAL.GetDataByRequisitionType(reqDAL.REQUISITIONTYPE, obj.zTrans); StockOutDAL _DAL = new StockOutDAL(); _DAL.OnDB = false; _DAL.ACTIVE = Constz.ActiveStatus.Active; _DAL.DOCTYPE = docDAL.LOID; _DAL.RECEIVER = (reqDAL.CUSTOMER != 0 ? reqDAL.CUSTOMER : reqDAL.WAREHOUSE); _DAL.REFLOID = reqDAL.LOID; _DAL.REFTABLE = reqDAL.TableName; _DAL.REQDATE = reqDAL.REQDATE; _DAL.SENDER = warehouse; _DAL.STATUS = Constz.Requisition.Status.Waiting.Code; _DAL.CTITLE = reqDAL.CTITLE; _DAL.CNAME = reqDAL.CNAME; _DAL.CLASTNAME = reqDAL.CLASTNAME; _DAL.CADDRESS = reqDAL.CADDRESS; _DAL.CFAX = reqDAL.CFAX; _DAL.CTEL = reqDAL.CTEL; ret = _DAL.InsertCurrentData(userID, obj.zTrans); if (!ret) { throw new ApplicationException(_DAL.ErrorMessage); } StockOutItemDAL _DALItem = new StockOutItemDAL(); foreach (DataRow dRow in dt.Rows) { StockFGDAL fgDAL = new StockFGDAL(); double qty = Convert.ToDouble(dRow["QTY"]); DataTable dtStock = fgDAL.GetProductStock(warehouse, Convert.ToDouble(dRow["PRODUCT"]), obj.zTrans); foreach (DataRow sRow in dtStock.Rows) { _DALItem.OnDB = false; _DALItem.LOTNO = sRow["LOTNO"].ToString(); _DALItem.PRODUCT = Convert.ToDouble(dRow["PRODUCT"]); if (qty >= Convert.ToDouble(sRow["QTY"])) _DALItem.QTY = Convert.ToDouble(sRow["QTY"]); else _DALItem.QTY = qty; _DALItem.REFLOID = Convert.ToDouble(dRow["LOID"]); _DALItem.REFTABLE = "REQUISITIONITEM"; _DALItem.STATUS = Constz.Requisition.Status.Waiting.Code; _DALItem.STOCKOUT = _DAL.LOID; _DALItem.UNIT = Convert.ToDouble(dRow["UNIT"]); _DALItem.ACTIVE = Constz.ActiveStatus.Active; _DALItem.PRICE = Convert.ToDouble(dRow["PRICE"]); double remain = _DALItem.GetRemainQTYStockFG(_DALItem.LOTNO, _DALItem.PRODUCT, obj.zTrans); _DALItem.REMAIN = remain; qty -= Convert.ToDouble(sRow["QTY"]); ret = _DALItem.InsertCurrentData(userID, obj.zTrans); if (!ret) { throw new ApplicationException(_DALItem.ErrorMessage); } if (qty <= 0) break; } } _LOID = _DAL.LOID; obj.zTrans.Commit(); obj.CloseConnection(); } catch (Exception ex) { obj.zTrans.Rollback(); obj.CloseConnection(); ret = false; _error = ex.Message; } return ret; }
public bool ApproveData(string UserID, double Approver, ArrayList arrData) { bool ret = true; OracleDBObj obj = new OracleDBObj(); obj.CreateConnection(); obj.CreateTransaction(); try { StockOutItemDAL itemDAL = new StockOutItemDAL(); for (int i = 0; i < arrData.Count; i++) { DALObj.OnDB = false; DALObj.GetDataByLOID(Convert.ToDouble(arrData[i]), obj.zTrans); if (DALObj.STATUS == Constz.Requisition.Status.Waiting.Code) { DALObj.APPROVEDATE = DateTime.Now.Date; DALObj.APPROVER = Approver; DALObj.STATUS = Constz.Requisition.Status.Approved.Code; ret = DALObj.UpdateCurrentData(UserID, obj.zTrans); if (!ret) throw new ApplicationException(DALObj.ErrorMessage); ret = itemDAL.UpdateStatusByStockOut(Convert.ToDouble(arrData[i]), DALObj.STATUS, UserID, obj.zTrans); if (!ret) throw new ApplicationException(itemDAL.ErrorMessage); ret = DALObj.CutStock(DALObj.LOID, UserID, obj.zTrans); if (!ret) throw new ApplicationException(DALObj.ErrorMessage); } } obj.zTrans.Commit(); obj.CloseConnection(); } catch (Exception ex) { obj.zTrans.Rollback(); obj.CloseConnection(); ret = false; _error = ex.Message; } return ret; }
public bool UpdateData(string userID, ReturnTesterData data) { bool ret = true; bool cutstock = true; if (ValidateData(data)) { OracleDBObj obj = new OracleDBObj(); obj.CreateConnection(); obj.CreateTransaction(); try { DALObj.OnDB = false; DALObj.GetDataByLOID(data.LOID, obj.zTrans); cutstock = (DALObj.STATUS == Constz.Requisition.Status.Waiting.Code && data.STATUS == Constz.Requisition.Status.Approved.Code); DALObj.ACTIVE = data.ACTIVE; DALObj.APPROVEDATE = data.APPROVEDATE; DALObj.APPROVER = data.APPROVER; DALObj.DOCTYPE = data.DOCTYPE; DALObj.REASON = data.REASON; DALObj.RECEIVER = data.RECEIVER; DALObj.REMARK = data.REMARK; DALObj.SENDER = data.SENDER; DALObj.STATUS = data.STATUS; if (DALObj.OnDB) ret = DALObj.UpdateCurrentData(userID, obj.zTrans); else { DALObj.CODE = OracleDB.GetRunningCode("STOCKOUT", data.DOCTYPE.ToString(), obj.zTrans); ret = DALObj.InsertCurrentData(userID, obj.zTrans); cutstock = false; } _LOID = DALObj.LOID; if (!ret) { throw new ApplicationException(DALObj.ErrorMessage); } StockOutItemDAL itemDAL = new StockOutItemDAL(); itemDAL.DeleteDataByStockOut(DALObj.LOID, obj.zTrans); for (Int16 i = 0; i < data.STOCKITEM.Count; ++i) { StockOutItemData item = (StockOutItemData)data.STOCKITEM[i]; itemDAL.ACTIVE = item.ACTIVE; itemDAL.LOTNO = item.LOTNO; itemDAL.PRODUCT = item.PRODUCT; itemDAL.QTY = item.QTY; itemDAL.STATUS = item.STATUS; itemDAL.STOCKOUT = DALObj.LOID; itemDAL.UNIT = item.UNIT; itemDAL.OnDB = false; ret = itemDAL.InsertCurrentData(userID, obj.zTrans); if (!ret) throw new ApplicationException(itemDAL.ErrorMessage); } if (cutstock) { ret = DALObj.CutStock(DALObj.LOID, userID, obj.zTrans); if (!ret) throw new ApplicationException(DALObj.ErrorMessage); } obj.zTrans.Commit(); obj.CloseConnection(); } catch (Exception ex) { obj.zTrans.Rollback(); obj.CloseConnection(); ret = false; _error = ex.Message; } } else ret = false; return ret; }
public bool UpdateDataReturn(string userID, StockoutFGData data) { bool ret = true; if (!VerifyData(data)) throw new ApplicationException(_error); OracleDBObj obj = new OracleDBObj(); obj.CreateConnection(); obj.CreateTransaction(); try { DALObj.GetDataByLOID(data.LOID, obj.zTrans); DALObj.ACTIVE = data.ACTIVE; DALObj.CADDRESS = data.CADDRESS; DALObj.CFAX = data.CFAX; DALObj.CLASTNAME = data.CLASTNAME; DALObj.CNAME = data.CNAME; DALObj.CTEL = data.CTEL; DALObj.CTITLE = data.CTITLE; DALObj.RECEIVER = data.RECEIVER; DALObj.DELIVERYDATE = data.DELIVERYDATE; DALObj.REMARK = data.REMARK; DALObj.REASON = data.REASON; DALObj.REQDATE = data.REQDATE; DALObj.DOCTYPE = data.DOCTYPE; DALObj.STATUS = data.STATUS; DALObj.REFLOID = data.REFLOID; DALObj.REFTABLE = data.REFTABLE; DALObj.PRODUCTREF = data.PRODUCTREF; DALObj.SENDER = data.SENDER; DALObj.INVCODE = data.INVCODE; // DALObj.REASON = data.REASON; if (DALObj.OnDB) ret = DALObj.UpdateCurrentData(userID, obj.zTrans); else ret = DALObj.InsertCurrentData(userID, obj.zTrans); _LOID = DALObj.LOID; if (!ret) { throw new ApplicationException(DALObj.ErrorMessage); } StockOutItemDAL itemDAL = new StockOutItemDAL(); itemDAL.DeleteDataByStockOut(data.LOID, obj.zTrans); for (Int16 i = 0; i < data.ITEM.Count; ++i) { RequisitionItemData item = (RequisitionItemData)data.ITEM[i]; itemDAL.ACTIVE = item.ACTIVE; itemDAL.PRODUCT = item.PRODUCT; itemDAL.QTY = item.QTY; itemDAL.PRICE = item.PRICE; itemDAL.INVNO = item.INVNO; itemDAL.STOCKOUT = DALObj.LOID; itemDAL.UNIT = item.UNIT; itemDAL.LOTNO = item.LOTNO; itemDAL.STATUS = data.STATUS; itemDAL.OnDB = false; ret = itemDAL.InsertCurrentData(userID, obj.zTrans); if (!ret) throw new ApplicationException(itemDAL.ErrorMessage); }//for obj.zTrans.Commit(); obj.CloseConnection(); } catch (Exception ex) { obj.zTrans.Rollback(); obj.CloseConnection(); ret = false; _error = ex.Message; } return ret; }
private void UpdateData(string userID, StockoutFGData data, System.Data.OracleClient.OracleTransaction zTrans) { bool ret = true; DALObj.GetDataByLOID(data.LOID, zTrans); DALObj.ACTIVE = data.ACTIVE; DALObj.CADDRESS = data.CADDRESS; DALObj.CFAX = data.CFAX; DALObj.CLASTNAME = data.CLASTNAME; DALObj.CNAME = data.CNAME; DALObj.CTEL = data.CTEL; DALObj.CTITLE = data.CTITLE; DALObj.RECEIVER = data.RECEIVER; DALObj.DELIVERYDATE = data.DELIVERYDATE; DALObj.REMARK = data.REMARK; DALObj.REASON = data.REASON; DALObj.REQDATE = data.REQDATE; DALObj.DOCTYPE = data.DOCTYPE; DALObj.STATUS = data.STATUS; DALObj.REFTABLE = data.REFTABLE; DALObj.REFLOID = data.REFLOID; //DALObj.REFPROD = data.REFPROD; DALObj.PRODUCTREF = data.PRODUCTREF; DALObj.INVCODE = data.INVCODE; //DALObj.REASON = data.REASON; DALObj.SENDER = data.SENDER; if (DALObj.OnDB) ret = DALObj.UpdateCurrentData(userID, zTrans); else ret = DALObj.InsertCurrentData(userID, zTrans); _LOID = DALObj.LOID; if (!ret) { throw new ApplicationException(DALObj.ErrorMessage); } DALItemObj.DeleteDataByStockOut(_LOID, zTrans); for (int i = 0; i < data.ITEM.Count; i++) { StockOutItemData itemData = (StockOutItemData)data.ITEM[i]; _itemDAL = new StockOutItemDAL(); DALItemObj.ACTIVE = itemData.ACTIVE; DALItemObj.LOTNO = itemData.LOTNO; DALItemObj.PRICE = itemData.PRICE; DALItemObj.PRODUCT = itemData.PRODUCT; DALItemObj.QTY = itemData.QTY; DALItemObj.REFLOID = itemData.REFLOID; DALItemObj.REFTABLE = itemData.REFTABLE; DALItemObj.STATUS = data.STATUS; DALItemObj.STOCKOUT = _LOID; DALItemObj.UNIT = itemData.UNIT; DALItemObj.INVNO = itemData.INVNO; ret = DALItemObj.InsertCurrentData(userID, zTrans); if (!ret) throw new ApplicationException(DALItemObj.ErrorMessage); } }