예제 #1
0
파일: EditPOFlow.cs 프로젝트: SoftSuite/ABB
        public bool UpdateData(string userID, PurchaseOrderData 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.ORDERDATE = data.ORDERDATE;
                    DALObj.ORDERTYPE = data.ORDERTYPE;
                    DALObj.SUPPLIER = data.SUPPLIER;
                    DALObj.CNAME = data.CNAME;
                    DALObj.CADDRESS = data.CADDRESS;
                    DALObj.CTEL = data.CTEL;
                    DALObj.CFAX = data.CFAX;
                    DALObj.APPROVER = data.APPROVER;
                    if (data.APPROVEDATE.Year != 1)
                    {
                        DALObj.APPROVEDATE = data.APPROVEDATE;
                    }
                    DALObj.REMARK = data.REMARK;
                    DALObj.PAYMENTTYPE = data.PAYMENTTYPE;
                    DALObj.PAYMENTDESC = data.PAYMENTDESC;
                    DALObj.TOTAL = data.TOTAL;
                    DALObj.TOTVAT = data.TOTVAT;
                    DALObj.TOTDIS = data.TOTDIS;
                    DALObj.GRANDTOT = data.GRANDTOT;
                    DALObj.REFLOID = data.REFLOID;
                    DALObj.REFTABLE = data.REFTABLE;
                    DALObj.STATUS = data.STATUS;
                    DALObj.ACTIVE = data.ACTIVE;
                    DALObj.DELIVERY = data.DELIVERY;
                    DALObj.OTHER = data.OTHER;
                    DALObj.VAT = data.VAT;
                    DALObj.POTYPE = data.TYPE;

                    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);
                    }

                    ret = DALObj2.UpdatePOOldActive(DALObj.REFLOID, Constz.ActiveStatus.InActive, userID, obj.zTrans);
                    if (!ret) throw new ApplicationException(DALObj.ErrorMessage);

                    POItemDAL itemDAL = new POItemDAL();
                    itemDAL.DeleteDataByPDOrder(data.LOID, obj.zTrans);
                    for (Int16 i = 0; i < data.ITEM.Count; ++i)
                    {
                        POItemData item = (POItemData)data.ITEM[i];
                        itemDAL.PRODUCT = item.PRODUCT;
                        itemDAL.PRITEM = item.PRITEM;
                        itemDAL.PDORDER = DALObj.LOID;
                        itemDAL.QTY = item.QTY;
                        itemDAL.RECEIVEQTY = item.RECEIVEQTY;
                        itemDAL.UNIT = item.UNIT;
                        itemDAL.PRICE = item.PRICE;
                        itemDAL.DISCOUNT = item.DISCOUNT;
                        itemDAL.DUEDATE = item.DUEDATE;
                        itemDAL.ACTIVE = item.ACTIVE;
                        itemDAL.REFPOITEM = item.LOID;
                        itemDAL.STATUS = DALObj.STATUS;
                        itemDAL.ISVAT = item.ISVAT;

                        itemDAL.OnDB = false;
                        ret = itemDAL.InsertCurrentData(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;
                }
            }
            else
                ret = false;
            return ret;
        }
예제 #2
0
        public bool NewPDOrder(string UserID, PurchaseOrderData data)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                PDOrderDAL _DAL = new PDOrderDAL();
                _DAL.OnDB = false;
                _DAL.ACTIVE = data.ACTIVE;
                _DAL.CODE = data.CODE;
                _DAL.ORDERDATE = data.ORDERDATE;
                _DAL.STATUS = data.STATUS;
                _DAL.VAT = data.VAT;
                _DAL.ORDERTYPE = Constz.OrderType.PO.Code;
                _DAL.POTYPE = "N";

                ret = _DAL.InsertCurrentData(UserID, obj.zTrans);
                _LOID = _DAL.LOID;
                if (!ret)
                {
                    throw new ApplicationException(_DAL.ErrorMessage);
                }
                
                POItemDAL _DALItem = new POItemDAL();
                for (int i = 0; i < data.ITEM.Count; ++i)
                {
                    _DALItem.OnDB = false;
                    POItemData itemData = (POItemData)data.ITEM[i];
                    
                    _DALItem.PRODUCT = itemData.PRODUCT;
                    _DALItem.PRITEM = itemData.PRITEM;
                    _DALItem.PDORDER = _DAL.LOID;
                    _DALItem.QTY = itemData.QTY;
                    _DALItem.UNIT = itemData.UNIT;
                    _DALItem.PRICE = itemData.PRICE;
                    _DALItem.DUEDATE = DateTime.Now.Date;
                    _DALItem.ACTIVE = itemData.ACTIVE;

                    ret = _DALItem.InsertCurrentData(UserID, obj.zTrans);
                    if (!ret)
                    {
                        throw new ApplicationException(_DALItem.ErrorMessage);
                    }
                }
                obj.zTrans.Commit();
                obj.CloseConnection();
            }
            catch (Exception ex)
            {
                obj.zTrans.Rollback();
                obj.CloseConnection();
                ret = false;
                _error = ex.Message;
            }

            return ret;

        }