예제 #1
0
        public bool UpdateRodData(Guid EXCode)
        {
            Editor           ed = Application.DocumentManager.MdiActiveDocument.Editor;
            OleDbTransaction aTransaction;
            OleDbConnection  aConnection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString);

            try
            {
                aConnection.Open();
                aTransaction = aConnection.BeginTransaction();
                try
                {
                    RodPack = Atend.Base.Design.DPackage.AccessSelectByCode(EXCode);
                    //ed.WriteMessage("**RodPAck.Code={0}\n",RodPack.Code);
                    if (!UseAccess)
                    {
                        if (!ERod.AccessInsert(aTransaction, aConnection, true, true))
                        {
                            throw new System.Exception("eRod.AccessInsert failed");
                        }
                    }
                    RodPack.IsExistance = Existance;
                    RodPack.ProductCode = ERod.Code;
                    RodPack.ProjectCode = ProjectCode;
                    RodPack.Number      = "";
                    if (RodPack.AccessUpdate(aTransaction, aConnection))
                    {
                        //ed.WriteMessage("ERod.Code={0},SelectedRod.ObjId={1}\n",ERod.Code,selectedObjectId);
                        Atend.Base.Acad.AT_INFO atinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(selectedObjectId);// id);

                        atinfo.ProductCode = ERod.Code;
                        atinfo.Insert();
                        ChangeComment(selectedObjectId, ERod.Comment);
                    }
                    else
                    {
                        throw new System.Exception("RodPack.AccessInsert2 failed");
                    }
                }
                catch (System.Exception ex1)
                {
                    ed.WriteMessage("ERROR Updaterod 01(transaction) : {0} \n", ex1.Message);
                    aTransaction.Rollback();
                    aConnection.Close();
                    return(false);
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("ERROR UpdateRod 01 : {0} \n", ex.Message);
                aConnection.Close();
                return(false);
            }

            aTransaction.Commit();
            aConnection.Close();
            return(true);
        }
예제 #2
0
        //private bool SaveRodData(string ParentCode)
        //{


        //    Guid Code = new Guid(ParentCode);
        //    Atend.Base.Design.DPackage Package = Atend.Base.Design.DPackage.AccessSelectByNodeCode(Code);

        //    Atend.Base.Acad.AcadGlobal.RodData.dPackageForRod.ParentCode = Package.Code;

        //    if (Atend.Base.Acad.AcadGlobal.RodData.dPackageForRod.AccessInsert())
        //    {
        //        System.Data.DataTable OperationTable = Atend.Base.Equipment.EOperation.SelectByProductCodeType(Atend.Base.Acad.AcadGlobal.RodData.dPackageForRod.ProductCode, Atend.Base.Acad.AcadGlobal.RodData.dPackageForRod.Type);

        //        if (OperationTable.Rows.Count > 0)
        //            foreach (DataRow OperationRow in OperationTable.Rows)
        //            {
        //                //ed.WriteMessage("\n115\n");
        //                Atend.Base.Design.DPackage P = new Atend.Base.Design.DPackage();
        //                P.ParentCode = Atend.Base.Acad.AcadGlobal.RodData.dPackageForRod.Code;
        //                P.Type = (int)Atend.Control.Enum.ProductType.Operation;
        //                P.ProductCode = Convert.ToInt32(OperationRow["ProductId"].ToString());
        //                P.Count = 1;

        //                if (P.AccessInsert())
        //                { //ed.WriteMessage("\n116\n");
        //                }
        //                else
        //                    throw new System.Exception("Operation Transaction");
        //            }
        //        else
        //        {
        //            //ed.WriteMessage("\n1167\n");
        //        }
        //        return true;
        //    }
        //    else
        //        return false;
        //}
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        private bool SaveRodData(string NodeCode)
        {
            Editor           ed          = Application.DocumentManager.MdiActiveDocument.Editor;
            OleDbConnection  aConnection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString);
            OleDbTransaction aTransaction;

            try
            {
                aConnection.Open();
                aTransaction = aConnection.BeginTransaction();

                try
                {
                    //Atend.Base.Equipment.ERod ro = Atend.Base.Equipment.ERod.AccessSelectByXCode(ERod.XCode);
                    if (!UseAccess)
                    {
                        //if (ro.Code == -1)
                        {
                            if (!ERod.AccessInsert(aTransaction, aConnection, true, true))
                            {
                                throw new System.Exception("eRod.AccessInsert failed");
                            }
                        }
                    }


                    Atend.Base.Design.DPackage dPack = Atend.Base.Design.DPackage.AccessSelectByNodeCode(new Guid(NodeCode));
                    RodPack.Count       = 1;
                    RodPack.IsExistance = Existance;
                    RodPack.ProductCode = ERod.Code;
                    //if (ro.Code == -1)
                    //    RodPack.ProductCode = ERod.Code;
                    //else
                    //    RodPack.ProductCode = ro.Code;
                    RodPack.Type        = (int)Atend.Control.Enum.ProductType.Rod;
                    RodPack.ParentCode  = dPack.Code;
                    RodPack.LoadCode    = 0;
                    RodPack.Number      = "";
                    RodPack.ProjectCode = ProjectCode;
                    if (!RodPack.AccessInsert(aTransaction, aConnection))
                    {
                        throw new System.Exception("RodPack.AccessInsert failed");
                    }
                }
                catch (System.Exception ex1)
                {
                    ed.WriteMessage("ERROR SaveRodData 02 :{0} \n", ex1.Message);
                    aTransaction.Rollback();
                    aConnection.Close();
                    return(false);
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("ERROR SaveRodData 01 :{0} \n", ex.Message);
                aConnection.Close();
                return(false);
            }

            aTransaction.Commit();
            aConnection.Close();

            #region Not to Get Green

            Atend.Base.Acad.AcadGlobal.RodData.UseAccess = true;
            //UseAccess = true;

            #endregion


            return(true);
        }