private void btnCalc_Click(object sender, EventArgs e) { Atend.Global.Calculation.Section sec = new Atend.Global.Calculation.Section(); System.Data.DataTable w = Atend.Base.Design.DWeather.AccessSelectTest(1, 2); MessageBox.Show("w.Count=" + w.Rows.Count.ToString()); //sec.DetermineSection(); // Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; // Atend.Base.Base.BReport report = Atend.Base.Base.BReport.Select_ByCode(1); // System.Globalization.PersianCalendar calender = new System.Globalization.PersianCalendar(); // int day = calender.GetDayOfMonth(DateTime.Today); // int Month = calender.GetMonth(DateTime.Today); // int Year = calender.GetYear(DateTime.Today); // string date = Year.ToString() + "-" + Month.ToString() + "-" + day.ToString(); // string Name = "نتایج محاسبات مکانیکی" + date + Atend.Control.Common.DesignName + cboSelectSection.Text; // string PAthFile = Atend.Control.Common.fullPath + "\\ReportFile\\mohasebat m .xlsx"; // File.Copy(PAthFile, report.Value1 + Name+".xlsx", true); // ed.WriteMessage("PathFlash:={0},PAth={1}\n", PAthFile, report.Value1 + Name); // string Path = report.Value1 + Name; // Atend.Global.Utility.UReport.CreateReport(Path, dtSagTension,Dic,"Data1" ,1); // ed.WriteMessage("save First File\n"); // //Atend.Global.Utility.UReport.CreateReport(NameForce, dtPole,1 ,1); //Atend.Global.Utility.UReport.CreateReport(Path, dtPole,DicPoleForce,"Data3",1); }
private void btnSelect_Click(object sender, EventArgs e) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; SelectedList.Clear(); SectionCode.Clear(); int gvCount = gvNetCross.Rows.Count - 1; for (int i = gvCount; i >= 0; i--) { gvNetCross.Rows.RemoveAt(i); } //gvNetCross.Rows.Clear(); gvNetCross.Refresh(); section = new Atend.Global.Calculation.Section(); section.DetermineSection(); #region Select this.Hide(); // ~~~~~~~~~~~~ Start Select Entities int PoleCounter = 0; int ConductorCounter = 0; PromptSelectionOptions pso = new PromptSelectionOptions(); pso.MessageForAdding = "Select area where you want: \n"; PromptSelectionResult psr = ed.GetSelection(pso); if (psr.Status == PromptStatus.OK) { SelectionSet ss = psr.Value; ObjectId[] SelectedObjectID = ss.GetObjectIds(); foreach (ObjectId so in SelectedObjectID) { Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(so); if (at_info.ParentCode != "NONE" && (at_info.NodeType == (int)Atend.Control.Enum.ProductType.Pole || at_info.NodeType == (int)Atend.Control.Enum.ProductType.PoleTip)) { Atend.Global.Calculation.General.General.AutocadSelectedList Item = new Atend.Global.Calculation.General.General.AutocadSelectedList(); Item.ProductGuid = new Guid(at_info.NodeCode); Item.ProductType = at_info.NodeType; Item.ConductorAngle = 0; string PoleNumber = ""; Atend.Base.Acad.AT_SUB poleSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(so); foreach (ObjectId oi in poleSub.SubIdCollection) { Atend.Base.Acad.AT_INFO subinfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi); if (subinfo.ParentCode != "NONE" && subinfo.NodeType == (int)Atend.Control.Enum.ProductType.Comment) { MText dbt = Atend.Global.Acad.UAcad.GetEntityByObjectID(oi) as MText; if (dbt != null) { PoleNumber = dbt.Contents; } } } Item.PoleNumber = PoleNumber; SelectedList.Add(Item); PoleCounter++; } else if (at_info.ParentCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.Conductor) { Atend.Global.Calculation.General.General.AutocadSelectedList Item = new Atend.Global.Calculation.General.General.AutocadSelectedList(); Item.ProductGuid = new Guid(at_info.NodeCode); Item.ProductType = (int)Atend.Control.Enum.ProductType.Conductor; Item.ConductorAngle = 0; Item.PoleNumber = ""; SelectedList.Add(Item); ConductorCounter++; } else if (at_info.ParentCode != "NONE" && at_info.NodeType == (int)Atend.Control.Enum.ProductType.SelfKeeper) { Atend.Global.Calculation.General.General.AutocadSelectedList Item = new Atend.Global.Calculation.General.General.AutocadSelectedList(); Item.ProductGuid = new Guid(at_info.NodeCode); Item.ProductType = (int)Atend.Control.Enum.ProductType.SelfKeeper; Item.ConductorAngle = 0; Item.PoleNumber = ""; SelectedList.Add(Item); ConductorCounter++; } } lblPole.Text = PoleCounter.ToString(); lblConductor.Text = ConductorCounter.ToString(); ed.WriteMessage("Finish\n"); } else { lblPole.Text = "0"; lblConductor.Text = "0"; } // ~~~~~~~~~~~~ End Select Entities this.Show(); #endregion //********************** ed.WriteMessage("~~~~~~~~~~after select \n"); dtSectionNumber = new System.Data.DataTable(); System.Data.DataColumn dcColumn = new System.Data.DataColumn("Name"); System.Data.DataColumn dcColumn1 = new System.Data.DataColumn("Code"); dtSectionNumber.Columns.Add(dcColumn); dtSectionNumber.Columns.Add(dcColumn1); Boolean chk = true; //ed.WriteMessage("SelectedList.Count= " + SelectedList.Count.ToString() + "\n"); for (int i = 0; i < SelectedList.Count; i++) { chk = true; Atend.Global.Calculation.General.General.AutocadSelectedList cadInfo = (Atend.Global.Calculation.General.General.AutocadSelectedList)SelectedList[i]; //ed.WriteMessage("Guid= "+cadInfo.ProductGuid.ToString()+"ProductType = "+cadInfo.ProductType.ToString()+"\n"); Atend.Base.Design.DPoleSection poleSection = Atend.Base.Design.DPoleSection.AccessSelectByProductCodeProductType(cadInfo.ProductGuid, cadInfo.ProductType); //ed.WriteMessage("PoleSection.SectionCode Is= "+poleSection.SectionCode.ToString()+"\n"); if (SectionCode.Count != 0) { for (int j = 0; j < SectionCode.Count; j++) { if ((Guid)SectionCode[j] == poleSection.SectionCode) { chk = false; } } if (chk) { // ed.WriteMessage("Add To SectionCode,SectionCode Is={0}\n", poleSection.SectionCode); SectionCode.Add(poleSection.SectionCode); } } else { // ed.WriteMessage("Add To SectionCode Else,SectionCode Is={0}\n", poleSection.SectionCode); SectionCode.Add(poleSection.SectionCode); } //ed.WriteMessage("SectionCodeList.Count= "+SectionCode.Count.ToString()+"\n"); } //ed.WriteMessage("Finish Full SectionCode\n"); ////Add SectionNumber To DataTable for (int i = 0; i < SectionCode.Count; i++) { //ed.WriteMessage("**Sec.Code={0}\n", SectionCode[i].ToString()); Atend.Base.Design.DSection sectionNUmber = Atend.Base.Design.DSection.AccessSelectByCode((Guid)SectionCode[i]); System.Data.DataRow dr = dtSectionNumber.NewRow(); ed.WriteMessage("Sec.Number={0},Sec.Code={1}\n", sectionNUmber.Number, sectionNUmber.Code); dr["Name"] = sectionNUmber.Number.ToString(); dr["Code"] = sectionNUmber.Code.ToString(); dtSectionNumber.Rows.Add(dr); } //ed.WriteMessage("Finsh Add SectionNumber To DataTable\n"); ////BindDataToGrid In Combo Box For NetCross DataGridViewComboBoxColumn c = (DataGridViewComboBoxColumn)gvNetCross.Columns["Column2"]; c.DisplayMember = "Name"; c.ValueMember = "Code"; c.DataSource = Atend.Base.Calculating.CNetWorkCross.AccessSelectAll(); c.Selected = true; gvNetCross.AutoGenerateColumns = false; gvNetCross.DataSource = dtSectionNumber; //Bind Data To ComboBoxSelect Section cboSelectSection.DisplayMember = "Name"; cboSelectSection.ValueMember = "Code"; cboSelectSection.DataSource = dtSectionNumber; //************************* }
private void CreateSection() { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Delete(); section = new Atend.Global.Calculation.Section(); section.DetermineSection(); dtSectionNumber.Rows.Clear(); dtSection.Rows.Clear(); SectionCode.Clear(); Boolean chk = true; ////for (int i = 0; i < SelectedList.Count; i++) ////{ //// chk = true; //// Atend.Global.Calculation.General.General.AutocadSelectedList cadInfo = (Atend.Global.Calculation.General.General.AutocadSelectedList)SelectedList[i]; //// //ed.WriteMessage("Guid= "+cadInfo.ProductGuid.ToString()+"ProductType = "+cadInfo.ProductType.ToString()+"\n"); //// Atend.Base.Design.DPoleSection poleSection = Atend.Base.Design.DPoleSection.AccessSelectByProductCodeProductType(cadInfo.ProductGuid, cadInfo.ProductType); //// //ed.WriteMessage("PoleSection.SectionCode Is= "+poleSection.SectionCode.ToString()+"\n"); //// if (SectionCode.Count != 0) //// { //// for (int j = 0; j < SectionCode.Count; j++) //// { //// if ((Guid)SectionCode[j] == poleSection.SectionCode) //// { //// chk = false; //// } //// } //// if (chk) //// { //// // ed.WriteMessage("Add To SectionCode,SectionCode Is={0}\n", poleSection.SectionCode); //// SectionCode.Add(poleSection.SectionCode); //// } //// } //// else //// { //// // ed.WriteMessage("Add To SectionCode Else,SectionCode Is={0}\n", poleSection.SectionCode); //// SectionCode.Add(poleSection.SectionCode); //// } //// //ed.WriteMessage("SectionCodeList.Count= "+SectionCode.Count.ToString()+"\n"); ////} ////for (int i = 0; i < SectionCode.Count; i++) ////{ //// //ed.WriteMessage("**Sec.Code={0}\n", SectionCode[i].ToString()); //// Atend.Base.Design.DSection sectionNUmber = Atend.Base.Design.DSection.AccessSelectByCode((Guid)SectionCode[i]); //// System.Data.DataRow dr = dtSectionNumber.NewRow(); //// ed.WriteMessage("Sec.Number={0},Sec.Code={1}\n", sectionNUmber.Number, sectionNUmber.Code); //// dr["SectionNumber"] = sectionNUmber.Number.ToString(); //// dr["SectionCode"] = sectionNUmber.Code.ToString(); //// dtSectionNumber.Rows.Add(dr); ////} if (SelectedList.Count != 0) { BindDateTodtSectionNumber(); ed.WriteMessage("dtSectionNumber.Rows.count={0}\n", dtSectionNumber.Rows.Count); if (dtSectionNumber.Rows.Count > 0) { BindDataToGridSection(); chkSelectSection.Checked = true; // ReadVoltage(); } else { ed.WriteMessage("سکشن یافت نشد\n"); } } }