Example #1
0
 public static double InsertPdOrder(string UserID,string Remark,string reftable, double refloid)
 {
     double POLoid = 0;
     PDOrderDAL poDAL = new PDOrderDAL();
     poDAL.REMARK = Remark.Trim();
     poDAL.ORDERTYPE = "PD";
     poDAL.ACTIVE = "1";
     poDAL.STATUS = "WA";
     poDAL.POTYPE = "N";
     poDAL.SUPPLIER = Constz.ProductionDepartment.LOID;
     poDAL.REFLOID = refloid;
     poDAL.REFTABLE = reftable;
     bool ret = poDAL.InsertCurrentData(UserID, null);
     if (ret == true)
     {
         POLoid = poDAL.LOID;
         return POLoid;
     }
     else
         return 0;     
 }
Example #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;

        }
Example #3
0
        public bool UpdateData(string userID, StockinQCData 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);
                    data.PDORDERLOID= DALObj.PDORDER ;

                    PDOrderDAL PDDAL = new PDOrderDAL();
                    PDDAL.GetDataByLOID(data.PDORDERLOID, null);

                    PDDAL.ANACODE = data.ANACODE;
                    PDDAL.ANADATE = data.ANADATE;

                    if (PDDAL.OnDB)
                        ret = PDDAL.UpdateCurrentData(userID, obj.zTrans);
                    else
                        ret = PDDAL.InsertCurrentData(userID, obj.zTrans);

                    _LOID = PDOrderDALObj.LOID;
                    if (!ret)
                    {
                        throw new ApplicationException(PDOrderDALObj.ErrorMessage);
                    }

                    obj.zTrans.Commit();
                    obj.CloseConnection();
                }
                catch (Exception ex)
                {
                    obj.zTrans.Rollback();
                    obj.CloseConnection();
                    ret = false;
                    _error = ex.Message;
                }
            }
            else
                ret = false;
            return ret;
        }