Exemplo n.º 1
0
 private void tsbShare_Click(object sender, EventArgs e)
 {
     if (selectedPhusePoleCode != Guid.Empty)
     {
         if (Atend.Base.Equipment.EContainerPackage.ShareOnServer(Convert.ToInt32(Atend.Control.Enum.ProductType.PhusePole), selectedPhusePoleCode))
         {
             Atend.Base.Equipment.EPhusePole PhusePole = Atend.Base.Equipment.EPhusePole.SelectByXCode(selectedPhusePoleCode);
             Code = PhusePole.Code;
             MessageBox.Show("به اشتراک گذاری با موفقیت انجام شد");
         }
         else
         {
             MessageBox.Show("خطا در به اشتراک گذاری .");
         }
     }
     else
     {
         MessageBox.Show("لطفا تجهیز مورد نظر را انتخاب کنید");
     }
     //if (selectedPhusePoleCode != Guid.Empty)
     //{
     //    if (Atend.Base.Equipment.EPhusePole.ShareOnServer(selectedPhusePoleCode))
     //    {
     //        Atend.Base.Equipment.EPhusePole p1 = Atend.Base.Equipment.EPhusePole.SelectByXCode(selectedPhusePoleCode);
     //        Code = p1.Code;
     //        MessageBox.Show("به اشتراک گذاری با موفقیت انجام شد");
     //    }
     //    else
     //        MessageBox.Show("خطا در به اشتراک گذاری . لطفاً دوباره سعی کنید");
     //}
     //else
     //    MessageBox.Show("لطفا تجهیز مورد نظر را انتخاب کنید");
 }
Exemplo n.º 2
0
        private void Save()
        {
            txtName.Focus();
            Atend.Base.Equipment.EPhusePole phusePole = new Atend.Base.Equipment.EPhusePole();
            phusePole.Amper       = Convert.ToDouble(txtAmper.Text);
            phusePole.ProductCode = Atend.Control.Common.selectedProductCode;
            phusePole.Comment     = txtComment.Text;
            phusePole.Name        = txtName.Text;
            phusePole.Mark        = txtMark.Text;
            phusePole.IsDefault   = IsDefault;
            phusePole.Code        = Code;

            //Equipment
            ArrayList EPackageProduct = new ArrayList();

            for (int j = 0; j < gvSelectedEquipment.Rows.Count; j++)
            {
                Atend.Base.Equipment.EProductPackage _EProductPackage = new Atend.Base.Equipment.EProductPackage();
                _EProductPackage.XCode     = new Guid(gvSelectedEquipment.Rows[j].Cells[0].Value.ToString());
                _EProductPackage.Count     = Convert.ToInt32(gvSelectedEquipment.Rows[j].Cells[2].Value.ToString());
                _EProductPackage.TableType = Convert.ToInt16(gvSelectedEquipment.Rows[j].Cells[3].Value.ToString());
                EPackageProduct.Add(_EProductPackage);
            }
            phusePole.EquipmentList = EPackageProduct;

            //Operation
            ArrayList EOperation = new ArrayList();

            for (int i = 0; i < gvOperation.Rows.Count; i++)
            {
                Atend.Base.Equipment.EOperation _EOperation = new Atend.Base.Equipment.EOperation();
                _EOperation.ProductID = Convert.ToInt32(gvOperation.Rows[i].Cells[0].Value);
                _EOperation.Count     = Convert.ToDouble(gvOperation.Rows[i].Cells[3].Value);
                EOperation.Add(_EOperation);
            }
            phusePole.OperationList = EOperation;
            if (selectedPhusePoleCode == Guid.Empty)
            {
                if (phusePole.InsertX())
                {
                    Reset();
                }
                else
                {
                    MessageBox.Show("امکان ثبت اطلاعات نمی باشد", "خطا");
                }
            }
            else
            {
                phusePole.XCode = selectedPhusePoleCode;
                if (phusePole.UpdateX())
                {
                    Reset();
                }
                else
                {
                    MessageBox.Show("امکان ذخیره سازی اطلاعات نمی باشد", "خطا");
                }
            }
        }
