Example #1
0
 public bool DeleteData(ArrayList arrData)
 {
     bool ret = true;
     OracleDBObj obj = new OracleDBObj();
     obj.CreateConnection();
     obj.CreateTransaction();
     try
     {
         BasketItemDAL itemDAL = new BasketItemDAL();
         for (int i = 0; i < arrData.Count; i++)
         {
             DALObj.GetDataByLOID(Convert.ToDouble(arrData[i]), obj.zTrans);
             itemDAL.DeleteDataByBasket(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;
 }
Example #2
0
        public bool UpdateData(string userID, StockoutBasketData data)
        {
            bool ret = true;
            if (ValidateData(data))
            {
                OracleDBObj obj = new OracleDBObj();
                obj.CreateConnection();
                obj.CreateTransaction();
                try
                {
                    DALObj.OnDB = false;
                    DALObj.GetDataByLOID(data.LOID, obj.zTrans);

                    DALObj.CODE = data.CODE;
                    DALObj.CHECKDATE = data.CHECKDATE;
                    DALObj.PRODUCT = data.PRODUCT;
                    DALObj.QTY = data.QTY;
                    if (data.STOCKINDATE.Year != 1)
                    {
                        DALObj.STOCKINDATE = data.STOCKINDATE;
                    }
                    DALObj.REMARK = data.REMARK;
                    DALObj.TYPE = data.TYPE;
                    DALObj.UNIT = data.UNIT;
                    DALObj.STATUS = data.STATUS;
                    DALObj.LOTNO = data.LOTNO;
                    DALObj.WAREHOUSE = data.WAREHOUSE;

                    if (DALObj.OnDB)
                    {
                        ret = DALObj.UpdateCurrentData(userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(DALObj.ErrorMessage);

                    }
                    else
                    {
                        DALObj.STATUS = data.STATUS;
                        ret = DALObj.InsertCurrentData(userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(DALObj.ErrorMessage);
                    }

                    _LOID = DALObj.LOID;
                    

                    BasketItemDAL itemDAL = new BasketItemDAL();
                    itemDAL.DeleteDataByBasket(data.LOID, obj.zTrans);
                    for (Int16 i = 0; i < data.ITEM.Count; ++i)
                    {
                        BasketItemData item = (BasketItemData)data.ITEM[i];
                        itemDAL.BASKET = DALObj.LOID;
                        itemDAL.PRODUCT = item.PRODUCT;
                        itemDAL.UNIT = item.UNIT;
                        itemDAL.LOTNO = item.LOTNO;
                        itemDAL.PACKAGE = item.PACKAGE;
                        itemDAL.QTY = item.QTY;
                        itemDAL.PRODUCTSTOCK = item.PRODUCTSTOCK;

                        itemDAL.OnDB = false;
                        ret = itemDAL.InsertCurrentData(userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(itemDAL.ErrorMessage);
                    }

                    if (data.STATUS == Constz.Requisition.Status.Approved.Code)
                    {
                        ret = DALObj.CutStockBasket(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;
        }