Beispiel #1
0
        public bool UpdateStockinReturnStatus(ArrayList arrData, string userID)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                for (int i = 0; i < arrData.Count; i++)
                {
                    if (GetItem(Convert.ToDouble(arrData[i])).Rows.Count == 0)
                    {
                        throw new ApplicationException("äÁèÊÒÁÒö͹ØÁѵÔÃÒ¡ÒÃä´é à¹×èͧ¨Ò¡ºÒ§ÃÒ¡ÒÃäÁèä´éÃкØÊÔ¹¤éÒ");
                    }
                    StockinReturnData data = GetData(Convert.ToDouble(arrData[i]));

                    DALObj.OnDB = false;
                    DALObj.GetDataByLOID(Convert.ToDouble(arrData[i]), obj.zTrans);
                    if (DALObj.STATUS == Constz.StockinReturn.Status.Waiting.Code)
                    {
                        DALObj.STATUS = Constz.StockinReturn.Status.Approved.Code;
                        ret = DALObj.UpdateCurrentData(userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(DALObj.ErrorMessage);

                        StockInDAL sDAL = new StockInDAL();
                        ret = sDAL.CutStock(DALObj.LOID, userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(sDAL.ErrorMessage);
                    }
                    StockInItemDAL itemDAL = new StockInItemDAL();
                    ret = itemDAL.UpdateStatusByStockIn(Convert.ToDouble(arrData[i]), Constz.StockinReturn.Status.Approved.Code, userID, obj.zTrans);
                    if (!ret) throw new ApplicationException(itemDAL.ErrorMessage);
                }
                obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                obj.zTrans.Rollback();
                obj.CloseConnection();
                ret = false;
                _error = ex.Message;
            }
            return ret;
        }
Beispiel #2
0
        public bool NewStockIn(string UserID, ToDoListStockinOrderData data)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                StockInDAL _DAL = new StockInDAL();
                _DAL.OnDB = false;
                _DAL.ACCCODE = data.ACCCODE;
                _DAL.DOCTYPE = data.DOCTYPE;
                _DAL.RECEIVEDATE = data.RECEIVEDATE;
                _DAL.RECEIVER = data.RECEIVER;
                _DAL.SENDER = data.SENDER;
                _DAL.STATUS = data.STATUS;

                ret = _DAL.InsertCurrentData(UserID, obj.zTrans);
                if (!ret)
                {
                    throw new ApplicationException(_DAL.ErrorMessage);
                }
                StockInItemDAL _DALItem = new StockInItemDAL();
                for (int i = 0; i < data.ITEM.Count; ++i)
                {
                    _DALItem.OnDB = false;
                    ToDoListStockInOrderItemData itemData = (ToDoListStockInOrderItemData)data.ITEM[i];
                    _DALItem.LOTNO = itemData.LOTNO;
                    _DALItem.PRICE = itemData.PRICE;
                    _DALItem.PRODUCT = itemData.PRODUCT;
                    _DALItem.QTY = itemData.QTY;
                    _DALItem.REFLOID = itemData.REFLOID;
                    _DALItem.REFTABLE = itemData.REFTABLE;
                    _DALItem.STATUS = itemData.STATUS;
                    _DALItem.STOCKIN = _DAL.LOID;
                    _DALItem.UNIT = itemData.UNIT;
                    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;
        }
Beispiel #3
0
        public bool CommitData(string userID, StockinReturnData data)
        {
            bool ret = true;
            bool cutstock = true;
            bool custockinreturnlost = 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);
                    custockinreturnlost = cutstock;
                    UpdateData(userID, data, obj.zTrans);
                    if (cutstock)
                    {
                        StockInDAL sDAL = new StockInDAL();
                        ret = sDAL.CutStock(DALObj.LOID, userID, obj.zTrans);
                        if (!ret) _error = sDAL.ErrorMessage;
                    }

                    if (custockinreturnlost)
                    {
                        StockInDAL sDAL = new StockInDAL();
                        ret = sDAL.CutStockInReturnLost(DALObj.LOID, userID, obj.zTrans);
                        if (!ret) _error = sDAL.ErrorMessage;
                    }
                    obj.zTrans.Commit();
                    obj.CloseConnection();
                }
                catch (Exception ex)
                {
                    obj.zTrans.Rollback();
                    obj.CloseConnection();
                    ret = false;
                    _error = ex.Message;
                }
            }
            else
                ret = false;
            return ret;
        }
Beispiel #4
0
        public double InsertStockIn(string UserId, StockInData data)
        {
            Boolean ret = true;
            StockInDAL oDAL = new StockInDAL();
            oDAL.SENDER = Convert.ToDouble(data.SENDER);
            oDAL.DOCTYPE = Constz.DocType.RetShop.LOID;
            oDAL.RECEIVEDATE = DateTime.Now.Date;
            oDAL.STATUS = Constz.Requisition.Status.Waiting.Code;
            oDAL.GRANDTOT = 0.00;
            oDAL.RECEIVER = data.RECEIVER;
            
            

            ret = oDAL.InsertCurrentData(UserId, null);

            if (ret == false)
            {
                _error = oDAL.ErrorMessage;
                return 0;
            }
            else
                return oDAL.LOID;
        }