Exemplo n.º 3
0
        public void BindDataToOwnControl(Guid XCode)
        {
            selectedPhusePoleCode = XCode;
            Atend.Base.Equipment.EPhusePole phusePole = Atend.Base.Equipment.EPhusePole.SelectByXCode(XCode);
            //Atend.Base.Base.BProduct product = Atend.Base.Base.BProduct.Select_ByCode(phusePole.ProductCode);
            Atend.Control.Common.selectedProductCode = phusePole.ProductCode;
            SelectProduct();

            txtName.Text         = phusePole.Name;
            txtAmper.Text        = Convert.ToString(Math.Round(phusePole.Amper, 4));
            txtComment.Text      = phusePole.Comment;
            txtMark.Text         = phusePole.Mark;
            tsbIsDefault.Checked = phusePole.IsDefault;
            Code = phusePole.Code;
            BindTreeViwAndGrid();
        }
Exemplo n.º 4
0
 private bool CheckStatuseOfAccessChangeDefault()
 {
     Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
     ed.WriteMessage("AccessChangeDefault={0}\n", Atend.Control.Common.AccessChangeDefault);
     if (!Atend.Control.Common.AccessChangeDefault)
     {
         if (selectedPhusePoleCode == Guid.Empty && IsDefault)
         {
             MessageBox.Show("کاربر گرامی شما اجازه ثبت تجهیز به صورت پیش فرض ندارید", "خطا");
             return(false);
         }
         else
         {
             Atend.Base.Equipment.EPhusePole phusePole = Atend.Base.Equipment.EPhusePole.SelectByXCode(selectedPhusePoleCode);
             if (phusePole.IsDefault || IsDefault)
             {
                 MessageBox.Show("کاربر گرامی شما اجازه ویرایش  تجهیز به صورت پیش فرض ندارید", "خطا");
                 return(false);
             }
         }
     }
     return(true);
 }
