Exemplo n.º 1
0
        public bool CopyPlan(string userID, double year, string description, double planSource)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                DALObj.GetDataByLOID(planSource, obj.zTrans);
                if (DALObj.OnDB)
                {
                    if (!DALObj.IsDuplicateData(year.ToString(), DALObj.PLANTYPE, obj.zTrans))
                    {
                        PlanDAL pDAL = new PlanDAL();
                        pDAL.OnDB = false;
                        pDAL.ACTIVE = Constz.ActiveStatus.InActive;
                        pDAL.DESCRIPTION = description;
                        pDAL.PLANTYPE = DALObj.PLANTYPE;
                        pDAL.STATUS = Constz.Requisition.Status.Waiting.Code;
                        pDAL.YEAR = year.ToString();

                        ret = pDAL.InsertCurrentData(userID, obj.zTrans);
                        if (!ret) throw new ApplicationException(pDAL.ErrorMessage);

                        ret = pDAL.CopyPlan(userID, planSource, pDAL.LOID, obj.zTrans);
                        if (!ret) throw new ApplicationException(pDAL.ErrorMessage);

                        _LOID = pDAL.LOID;

                        obj.zTrans.Commit();
                        obj.CloseConnection();
                    }
                    else
                    {
                        throw new ApplicationException(DALObj.ErrorMessage);
                    }
                }
                else
                    throw new ApplicationException("äÁ辺¢éÍÁÙÅá¼¹¡ÒèÓ˹èÒ·Õèµéͧ¡ÒäѴÅÍ¡");
            }
            catch (Exception ex)
            {
                obj.zTrans.Rollback();
                obj.CloseConnection();
                ret = false;
                _error = ex.Message;
            }
            return ret;
        }
Exemplo n.º 2
0
        public bool InsertPlan(string userID, PlanData data)
        {
            bool ret = true;
            OracleDBObj obj = new OracleDBObj();
            obj.CreateConnection();
            obj.CreateTransaction();
            try
            {
                if (!DALObj.IsDuplicateData(data.YEAR, data.PLANTYPE, obj.zTrans))
                {
                    _DAL = new PlanDAL();
                    DALObj.OnDB = false;
                    DALObj.ACTIVE = data.ACTIVE;
                    DALObj.DESCRIPTION = data.DESCRIPTION;
                    DALObj.PLANTYPE = data.PLANTYPE;
                    DALObj.STATUS = data.STATUS;
                    DALObj.YEAR = data.YEAR;

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

                    _LOID = DALObj.LOID;

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