Exemplo n.º 5
0
        private bool Validation()
        {
            //if (Atend.Control.Common.selectedProductCode == -1)
            //{
            //    MessageBox.Show("لطفا ابتدا یک کالا را از پشتیبان انتخاب کنید", "خطا");

            //    return false;
            //}
            if (string.IsNullOrEmpty(txtName.Text))
            {
                MessageBox.Show("لطفا نام را مشخص نمایید", "خطا");
                txtName.Focus();
                return(false);
            }
            if (Atend.Base.Equipment.EPhusePole.SearchByName(txtName.Text) == true && selectedPhusePoleCode == Guid.Empty)
            {
                MessageBox.Show("نام قبلا استفاده شده است", "خطا");
                txtName.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(txtAmper.Text))
            {
                MessageBox.Show("لطفا آمپراژ را مشخص نمایید", "خطا");
                txtAmper.Focus();
                return(false);
            }
            if (!Atend.Control.NumericValidation.DoubleConverter(txtAmper.Text))
            {
                MessageBox.Show("لطفاً آمپراژ را با فرمت مناسب مشخص نمایید", "خطا");
                txtAmper.Focus();
                txtAmper.Select(0, txtAmper.Text.Length);
                return(false);
            }
            if (string.IsNullOrEmpty(txtMark.Text))
            {
                MessageBox.Show("لطفا مدل را مشخص نمایید", "خطا");
                txtMark.Focus();
                return(false);
            }
            Atend.Base.Equipment.EPhusePole phusepole = Atend.Base.Equipment.EPhusePole.CheckForExist(Convert.ToDouble(txtAmper.Text), txtMark.Text);
            if (phusepole.Code != -1 && selectedPhusePoleCode == Guid.Empty)
            {
                if (MessageBox.Show("پایه فیوز با مشخصات داده شده موجود میباشد\n\n پایه فیوز با مشخصات فوق  : " + phusepole.Name + "\n\n" + "آیا مایل به ادامه  ثبت می باشید؟", "خطا", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    txtAmper.Focus();
                    return(false);
                }
            }
            if (!Atend.Global.Utility.UBinding.CheckGridValidation(gvOperation, 3))
            {
                MessageBox.Show("لطفا تعداد آماده سازی را با فرمت مناسب وارد نمایید", "خطا");
                return(false);
            }

            if (!Atend.Global.Utility.UBinding.CheckGridValidation(gvSelectedEquipment, 2))
            {
                MessageBox.Show("لطفا تعداد تجهیزات جانبی را با فرمت مناسب وارد نمایید", "خطا");
                return(false);
            }
            if (!Atend.Global.Utility.UBinding.CheckGridValidation(gvOperation, 3))
            {
                MessageBox.Show("لطفا تعداد آماده سازی را با فرمت مناسب وارد نمایید", "خطا");
                gvOperation.Focus();
                return(false);
            }
            if (!Atend.Global.Utility.UBinding.CheckGridValidation(gvSelectedEquipment, 2))
            {
                MessageBox.Show("لطفا تعداد تجهیزات جانبی را با فرمت مناسب وارد نمایید", "خطا");
                gvSelectedEquipment.Focus();
                return(false);
            }

            for (int j = 0; j < gvSelectedEquipment.Rows.Count; j++)
            {
                Atend.Base.Equipment.EProductPackage _EProductPackage = new Atend.Base.Equipment.EProductPackage();
                _EProductPackage.XCode     = new Guid(gvSelectedEquipment.Rows[j].Cells[0].Value.ToString());
                _EProductPackage.Count     = Convert.ToInt32(gvSelectedEquipment.Rows[j].Cells[2].Value.ToString());
                _EProductPackage.TableType = Convert.ToInt16(gvSelectedEquipment.Rows[j].Cells[3].Value.ToString());

                if (Atend.Base.Equipment.EContainerPackage.FindLoopNode(selectedPhusePoleCode, Convert.ToInt32(Atend.Control.Enum.ProductType.PhusePole), _EProductPackage.XCode, _EProductPackage.TableType))
                {
                    MessageBox.Show(string.Format("تجهیز '{0}' در زیر تجهیزات موجود می باشد", txtName.Text), "خطا");
                    gvSelectedEquipment.Focus();
                    return(false);
                }
            }

            return(CheckStatuseOfAccessChangeDefault());
            //return true;
        }
Exemplo n.º 6
0
        private bool SaveStreetBoxData()
        {
            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.EStreetBox sb = Atend.Base.Equipment.EStreetBox.AccessSelectByXCode(eStreetBox.XCode);
                    if (!UseAccess)
                    {
                        //if (sb.Code == -1)
                        {
                            if (!eStreetBox.AccessInsert(aTransaction, aConnection, true, true))
                            {
                                throw new System.Exception("eStreetBox.AccessInsert failed");
                            }
                        }
                        //}

                        //if (!UseAccess)
                        //{
                        foreach (Atend.Base.Equipment.EStreetBoxPhuse SelectedStreetBoxPhuse in eStreetBoxPhuse)
                        {
                            //ed.WriteMessage("@@{0}\n", SelectedStreetBoxPhuse.PhuseXCode);
                            //ed.WriteMessage("########## SelectedStreetBoxPhuse.PhuseXCode:{0}\n", SelectedStreetBoxPhuse.PhuseXCode);



                            Atend.Base.Equipment.EPhuse phuse = Atend.Base.Equipment.EPhuse.SelectByXCode(SelectedStreetBoxPhuse.PhuseXCode);
                            //ed.WriteMessage("########## phuse.Code:{0}\n", phuse.Code);
                            if (phuse.Code != -1)
                            {
                                Atend.Base.Equipment.EPhusePole _EPhusePole = Atend.Base.Equipment.EPhusePole.SelectByXCode(phuse.PhusePoleXCode);
                                if (_EPhusePole.Code != -1)
                                {
                                    //ed.WriteMessage("112\n");
                                    if (!_EPhusePole.AccessInsert(aTransaction, aConnection, true, true))
                                    {
                                        throw new System.Exception("AccessInsert failed PhusePole");
                                    }
                                }
                                else
                                {
                                    throw new System.Exception("Lack of data in StreetBox:Phuse:PhusePole");
                                }

                                phuse.PhusePoleCode = _EPhusePole.Code;
                                if (!phuse.AccessInsert(aTransaction, aConnection, true, true))
                                {
                                    throw new System.Exception("ePhuse.AccesInsert failed");
                                }
                                SelectedStreetBoxPhuse.PhuseCode     = phuse.Code;
                                SelectedStreetBoxPhuse.StreetBoxCode = eStreetBox.Code;
                                //if (sb.Code == -1)
                                //    SelectedStreetBoxPhuse.StreetBoxCode = eStreetBox.Code;
                                //else
                                //    SelectedStreetBoxPhuse.StreetBoxCode = sb.Code;
                                if (!SelectedStreetBoxPhuse.AccessInsert(aTransaction, aConnection, true, true))
                                {
                                    throw new System.Exception("EStreetBoxPhuseInsert failed");
                                }
                            }
                            else
                            {
                                throw new System.Exception("EPhuse.SelectByXCode failed");
                            }
                        }
                    }

                    StreetBoxPack             = new Atend.Base.Design.DPackage();
                    StreetBoxPack.Count       = 1;
                    StreetBoxPack.IsExistance = Existance;
                    StreetBoxPack.NodeCode    = Guid.Empty;
                    StreetBoxPack.Number      = "0";
                    StreetBoxPack.ParentCode  = Guid.Empty;
                    StreetBoxPack.ProjectCode = ProjectCode;
                    StreetBoxPack.ProductCode = eStreetBox.Code;
                    //if (sb.Code == -1)
                    //    StreetBoxPack.ProductCode = eStreetBox.Code;
                    //else
                    //    StreetBoxPack.ProductCode = sb.Code;
                    StreetBoxPack.Type = Convert.ToInt32(Atend.Control.Enum.ProductType.StreetBox);

                    if (!StreetBoxPack.AccessInsert(aTransaction, aConnection))
                    {
                        throw new System.Exception("StreetBoxPack.AccessInsert failed");
                    }
                }
                catch (System.Exception ex1)
                {
                    ed.WriteMessage("ERROR SaveStreetBoxData 02 :{0} \n", ex1.Message);
                    aTransaction.Rollback();
                    aConnection.Close();
                    return(false);
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("ERROR SaveStreetBoxData 01 :{0} \n", ex.Message);
                aConnection.Close();
                return(false);
            }

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

            #region Not to Get Green

            Atend.Base.Acad.AcadGlobal.StreetBoxData.UseAccess = true;
            UseAccess = true;

            #endregion


            return(true);
        }
Exemplo n.º 7
0
        //private string FindNameOperation(Guid Code)
        //{
        //    string DBName = string.Empty;
        //    Atend.Base.Equipment.EOperation eOP = Atend.Base.Equipment.EOperation.SelectByCode(Code);
        //    Atend.Base.Base.BProduct BP = Atend.Base.Base.BProduct.Select_ById(eOP.ProductID);

        //    DBName = BP.Name;
        //    PID = BP.Code;
        //    return DBName;
        //}

        private string FindNameAndProductCode(int Type, int ProductCode)
        {
            //Atend.Base.Equipment.EPole. p = new Atend.Base.Equipment.EPole();

            string DBName = string.Empty;

            switch ((Atend.Control.Enum.ProductType)Type)
            {
            case Atend.Control.Enum.ProductType.Pole:
                Atend.Base.Equipment.EPole ePole = Atend.Base.Equipment.EPole.SelectByCode(ProductCode);
                DBName = ePole.Name;
                PID    = ePole.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.Conductor:
                Atend.Base.Equipment.EConductor eConductor = Atend.Base.Equipment.EConductor.SelectByCode(ProductCode);
                DBName = eConductor.Name;
                PID    = eConductor.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.AuoKey3p:
                Atend.Base.Equipment.EAutoKey_3p eAuto = Atend.Base.Equipment.EAutoKey_3p.SelectByCode(ProductCode);
                DBName = eAuto.Name;
                PID    = eAuto.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.Breaker:
                Atend.Base.Equipment.EBreaker eBreaker = Atend.Base.Equipment.EBreaker.SelectByCode(ProductCode);
                DBName = eBreaker.Name;
                PID    = eBreaker.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.Bus:
                Atend.Base.Equipment.EBus eBus = Atend.Base.Equipment.EBus.SelectByCode(ProductCode);
                DBName = eBus.Name;
                PID    = eBus.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.CatOut:
                Atend.Base.Equipment.ECatOut eCatOut = Atend.Base.Equipment.ECatOut.SelectByCode(ProductCode);
                DBName = eCatOut.Name;
                PID    = eCatOut.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.CT:
                Atend.Base.Equipment.ECT eCT = Atend.Base.Equipment.ECT.SelectByCode(ProductCode);
                DBName = eCT.Name;
                PID    = eCT.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.DB:
                Atend.Base.Equipment.EDB eDB = Atend.Base.Equipment.EDB.SelectByCode(ProductCode);
                DBName = eDB.Name;
                PID    = eDB.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.HeaderCabel:
                Atend.Base.Equipment.EHeaderCabel eHeader = Atend.Base.Equipment.EHeaderCabel.SelectByCode(ProductCode);
                DBName = eHeader.Name;
                PID    = eHeader.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.Disconnector:
                Atend.Base.Equipment.EDisconnector eDC = Atend.Base.Equipment.EDisconnector.SelectByCode(ProductCode);
                DBName = eDC.Name;
                PID    = eDC.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.Rod:
                Atend.Base.Equipment.ERod eRod = Atend.Base.Equipment.ERod.SelectByCode(ProductCode);
                DBName = eRod.Name;
                PID    = eRod.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.Countor:
                Atend.Base.Equipment.ECountor eCounter = Atend.Base.Equipment.ECountor.SelectByCode(ProductCode);
                DBName = eCounter.Name;
                PID    = eCounter.ProductCode;
                break;

            //case Atend.Control.Enum.ProductType.JackPanel:
            //    Atend.Base.Equipment.EJAckPanel eJack = Atend.Base.Equipment.EJAckPanel.SelectByCode(ProductCode);
            //    break;

            case Atend.Control.Enum.ProductType.PhotoCell:
                Atend.Base.Equipment.EPhotoCell ePhotoCell = Atend.Base.Equipment.EPhotoCell.SelectByCode(ProductCode);
                DBName = ePhotoCell.Name;
                PID    = ePhotoCell.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.Phuse:
                Atend.Base.Equipment.EPhuse ePhuse = Atend.Base.Equipment.EPhuse.SelectByCode(ProductCode);
                DBName = ePhuse.Name;
                PID    = ePhuse.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.StreetBox:
                Atend.Base.Equipment.EStreetBox eStreet = Atend.Base.Equipment.EStreetBox.SelectByCode(ProductCode);
                DBName = eStreet.Name;
                PID    = eStreet.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.Transformer:
                Atend.Base.Equipment.ETransformer eTrans = Atend.Base.Equipment.ETransformer.SelectByCode(ProductCode);
                DBName = eTrans.Name;
                PID    = eTrans.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.PT:
                Atend.Base.Equipment.EPT ePT = Atend.Base.Equipment.EPT.SelectByCode(ProductCode);
                DBName = ePT.Name;
                PID    = ePT.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.Insulator:
                Atend.Base.Equipment.EInsulator eInsulator = Atend.Base.Equipment.EInsulator.SelectByCode(ProductCode);
                DBName = eInsulator.Name;
                PID    = eInsulator.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.ReCloser:
                Atend.Base.Equipment.EReCloser eRecloser = Atend.Base.Equipment.EReCloser.SelectByCode(ProductCode);
                DBName = eRecloser.Name;
                PID    = eRecloser.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.PhuseKey:
                Atend.Base.Equipment.EPhuseKey ePhusekey = Atend.Base.Equipment.EPhuseKey.SelectByCode(ProductCode);
                DBName = ePhusekey.Name;
                PID    = ePhusekey.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.Consol:
                Atend.Base.Equipment.EConsol eConsol = Atend.Base.Equipment.EConsol.SelectByCode(ProductCode);
                DBName = eConsol.Name;
                PID    = eConsol.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.PhusePole:
                Atend.Base.Equipment.EPhusePole ePhusepole = Atend.Base.Equipment.EPhusePole.SelectByCode(ProductCode);
                DBName = ePhusepole.Name;
                PID    = ePhusepole.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.MiddleJackPanel:
                Atend.Base.Equipment.EJAckPanel eJackP = Atend.Base.Equipment.EJAckPanel.SelectByCode(ProductCode);
                DBName = eJackP.Name;
                PID    = eJackP.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.Khazan:
                Atend.Base.Equipment.EKhazan eKhazan = Atend.Base.Equipment.EKhazan.SelectByCode(ProductCode);
                DBName = eKhazan.Name;
                PID    = eKhazan.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.GroundPost:
                Atend.Base.Equipment.EGroundPost ePost = Atend.Base.Equipment.EGroundPost.SelectByCode(ProductCode);
                DBName = ePost.Name;
                PID    = ePost.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.AirPost:
                Atend.Base.Equipment.EAirPost eAirpost = Atend.Base.Equipment.EAirPost.SelectByCode(ProductCode);
                DBName = eAirpost.Name;
                PID    = eAirpost.ProductCode;
                break;

            case Atend.Control.Enum.ProductType.WeekJackPanel:
                Atend.Base.Equipment.EJackPanelWeek eJPW = Atend.Base.Equipment.EJackPanelWeek.SelectByCode(ProductCode);
                DBName = eJPW.Name;
                PID    = eJPW.ProductCode;
                break;
            }

            return(DBName);
        }