private bool Validation() { if (gvSelfKeeper.SelectedRows.Count <= 0) { MessageBox.Show("لطفا کابل خودنگهدار مورد نظر را انتخاب نمایید", "خطا"); return(false); } Atend.Base.Design.DBranch Branch = Atend.Base.Design.DBranch.AccessSelectByCode(BranchCode); Atend.Base.Design.DBranch _DBranch = Atend.Base.Design.DBranch.AccessSelectByRigthAndLeftNodeCode(Branch.RightNodeCode, Branch.LeftNodeCode); if (_DBranch.Code != Guid.Empty) { if (Convert.ToDouble(txtLenght.Text) != _DBranch.Lenght) { if (MessageBox.Show(" تغیر در طول سیم باعث تغییر در طول سایر سیمهای بین این دو پایه میشود . آیا مایل به تغیر طول سیم هستید ؟ ", "خطا", MessageBoxButtons.YesNo) == DialogResult.No) { txtLenght.Text = Length.ToString(); return(false); } else { return(true); } } } else { _DBranch = Atend.Base.Design.DBranch.AccessSelectByRigthAndLeftNodeCode(Branch.LeftNodeCode, Branch.RightNodeCode); if (_DBranch.Code != Guid.Empty) { if (Convert.ToDouble(txtLenght.Text) != _DBranch.Lenght) { if (MessageBox.Show(" تغیر در طول سیم باعث تغییر در طول سایر سیمهای بین این دو پایه میشود . آیا مایل به تغیر طول سیم هستید ؟ ", "خطا", MessageBoxButtons.YesNo) == DialogResult.No) { txtLenght.Text = Length.ToString(); return(false); } else { return(true); } } } } return(true); }
private void btnOk_Click(object sender, EventArgs e) { for (int i = 0; i < ConductorList.Count; i++) { Atend.Global.Calculation.General.General.AutoCAdConductorList Cond = (Atend.Global.Calculation.General.General.AutoCAdConductorList)ConductorList[i]; Atend.Base.Design.DBranch Branch = Atend.Base.Design.DBranch.AccessSelectByCode(Cond.ConductorGuid); Atend.Base.Equipment.EConductorTip condTip = Atend.Base.Equipment.EConductorTip.AccessSelectByCode(Branch.ProductCode); //ed.WriteMessage("CondTip.Code= "+condTip.Code+"\n"); Atend.Base.Acad.AT_INFO at_info = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(Cond.ConductorObjectID); if (gvConductor.Rows.Count > 0) { //Branch.ProductCode = Convert.ToInt32(gvConductor.Rows[gvConductor.CurrentRow.Index].Cells[0].Value.ToString()); //Branch.XCode = new Guid(gvConductor.Rows[gvConductor.CurrentRow.Index].Cells[0].Value.ToString()); //if (chkIsExist.CheckState == CheckState.Unchecked && cboIsExist.SelectedIndex == 0) // Branch.IsExist = 0; //if (chkIsExist.Checked && cboIsExist.SelectedIndex == 0) // Branch.IsExist = 1; //if (chkIsExist.Checked && cboIsExist.SelectedIndex == 1) // Branch.IsExist = 2; //Branch.IsExist = chkIsExist.Checked; Branch.Number = condTip.Description; //if (Branch.AccessUpdate()) //{ // //at_info.ProductCode = Convert.ToInt32(gvConductor.Rows[gvConductor.CurrentRow.Index].Cells[0].Value.ToString()); // //**EDIT** // ////at_info.ProductCode = Convert.ToInt32(gvConductor.Rows[gvConductor.CurrentRow.Index].Cells[0].Value.ToString()); // ////at_info.Insert(); // //ed.WriteMessage("Branch.Number= " + Branch.Number + "\n"); // //ed.WriteMessage("Branch.OBJID= " + Cond.ConductorObjectID + "\n"); // Atend.Global.Acad.UAcad.ChangeBranchText(Cond.ConductorObjectID, Branch.Number); //} //else //{ // MessageBox.Show("ويرايش امكان پذير نمي باشد"); //} } } AllowClose = true; Close(); }
private void btnChange_Click(object sender, EventArgs e) { Atend.Global.Calculation.Electrical.CElectricalCrossSectionChane change = new Atend.Global.Calculation.Electrical.CElectricalCrossSectionChane(); for (int i = 0; i < gvConductor.Rows.Count; i++) { DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)gvConductor.Rows[i].Cells["chkSelect"]; if (chk.Value.ToString() == "True") { if (gvConductor.Rows[i].Cells["NameCommentTip"].Value.ToString() != "") { Atend.Base.Design.DBranch branch = Atend.Base.Design.DBranch.AccessSelectByCode(new Guid(gvConductor.Rows[i].Cells["Code"].Value.ToString())); change.DBranch.Add(branch); if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Conductor)) { Atend.Base.Equipment.EConductorTip CondTip = Atend.Base.Equipment.EConductorTip.SelectByXCode(new Guid(gvConductor.Rows[i].Cells["CommentTipXCode"].Value.ToString())); change.CondTip.Add(CondTip); } if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.SelfKeeper)) { Atend.Base.Equipment.ESelfKeeperTip SelfTip = Atend.Base.Equipment.ESelfKeeperTip.SelectByXCode(new Guid(gvConductor.Rows[i].Cells["CommentTipXCode"].Value.ToString())); change.SelfTip.Add(SelfTip); } //if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.GroundCabel)) //{ // Atend.Base.Equipment.EGroundCabelTip GroundTip = Atend.Base.Equipment.EGroundCabelTip.SelectByXCode(new Guid(gvConductor.Rows[i].Cells["CommentTipXCode"].Value.ToString())); // change.GroundTip.Add(GroundTip); //} } } } if (change.ChangeBranchInfo()) { MessageBox.Show("اعمال تغییرات با موفقیت انجام شد"); } else { MessageBox.Show("اعمال تغییرات با موفقیت انجام نشد"); } }
private void btnOk_Click(object sender, EventArgs e) { if (gvConductor.SelectedRows.Count > 0) { Atend.Base.Equipment.EGroundCabel GC = Atend.Base.Equipment.EGroundCabel.AccessSelectByCode(GCCode); Atend.Base.Design.DBranch Branch = Atend.Base.Design.DBranch.AccessSelectByCode(BranchCode);// SelectByCode(BranchCode); Branch.ProductCode = Convert.ToInt32(gvConductor.SelectedRows[0].Cells[0].Value.ToString()); //if (Branch.AccessUpdate()) //{ // //ed.WriteMessage("OK"); // //Atend.Base.Acad.AT_INFO // GCCode = Convert.ToInt32(gvConductor.SelectedRows[0].Cells[0].Value.ToString()); // AllowClose = true; // this.Close(); //} //else // MessageBox.Show("انجام ويرايش امكانپذير نيست"); } }
private bool Validation() { if (!Atend.Control.NumericValidation.DoubleConverter(txtLength.Text)) { MessageBox.Show("لطفا طول هادی را با فرمت مناسب وارد نمایید"); txtLength.Focus(); return(false); } if (_StartPole != Guid.Empty && _EndPole != Guid.Empty) { Atend.Base.Design.DBranch _DBranch = Atend.Base.Design.DBranch.AccessSelectByRigthAndLeftNodeCode(_StartPole, _EndPole); if (_DBranch.Code != Guid.Empty) { if (Convert.ToDouble(txtLength.Text) != _DBranch.Lenght) { MessageBox.Show("لطفا طول سیم را تصحیح نمایید" + "\n" + "طول مورد تایید :" + _DBranch.Lenght.ToString()); txtLength.Text = _DBranch.Lenght.ToString(); btnOk.Focus(); return(false); } } else { _DBranch = Atend.Base.Design.DBranch.AccessSelectByRigthAndLeftNodeCode(_EndPole, _StartPole); if (_DBranch.Code != Guid.Empty) { if (Convert.ToDouble(txtLength.Text) != _DBranch.Lenght) { MessageBox.Show("لطفا طول سیم را تصحیح نمایید" + "\n" + "طول مورد تایید :" + _DBranch.Lenght.ToString()); txtLength.Text = _DBranch.Lenght.ToString(); btnOk.Focus(); return(false); } } } } return(true); }
private void پروندهToolStripMenuItem_Click(object sender, EventArgs e) { calcOptimalSagTension = new Atend.Global.Calculation.Mechanical.CalcOptimalSagTensionTest(); if (Validation()) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; calcOptimalSagTension.DtPoleSection = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(cboSelectSection.SelectedValue.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.Pole)); ed.WriteMessage("dtPoleSection1={0}\n", calcOptimalSagTension.DtPoleSection.Rows.Count); System.Data.DataTable dtPole = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(cboSelectSection.SelectedValue.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.PoleTip)); ed.WriteMessage("dtPoleSection2={0}\n", calcOptimalSagTension.DtPoleSection.Rows.Count); foreach (DataRow dr in dtPole.Rows) { DataRow drPole = calcOptimalSagTension.DtPoleSection.NewRow(); drPole["ProductType"] = dr["ProductType"].ToString(); drPole["ProductCode"] = dr["ProductCode"].ToString(); drPole["SectionCode"] = dr["SectionCode"].ToString(); calcOptimalSagTension.DtPoleSection.Rows.Add(drPole); } System.Data.DataColumn dc = new System.Data.DataColumn("PoleNumber"); calcOptimalSagTension.DtPoleSection.Columns.Add(dc); foreach (DataRow dr in calcOptimalSagTension.DtPoleSection.Rows) { Atend.Base.Design.DPackage node = Atend.Base.Design.DPackage.AccessSelectByNodeCode(new Guid(dr["ProductCode"].ToString())); dr["PoleNumber"] = node.Number.ToString(); } calcOptimalSagTension.VTS = Convert.ToDouble(txtVTS.Text); calcOptimalSagTension.Volt = Convert.ToDouble(cboVolt.Text); calcOptimalSagTension.DtPoleCond = section.dtGlobal; calcOptimalSagTension.dtBranchList = section.dtBranchList; //ed.WriteMessage("Befor Read NetCross\n"); for (int i = 0; i < gvNetCross.Rows.Count; i++) { if (Convert.ToInt32(gvNetCross.Rows[i].Cells[0].Value) == Convert.ToInt32(cboSelectSection.Text)) { DataGridViewComboBoxCell cboNetCross = (DataGridViewComboBoxCell)gvNetCross.Rows[i].Cells["Column2"]; NetCross = Atend.Base.Calculating.CNetWorkCross.AccessSelectByCode(Convert.ToInt32(cboNetCross.Value.ToString())); } } if (cboVolt.Text == "400") { calcOptimalSagTension.Clearance = NetCross.V380; } if (cboVolt.Text == "11000") { calcOptimalSagTension.Clearance = NetCross.KV11; } if (cboVolt.Text == "20000") { calcOptimalSagTension.Clearance = NetCross.KV20; } if (cboVolt.Text == "33000") { calcOptimalSagTension.Clearance = NetCross.KV32; } //ed.WriteMessage("Create DtconductorSectionConsol={0}\n", cboSelectSection.SelectedValue.ToString()); calcOptimalSagTension.DtconductorSection = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(cboSelectSection.SelectedValue.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.Conductor)); if (calcOptimalSagTension.DtconductorSection.Rows.Count == 0) { //ed.WriteMessage("Create DtconductorSection={0}\n", cboSelectSection.SelectedValue.ToString()); calcOptimalSagTension.DtconductorSection = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(cboSelectSection.SelectedValue.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.SelfKeeper)); //ed.WriteMessage("Count={0}\n", calcOptimalSagTension.DtconductorSection.Rows.Count); } System.Data.DataColumn dc1 = new System.Data.DataColumn("Angle"); calcOptimalSagTension.DtconductorSection.Columns.Add(dc1); calcOptimalSagTension.SectionCode = new Guid(cboSelectSection.SelectedValue.ToString()); calcOptimalSagTension.Start = Convert.ToInt32(txtStart.Text); calcOptimalSagTension.End = Convert.ToInt32(txtEnd.Text); calcOptimalSagTension.Distance = Convert.ToInt32(txtDistance.Text); Atend.Base.Design.DBranch MyBranch = Atend.Base.Design.DBranch.AccessSelectByCode(new Guid(calcOptimalSagTension.DtconductorSection.Rows[0]["ProductCode"].ToString())); //ed.WriteMessage("OOO\n"); dtSagTension.Rows.Clear(); dtPole.Rows.Clear(); dtConductorDay.Rows.Clear(); se = calcOptimalSagTension.ComputeSE(); SpanCount = calcOptimalSagTension.DtconductorSection.Rows.Count; dtSagTension = calcOptimalSagTension.CalSagTension(MyBranch).Copy(); dtConductorDay = calcOptimalSagTension.CalcTempTable(); gvSagAndTension.AutoGenerateColumns = false; gvPole.AutoGenerateColumns = false; gvSagAndTension.DataSource = dtSagTension; gvConductorDay.DataSource = dtConductorDay; dtPole = calcOptimalSagTension.WindOnPole(); gvPole.DataSource = dtPole; //calcOptimalSagTension.IsSagOk(); DataRow dr1 = dtRow.NewRow(); dr1["ProjectName"] = ""; dr1["NumSection"] = cboSelectSection.Text; dr1["FirstPole"] = ""; dr1["LastPole"] = ""; dr1["UTS"] = txtVTS.Text; dr1["SE"] = se.ToString(); dr1["SpanCount"] = SpanCount; dr1["SpanLenght"] = ""; dr1["CondName"] = gvSagAndTension.Rows[0].Cells[0].Value; dtRow.Rows.Add(dr1); } }
public static void SetBranchData(Atend.Base.Design.DBranch Branch, int BranchMode) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; // ed.WriteMessage("Branch>productType={0},Mode={1},BranchGuid={2}\n",Branch.ProductType,BranchMode.ToString(),Branch.Code); if (Branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Conductor)) { Atend.Base.Equipment.EConductorTip MyConductorTip = Atend.Base.Equipment.EConductorTip.AccessSelectByCode(Branch.ProductCode); Atend.Base.Equipment.EConductor MyConductor = new Atend.Base.Equipment.EConductor(); switch ((Atend.Control.Enum.BranchMode)BranchMode) { case Atend.Control.Enum.BranchMode.Phase: { MyConductor = Atend.Base.Equipment.EConductor.AccessSelectByCode(MyConductorTip.PhaseProductCode); //ed.WriteMessage("***MyMranch.Name={0}\n",MyConductor.Name); break; } case Atend.Control.Enum.BranchMode.Night: { MyConductor = Atend.Base.Equipment.EConductor.AccessSelectByCode(MyConductorTip.NightProductCode); break; } case Atend.Control.Enum.BranchMode.Netural: { MyConductor = Atend.Base.Equipment.EConductor.AccessSelectByCode(MyConductorTip.NeutralProductCode); break; } } Atend.Global.Calculation.Mechanical.CCommon.Code = MyConductor.Code; //double f=10e-6; //ed.WriteMessage("10^-6={0}\n", f.ToString()); Atend.Global.Calculation.Mechanical.CCommon.Alpha = MyConductor.Alpha * Math.Pow(10, -6); Atend.Global.Calculation.Mechanical.CCommon.Diagonal = MyConductor.Diagonal; Atend.Global.Calculation.Mechanical.CCommon.UTS = MyConductor.UTS; Atend.Global.Calculation.Mechanical.CCommon.Name = MyConductor.Name; Atend.Global.Calculation.Mechanical.CCommon.Alasticity = MyConductor.Alasticity; Atend.Global.Calculation.Mechanical.CCommon.CrossSectionArea = MyConductor.CrossSectionArea; Atend.Global.Calculation.Mechanical.CCommon.WC = MyConductor.Wc; Atend.Global.Calculation.Mechanical.CCommon.Type = MyConductor.TypeCode; //ed.WriteMessage("**************ALPHA={0},ConductorALPHA={1}\n", Atend.Global.Calculation.Mechanical.CCommon.Alpha, MyConductor.Alpha); } else { Atend.Base.Equipment.ESelfKeeperTip MySelfKeeperTip = Atend.Base.Equipment.ESelfKeeperTip.AccessSelectByCode(Branch.ProductCode); Atend.Base.Equipment.ESelfKeeper MySelfKeeper = new Atend.Base.Equipment.ESelfKeeper(); switch ((Atend.Control.Enum.BranchMode)BranchMode) { case Atend.Control.Enum.BranchMode.Phase: { MySelfKeeper = Atend.Base.Equipment.ESelfKeeper.AccessSelectByCode(MySelfKeeperTip.PhaseProductCode); break; } case Atend.Control.Enum.BranchMode.Night: { MySelfKeeper = Atend.Base.Equipment.ESelfKeeper.AccessSelectByCode(MySelfKeeperTip.NightProductCode); break; } case Atend.Control.Enum.BranchMode.Netural: { MySelfKeeper = Atend.Base.Equipment.ESelfKeeper.AccessSelectByCode(MySelfKeeperTip.NeutralProductCode); break; } } Atend.Global.Calculation.Mechanical.CCommon.Code = MySelfKeeper.Code; Atend.Global.Calculation.Mechanical.CCommon.Alpha = MySelfKeeper.Alpha * Math.Pow(10, -6); Atend.Global.Calculation.Mechanical.CCommon.Diagonal = MySelfKeeper.Diagonal; Atend.Global.Calculation.Mechanical.CCommon.UTS = MySelfKeeper.UTS; Atend.Global.Calculation.Mechanical.CCommon.Name = MySelfKeeper.Name; Atend.Global.Calculation.Mechanical.CCommon.Alasticity = MySelfKeeper.Alastisity; Atend.Global.Calculation.Mechanical.CCommon.CrossSectionArea = MySelfKeeper.CrossSectionKeeper; Atend.Global.Calculation.Mechanical.CCommon.WC = MySelfKeeper.Weight; } }
//DataColumn dcSCCurrent = new DataColumn("SCCurrent"); //DataColumn CondMax1sCurrent = new DataColumn("CondMax1sCurrent"); public frmElectericalResult(DataTable dtNodes, DataTable dtBranch) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage("\nchecking.....\n"); if (!Atend.Global.Acad.DrawEquips.Dicision.IsHere()) { if (!Atend.Global.Acad.DrawEquips.Dicision.IsThere()) { //System.Diagnostics.Process[] prs = System.Diagnostics.Process.GetProcesses(); //foreach (System.Diagnostics.Process pr in prs) //{ // if (pr.ProcessName == "acad") // { // pr.CloseMainWindow(); // } //} Atend.Global.Acad.Notification notification = new Atend.Global.Acad.Notification(); notification.Title = "شناسایی قفل"; notification.Msg = "لطفا وضعیت قفل را بررسی نمایید "; notification.infoCenterBalloon(); ForceToClose = true; } } InitializeComponent(); dtResultNode.Columns.Add(dcLoadPowerImage); dtResultNode.Columns.Add(dcLoadPowerReal); dtResultNode.Columns.Add(dcVoltAbs); dtResultNode.Columns.Add(dcVoltAng); dtResultNode.Columns.Add(dcVoltDropPer); dtResultNode.Columns.Add(dcLoadCurrentAbs); dtResultNode.Columns.Add(dcLoadCurrentArg); dtResultNode.Columns.Add(dcConsolGuid); dtResultBranch.Columns.Add(dcCode); dtResultBranch.Columns.Add(dcCondUtilization); dtResultBranch.Columns.Add(dcLenght); dtResultBranch.Columns.Add(dcCurrentAbs); dtResultBranch.Columns.Add(dcCurrentAng); dtResultBranch.Columns.Add(dcTotalLoadREal); dtResultBranch.Columns.Add(dcCondCode); dtResultBranch.Columns.Add(dcCondCurrent); dtResultBranch.Columns.Add(dcFrom); dtResultBranch.Columns.Add(dcTo); dtResultBranch.Columns.Add(dcPowerLoss); //dtResultBranch.Columns.Add(dcSCCurrent); //dtResultBranch.Columns.Add(CondMax1sCurrent); //ed.WriteMessage("Print Nodes\n"); Atend.Base.Calculating.CDistributedLoadBranch.AccessDelete(); Atend.Base.Calculating.CDistributedLoadNode.AccessDelete(); foreach (DataRow dr in dtNodes.Rows) { DataRow drNew = dtResultNode.NewRow(); Atend.Base.Calculating.CDistributedLoadNode loadNode = new Atend.Base.Calculating.CDistributedLoadNode(); Atend.Base.Design.DPackage pack = Atend.Base.Design.DPackage.AccessSelectByCode(new Guid(dr["ConsoleGuid"].ToString())); if (pack.Code != Guid.Empty) { drNew["ConsolGuid"] = pack.Number; loadNode.NodeName = pack.Number; drNew["VoltAbs"] = Math.Round(((Complex)dr["Voltage"]).abs, 3); loadNode.VoltAbs = Math.Round(((Complex)dr["Voltage"]).abs, 3); double voltDegree = ConvertToDegree(((Complex)dr["Voltage"]).arg); //drNew["VoltArg"] = Math.Round(((Complex)dr["Voltage"]).arg, 2); //loadNode.VoltArg = Math.Round(((Complex)dr["Voltage"]).arg, 2); drNew["VoltArg"] = Math.Round(voltDegree, 2); loadNode.VoltArg = Math.Round(voltDegree, 2); double voltDropPer = 100 - Convert.ToDouble(dr["VoltageDropPer"].ToString()); drNew["VoltDropPer"] = Math.Round(voltDropPer, 2); loadNode.DropVolt = Convert.ToDouble(Math.Round(voltDropPer, 2)); drNew["LoadPowerReal"] = Math.Round(((Complex)dr["LoadPower"]).imag, 3) / 1000; loadNode.LoadPower = Math.Round(((Complex)dr["LoadPower"]).imag, 3) / 1000; drNew["LoadPowerImg"] = Math.Round(((Complex)dr["LoadPower"]).real, 3) / 1000; loadNode.LoadPowerActive = Math.Round(((Complex)dr["LoadPower"]).real, 3) / 1000; drNew["LoadCurrentAbs"] = Math.Round(((Complex)dr["LoadCurrent"]).abs, 3);//.ToString(); loadNode.LoadCurrentAbs = Math.Round(((Complex)dr["LoadCurrent"]).abs, 3); double LoadCurrentArg = ConvertToDegree(((Complex)dr["LoadCurrent"]).arg); //drNew["LoadCurrentArg"] = Math.Round(((Complex)dr["LoadCurrent"]).arg, 3); //loadNode.LoadCurrentArg = Math.Round(((Complex)dr["LoadCurrent"]).arg, 3); drNew["LoadCurrentArg"] = Math.Round(LoadCurrentArg, 3); loadNode.LoadCurrentArg = Math.Round(LoadCurrentArg, 3); dtResultNode.Rows.Add(drNew); if (!loadNode.AccessInsert()) { ed.WriteMessage("LoadNode Insert Failed\n"); } } } //ed.WriteMessage("Print Branch\n"); double totalLoad = 0; foreach (DataRow dr in dtBranch.Rows) { DataRow drNew = dtResultBranch.NewRow(); Atend.Base.Calculating.CDistributedLoadBranch LoadBranch = new Atend.Base.Calculating.CDistributedLoadBranch(); Atend.Base.Design.DBranch branch = Atend.Base.Design.DBranch.AccessSelectByCode(new Guid(dr["Code"].ToString())); if (branch.Code != Guid.Empty) { drNew["Code"] = branch.Number; LoadBranch.BranchName = branch.Number; drNew["Lenght"] = Math.Round(Convert.ToDouble(dr["Length"].ToString()), 2); LoadBranch.Lenght = Math.Round(Convert.ToDouble(dr["Length"].ToString()), 3); drNew["CondUtilization"] = Math.Round(Convert.ToDouble(dr["CondUtilization"].ToString()), 3); LoadBranch.Condutilization = Math.Round(Convert.ToDouble(dr["CondUtilization"].ToString()), 3); drNew["CurrentAbs"] = Math.Round(((Complex)dr["Current"]).abs, 3);//.ToString(); LoadBranch.CurrentAbs = Math.Round(((Complex)dr["Current"]).abs, 3); double currentArg = ConvertToDegree(((Complex)dr["Current"]).arg); //drNew["CurrentArg"] = Math.Round(((Complex)dr["Current"]).arg, 3); //LoadBranch.CurrentArg = Math.Round(((Complex)dr["Current"]).arg, 3); drNew["CurrentArg"] = Math.Round(currentArg, 3); LoadBranch.CurrentArg = Math.Round(currentArg, 3); //MessageBox.Show(dr["PowerLoss"].ToString()); totalLoad += Math.Round(((Complex)dr["TotalLoad"]).real / 1000 + (Convert.ToDouble(dr["PowerLoss"].ToString()) / 1000), 3); drNew["TotalLoadReal"] = totalLoad; LoadBranch.TotalLoad = totalLoad;//Math.Round(((Complex)dr["TotalLoad"]).real / 1000 + (Convert.ToDouble(dr["PowerLoss"].ToString()) / 1000), 3); ed.WriteMessage("CondCode={0}\n", dr["CondCode"].ToString()); if ((branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Conductor)) || (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Jumper)) || (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Terminal))) { Atend.Base.Equipment.EConductorTip econdTip = Atend.Base.Equipment.EConductorTip.AccessSelectByCode(branch.ProductCode); Atend.Base.Equipment.EConductor eCond = Atend.Base.Equipment.EConductor.AccessSelectByCode(econdTip.PhaseProductCode); drNew["CondName"] = eCond.Name; drNew["CondCurrent"] = eCond.MaxCurrent; LoadBranch.CondName = eCond.Name; LoadBranch.CondCurrent = eCond.MaxCurrent; } else if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.SelfKeeper)) { Atend.Base.Equipment.ESelfKeeperTip eSelTip = Atend.Base.Equipment.ESelfKeeperTip.AccessSelectByCode(branch.ProductCode); Atend.Base.Equipment.ESelfKeeper eSelf = Atend.Base.Equipment.ESelfKeeper.AccessSelectByCode(eSelTip.PhaseProductCode); drNew["CondName"] = eSelf.Name; drNew["CondCurrent"] = eSelf.MaxCurrent; LoadBranch.CondName = eSelf.Name; LoadBranch.CondCurrent = eSelf.MaxCurrent; } else if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.GroundCabel)) { Atend.Base.Equipment.EGroundCabelTip egroundTip = Atend.Base.Equipment.EGroundCabelTip.AccessSelectByCode(branch.ProductCode); Atend.Base.Equipment.EGroundCabel eGround = Atend.Base.Equipment.EGroundCabel.AccessSelectByCode(egroundTip.PhaseProductCode); drNew["CondName"] = eGround.Name; drNew["CondCurrent"] = eGround.MaxCurrent; LoadBranch.CondName = eGround.Name; LoadBranch.CondCurrent = eGround.MaxCurrent; } DataRow[] drnodeFrom = dtNodes.Select(string.Format("ConsoleObjID={0}", dr["UpNodeId"].ToString())); if (drnodeFrom.Length > 0) { drNew["From"] = FindNodeComment(new Guid(drnodeFrom[0]["ConsoleGuid"].ToString())); LoadBranch.From = drNew["From"].ToString(); } //به DataRow[] drnodeTo = dtNodes.Select(string.Format("ConsoleObjID={0}", dr["DnNodeId"].ToString())); if (drnodeTo.Length > 0) { //drNew["Volt"] = Math.Round(((Complex)(drnodeTo[0]["Voltage"])).abs, 2).ToString(); drNew["To"] = FindNodeComment(new Guid(drnodeTo[0]["ConsoleGuid"].ToString())); LoadBranch.To = drNew["To"].ToString(); } LoadBranch.PowerLoss = Math.Round(Convert.ToDouble(dr["PowerLoss"]) / 1000, 2); drNew["PowerLoss"] = Math.Round(Convert.ToDouble(dr["PowerLoss"]) / 1000, 2); dtResultBranch.Rows.Add(drNew); if (!LoadBranch.AccessInsert()) { ed.WriteMessage("LoadBranch Inser Failed\n"); } } //drNew["SCCurrent"] = Math.Round(Convert.ToDouble(dr["SCCurrent"].ToString()), 3); //drNew["CondMax1sCurrent"] = Math.Round(Convert.ToDouble(dr["CondMax1sCurrent"].ToString()), 3); } //ed.WriteMessage("BindDAtA\n"); //string Code1 = "00000000-0000-0000-0000-000000000000"; //DataRow[] drs = dtResultBranch.Select(" Code= '" + Code1 + "'"); //drs[0].Delete(); //DataRow[] drs1 = dtResultNode.Select(" ConsolGuid ='" + Code1 + "'"); //drs1[0].Delete(); gvBranch.AutoGenerateColumns = false; gvBranch.DataSource = dtResultBranch; gvNode.AutoGenerateColumns = false; gvNode.DataSource = dtResultNode; }
private void Calculation() { chkSelectSection.Focus(); if (Validation()) { this.Cursor = Cursors.WaitCursor; System.Data.DataTable dtGlobal = Atend.Base.Design.DGlobal.AccessSelectAll(); System.Data.DataTable dtBranch = Atend.Global.Acad.UAcad.FillBranchList(); Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; for (int gCounter = 0; gCounter < gvSection.Rows.Count; gCounter++) { DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)gvSection.Rows[gCounter].Cells[1]; if (chk.Value.ToString() == "True") { calcOptimalSagTension = new Atend.Global.Calculation.Mechanical.CalcOptimalSagTension(); calcOptimalSagTension.DtPoleSection = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(gvSection.Rows[gCounter].Cells[0].Value.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.Pole)); System.Data.DataTable dtPole1 = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(gvSection.Rows[gCounter].Cells[0].Value.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.PoleTip)); foreach (DataRow dr in dtPole1.Rows) { DataRow drPole = calcOptimalSagTension.DtPoleSection.NewRow(); drPole["ProductType"] = dr["ProductType"].ToString(); drPole["ProductCode"] = dr["ProductCode"].ToString(); drPole["SectionCode"] = dr["SectionCode"].ToString(); calcOptimalSagTension.DtPoleSection.Rows.Add(drPole); } System.Data.DataColumn dc = new System.Data.DataColumn("PoleNumber"); calcOptimalSagTension.DtPoleSection.Columns.Add(dc); foreach (DataRow dr in calcOptimalSagTension.DtPoleSection.Rows) { Atend.Base.Design.DPackage node = Atend.Base.Design.DPackage.AccessSelectByNodeCode(new Guid(dr["ProductCode"].ToString())); dr["PoleNumber"] = node.Number.ToString(); } ReadVoltage(gCounter); calcOptimalSagTension.Volt = Volt; calcOptimalSagTension.DtPoleCond = dtGlobal; calcOptimalSagTension.dtBranchList = dtBranch; DataGridViewComboBoxCell cboNetCross = (DataGridViewComboBoxCell)gvSection.Rows[gCounter].Cells[4]; //ed.WriteMessage("NetCrossCode={0}\n", cboNetCross.Value.ToString()); NetCross = Atend.Base.Calculating.CNetWorkCross.AccessSelectByCode(Convert.ToInt32(cboNetCross.Value.ToString())); if (Volt == 400) { calcOptimalSagTension.Clearance = NetCross.V380; } if (Volt == 11000) { calcOptimalSagTension.Clearance = NetCross.KV11; } if (Volt == 20000) { calcOptimalSagTension.Clearance = NetCross.KV20; } if (Volt == 33000) { calcOptimalSagTension.Clearance = NetCross.KV32; } calcOptimalSagTension.DtconductorSection = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(gvSection.Rows[gCounter].Cells[0].Value.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.Conductor)); if (calcOptimalSagTension.DtconductorSection.Rows.Count == 0) { calcOptimalSagTension.DtconductorSection = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(gvSection.Rows[gCounter].Cells[0].Value.ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.SelfKeeper)); //ed.WriteMessage("Count={0}\n", calcOptimalSagTension.DtconductorSection.Rows.Count); } calcOptimalSagTension.VTS = Convert.ToDouble(gvSection.Rows[gCounter].Cells["UTS"].Value.ToString()); //System.Data.DataColumn dc1 = new System.Data.DataColumn("Angle"); //calcOptimalSagTension.DtconductorSection.Columns.Add(dc1); calcOptimalSagTension.SectionCode = new Guid(gvSection.Rows[gCounter].Cells[0].Value.ToString()); //calcOptimalSagTension.Start = Convert.ToInt32(txtStart.Text); //calcOptimalSagTension.End = Convert.ToInt32(txtEnd.Text); //calcOptimalSagTension.Distance = Convert.ToInt32(txtDistance.Text); Atend.Base.Design.DBranch MyBranch = Atend.Base.Design.DBranch.AccessSelectByCode(new Guid(calcOptimalSagTension.DtconductorSection.Rows[0]["ProductCode"].ToString())); //ed.WriteMessage("OOO\n"); dtResult.Rows.Clear(); //se = calcOptimalSagTension.ComputeSE(); //ed.WriteMessage("&&&&&&&&&&&&&&&&&&&SE={0}\n", se.ToString()); //SpanCount = calcOptimalSagTension.DtconductorSection.Rows.Count; calcOptimalSagTension.dtStTable.Rows.Clear(); ed.WriteMessage("GOTOSurface\n"); dtResult = calcOptimalSagTension.calcRudSurface02().Copy(); gvResult.AutoGenerateColumns = false; calcOptimalSagTension.CloseConnection(); gvResult.DataSource = dtResult; Save(gCounter); } } this.Cursor = Cursors.Default; //DataRow dr1 = dtRow.NewRow(); //dr1["ProjectName"] = ""; //dr1["NumSection"] = gvSection.SelectedRows[0].Cells[1].Value.ToString(); //dr1["FirstPole"] = ""; //dr1["LastPole"] = ""; //dr1["UTS"] = calcOptimalSagTension.VTS; //dr1["SE"] = se.ToString(); //dr1["SpanCount"] = SpanCount; //dr1["SpanLenght"] = ""; //dr1["CondName"] = gvSagAndTension.Rows[0].Cells[0].Value; //dtRow.Rows.Add(dr1); //ChangeColor(); } }
private void frmEditDrawSelfKeeper_Load(object sender, EventArgs e) { if (ForceToClose) { this.Close(); } dtMerge = Atend.Base.Equipment.ESelfKeeperTip.SelectAllAndMerge(); Atend.Base.Design.DBranch Branch = Atend.Base.Design.DBranch.AccessSelectByCode(BranchCode); Atend.Base.Equipment.ESelfKeeperTip SelfTip = Atend.Base.Equipment.ESelfKeeperTip.AccessSelectByCode(Branch.ProductCode); selectedProductCode = SelfTip.Code; System.Data.DataColumn dcMaterialName = new System.Data.DataColumn("MaterialName"); System.Data.DataColumn dcAMP = new System.Data.DataColumn("AMP"); dtMerge.Columns.Add("AMP"); dtMerge.Columns.Add(dcMaterialName); foreach (DataRow dr in dtMerge.Rows) { dr["AMP"] = string.Format("{0}+{1}j", dr["Resistance"].ToString(), dr["Reactance"].ToString()); if (Convert.ToInt32(dr["MaterialConductorCode"].ToString()) == 1) { dr["MaterialName"] = "مسی"; } if (Convert.ToInt32(dr["MaterialConductorCode"].ToString()) == 2) { dr["MaterialName"] = "آلومینیوم"; } if (Convert.ToInt32(dr["MaterialConductorCode"].ToString()) == 3) { dr["MaterialName"] = "آلومینیو مغز فولاد"; } if (Convert.ToInt32(dr["MaterialConductorCode"].ToString()) == 4) { dr["MaterialName"] = "آلیاژ آلومینیوم"; } } gvSelfKeeper.AutoGenerateColumns = false; gvSelfKeeper.DataSource = dtMerge; Atend.Global.Utility.UBinding.SetGridToCurrentSelectedEquip("SelfCode,SelfXCode", new object[2] { selectedProductCode, "00000000-0000-0000-0000-000000000000" }, dtMerge, gvSelfKeeper, this); ChangeColor(); for (int i = 0; i < gvSelfKeeper.Rows.Count; i++) { if (Convert.ToInt32(gvSelfKeeper.Rows[i].Cells[0].Value.ToString()) == selectedProductCode /*SelfTip.Code*/) { gvSelfKeeper.Rows[i].DefaultCellStyle.BackColor = Color.Yellow; } } BindMaterialToComboBox(); if (cboMaterial.Items.Count > 0) { cboMaterial.SelectedIndex = 0; } BindDataToComboBoxIsExist(); if (cboMaterial.Items.Count > 0) { cboMaterial.SelectedIndex = 0; } //BindDataToProjectCode(); if (cboProject.Items.Count > 0) { cboProject.SelectedIndex = 0; } txtLenght.Text = Math.Round(Branch.Lenght, 2).ToString(); Length = Convert.ToDouble(Math.Round(Branch.Lenght, 2).ToString()); cboIsExist.SelectedValue = Atend.Base.Base.BEquipStatus.SelectByACode(Branch.IsExist).Code; cboProject.SelectedValue = Branch.ProjectCode; }
public frmShortCircuitResult(DataTable dtNodes, DataTable dtBranch, double FalutDuration) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage("\nchecking.....\n"); if (!Atend.Global.Acad.DrawEquips.Dicision.IsHere()) { if (!Atend.Global.Acad.DrawEquips.Dicision.IsThere()) { //System.Diagnostics.Process[] prs = System.Diagnostics.Process.GetProcesses(); //foreach (System.Diagnostics.Process pr in prs) //{ // if (pr.ProcessName == "acad") // { // pr.CloseMainWindow(); // } //} Atend.Global.Acad.Notification notification = new Atend.Global.Acad.Notification(); notification.Title = "شناسایی قفل"; notification.Msg = "لطفا وضعیت قفل را بررسی نمایید "; notification.infoCenterBalloon(); ForceToClose = true; } } InitializeComponent(); _FaultDuration = FalutDuration; dtResultNode.Columns.Add(dcLoadPowerImage); dtResultNode.Columns.Add(dcLoadPowerReal); dtResultNode.Columns.Add(dcVoltAbs); dtResultNode.Columns.Add(dcVoltAng); dtResultNode.Columns.Add(dcVoltDropPer); dtResultNode.Columns.Add(dcLoadCurrentAbs); dtResultNode.Columns.Add(dcLoadCurrentArg); dtResultNode.Columns.Add(dcConsolGuid); dtResultBranch.Columns.Add(dcCode); dtResultBranch.Columns.Add(dcCondUtilization); dtResultBranch.Columns.Add(dcLenght); dtResultBranch.Columns.Add(dcCurrentAbs); dtResultBranch.Columns.Add(dcCurrentAng); dtResultBranch.Columns.Add(dcTotalLoadREal); dtResultBranch.Columns.Add(dcSCCurrent); dtResultBranch.Columns.Add(CondMax1sCurrent); dtResultBranch.Columns.Add(dcFrom); dtResultBranch.Columns.Add(dcTo); dtResultBranch.Columns.Add(dcCondName); dtResultBranch.Columns.Add(dcVolt); ed.WriteMessage("Print Nodes\n"); foreach (DataRow dr in dtNodes.Rows) { DataRow drNew = dtResultNode.NewRow(); if (new Guid(dr["ConsoleGuid"].ToString()) != Guid.Empty) { Atend.Base.Design.DPackage dPack = Atend.Base.Design.DPackage.AccessSelectByCode(new Guid(dr["ConsoleGuid"].ToString())); drNew["ConsolGuid"] = dPack.Number; drNew["VoltAbs"] = Math.Round(((Complex)dr["Voltage"]).abs, 3); double voltArg = ConvertToDegree(((Complex)dr["Voltage"]).arg); //drNew["VoltArg"] = Math.Round(((Complex)dr["Voltage"]).arg, 2); drNew["VoltArg"] = Math.Round(voltArg, 2); drNew["VoltDropPer"] = Math.Round(Convert.ToDouble(dr["VoltageDropPer"].ToString())); drNew["LoadPowerReal"] = Math.Round(((Complex)dr["LoadPower"]).real, 3); drNew["LoadPowerImg"] = Math.Round(((Complex)dr["LoadPower"]).imag, 3); drNew["LoadCurrentAbs"] = Math.Round(((Complex)dr["LoadCurrent"]).abs, 3);//.ToString(); double loadcurrentArg = ConvertToDegree(((Complex)dr["LoadCurrent"]).arg); //drNew["LoadCurrentArg"] = Math.Round(((Complex)dr["LoadCurrent"]).arg, 3);//.ToString(); drNew["LoadCurrentArg"] = loadcurrentArg; dtResultNode.Rows.Add(drNew); } } ed.WriteMessage("Print Branch\n"); Atend.Base.Calculating.CShortCircuit.AccessDelete(); foreach (DataRow dr in dtBranch.Rows) { Atend.Base.Calculating.CShortCircuit shortCircuit = new Atend.Base.Calculating.CShortCircuit(); if (new Guid(dr["Code"].ToString()) != Guid.Empty) { DataRow drNew = dtResultBranch.NewRow(); Atend.Base.Design.DBranch branch = Atend.Base.Design.DBranch.AccessSelectByCode(new Guid(dr["Code"].ToString())); //drNew["Code"] = branch.Number; if ((branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Conductor)) || (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Jumper)) || (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Terminal))) { Atend.Base.Equipment.EConductorTip ConductorTip = Atend.Base.Equipment.EConductorTip.AccessSelectByCode(branch.ProductCode); Atend.Base.Equipment.EConductor Conductor = Atend.Base.Equipment.EConductor.AccessSelectByCode(ConductorTip.PhaseProductCode); drNew["CondName"] = Conductor.Name; double IbMax = Convert.ToDouble(Conductor.MaxCurrent1Second) / Math.Sqrt(_FaultDuration); drNew["CondMax1sCurrent"] = Math.Round(IbMax, 1); shortCircuit.CondName = Conductor.Name; shortCircuit.CondMax1SCurrent = Math.Round(IbMax, 1); } if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.SelfKeeper)) { Atend.Base.Equipment.ESelfKeeperTip SelfKeeperTip = Atend.Base.Equipment.ESelfKeeperTip.AccessSelectByCode(branch.ProductCode); Atend.Base.Equipment.ESelfKeeper SelfKeeper = Atend.Base.Equipment.ESelfKeeper.AccessSelectByCode(SelfKeeperTip.PhaseProductCode); drNew["CondName"] = SelfKeeper.Name; double IbMax = Convert.ToDouble(SelfKeeper.MaxCurrent1Second) / Math.Sqrt(_FaultDuration); drNew["CondMax1sCurrent"] = Math.Round(IbMax, 1); shortCircuit.CondName = SelfKeeper.Name; shortCircuit.CondMax1SCurrent = Math.Round(IbMax, 1); } if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.GroundCabel)) { Atend.Base.Equipment.EGroundCabelTip GroundTip = Atend.Base.Equipment.EGroundCabelTip.AccessSelectByCode(branch.ProductCode); Atend.Base.Equipment.EGroundCabel Ground = Atend.Base.Equipment.EGroundCabel.AccessSelectByCode(GroundTip.PhaseProductCode); drNew["CondName"] = Ground.Name; double IbMax = Convert.ToDouble(Ground.MaxCurrent1Second) / Math.Sqrt(_FaultDuration); drNew["CondMax1sCurrent"] = Math.Round(IbMax, 1); shortCircuit.CondName = Ground.Name; shortCircuit.CondMax1SCurrent = Math.Round(IbMax, 1); } drNew["Lenght"] = dr["Length"].ToString(); drNew["CondUtilization"] = Math.Round(Convert.ToDouble(dr["CondUtilization"].ToString()), 3); drNew["CurrentAbs"] = Math.Round(((Complex)dr["Current"]).abs, 3);//.ToString(); double currentArg = ConvertToDegree(((Complex)dr["Current"]).arg); //drNew["CurrentArg"] = Math.Round(((Complex)dr["Current"]).arg, 3);//.ToString(); drNew["CurrentArg"] = Math.Round(currentArg, 3); drNew["TotalLoadReal"] = Math.Round(((Complex)dr["TotalLoad"]).arg, 3); drNew["SCCurrent"] = Math.Round(Convert.ToDouble(dr["SCCurrent"].ToString()), 0); ed.WriteMessage("CondCode={0}\n", dr["CondCode"].ToString()); shortCircuit.Lenght = Convert.ToDouble(dr["Length"].ToString()); shortCircuit.Condutilization = Math.Round(Convert.ToDouble(dr["CondUtilization"].ToString()), 3); shortCircuit.CurrentAbs = Math.Round(((Complex)dr["Current"]).abs, 3); //.ToString(); shortCircuit.CurrentArg = Math.Round(currentArg, 3); //.ToString(); shortCircuit.TotalLoad = Math.Round(((Complex)dr["TotalLoad"]).arg, 3); shortCircuit.ScCurrent = Math.Round(Convert.ToDouble(dr["SCCurrent"].ToString()), 0); ed.WriteMessage("Current={0}\n", shortCircuit.ScCurrent); //از DataRow[] drnodeFrom = dtNodes.Select(string.Format("ConsoleObjID={0}", dr["UpNodeId"].ToString())); if (drnodeFrom.Length > 0) { drNew["From"] = FindNodeComment(new Guid(drnodeFrom[0]["ConsoleGuid"].ToString())); shortCircuit.From = drNew["From"].ToString(); } //به DataRow[] drnodeTo = dtNodes.Select(string.Format("ConsoleObjID={0}", dr["DnNodeId"].ToString())); if (drnodeTo.Length > 0) { drNew["Volt"] = Math.Round(((Complex)(drnodeTo[0]["Voltage"])).abs, 2).ToString(); drNew["To"] = FindNodeComment(new Guid(drnodeTo[0]["ConsoleGuid"].ToString())); shortCircuit.To = drNew["To"].ToString(); shortCircuit.Volt = Math.Round(((Complex)(drnodeTo[0]["Voltage"])).abs, 2); } //if (new Guid(dr["Code"].ToString()) != Guid.Empty) //{ ////Atend.Base.Equipment.EConductorTip condTip = Atend.Base.Equipment.EConductorTip.AccessSelectByCode(Convert.ToInt32(dr["CondCode"].ToString())); ////Atend.Base.Equipment.EConductor conductor = Atend.Base.Equipment.EConductor.AccessSelectByCode(condTip.PhaseProductCode); ////ed.WriteMessage("conductor.MaxCurrent1Second={0},SCCurrent={1}\n", conductor.MaxCurrent1Second, dr["SCCurrent"].ToString()); ////ed.WriteMessage("#######\n"); //ed.WriteMessage("&&&&&&={0}\n", dr["CondMax1sCurrent"].ToString()); //} //else //{ // drNew["CondMax1sCurrent"] = dr["CondUtilizationSC"].ToString(); //} dtResultBranch.Rows.Add(drNew); if (!shortCircuit.AccessInsert()) { ed.WriteMessage("Insert Failed\n"); } } } ////foreach (DataRow dr in dtResultBranch.Rows) ////{ //// ed.WriteMessage("dtResultBranch.CondMax1sCurrent={0}\n", dr["CondMax1sCurrent"].ToString()); ////} //string code1 = "00000000-0000-0000-0000-000000000000"; //DataRow[] drs = dtResultBranch.Select(" Code = '"+code1+"'"); //drs[0].Delete(); //DataRow[] drs1 = dtResultNode.Select(" ConsolGuid = '" + code1 + "'"); //drs1[0].Delete(); ed.WriteMessage("BindDAtA\n"); gvBranch.AutoGenerateColumns = false; gvBranch.DataSource = dtResultBranch; //gvNode.AutoGenerateColumns = false; //gvNode.DataSource = dtResultNode; CheckCurrent(); }
private bool Validation() { //if (string.IsNullOrEmpty(cboProjCode.Text)) //{ // MessageBox.Show("لطفاً کد دستور کار را انتخاب کنید", "خطا"); // return false; //} if (string.IsNullOrEmpty(txtLenght.Text)) { MessageBox.Show("لطفا مقدار طول را وارد نمایید", "خطا"); txtLenght.Focus(); return(false); } if (!Atend.Control.NumericValidation.DoubleConverter(txtLenght.Text)) { MessageBox.Show("لطفا طول رابا فرمت مناسب وارد نمایید", "خطا"); txtLenght.Focus(); return(false); } //if (txtEquip1.Text == "") //{ // MessageBox.Show("لطفاً تجهیز مورد نظر را انتخاب نمایید", "خطا"); // txtEquip1.Focus(); // return false; //} //if (txtEquip2.Text == "") //{ // MessageBox.Show("لطفاً تجهیز مورد نظر را انتخاب نمایید", "خطا"); // txtEquip2.Focus(); // return false; //} //if (txtSag.Text == "" ) //{ // MessageBox.Show("لطفا اندازه فلش را مشخص نمایید","خطا"); // txtSag.Focus(); // return false; //} //if (txtMaterial.Text == "") //{ // MessageBox.Show("لطفا سیم مورد نظر را انتخاب نمایید","خطا"); // tabControl1.TabPages[0].Focus(); // return false; //} Atend.Base.Design.DBranch Branch = Atend.Base.Design.DBranch.AccessSelectByCode(NodeCode); Atend.Base.Design.DBranch _DBranch = Atend.Base.Design.DBranch.AccessSelectByRigthAndLeftNodeCode(Branch.RightNodeCode, Branch.LeftNodeCode); if (_DBranch.Code != Guid.Empty) { if (Convert.ToDouble(txtLenght.Text) != _DBranch.Lenght) { if (MessageBox.Show(" تغیر در طول سیم باعث تغییر در طول سایر سیمهای بین این دو پایه میشود . آیا مایل به تغیر طول سیم هستید ؟ ", "خطا", MessageBoxButtons.YesNo) == DialogResult.No) { txtLenght.Text = Length.ToString(); return(false); } else { return(true); } } } else { _DBranch = Atend.Base.Design.DBranch.AccessSelectByRigthAndLeftNodeCode(Branch.LeftNodeCode, Branch.RightNodeCode); if (_DBranch.Code != Guid.Empty) { if (Convert.ToDouble(txtLenght.Text) != _DBranch.Lenght) { if (MessageBox.Show(" تغیر در طول سیم باعث تغییر در طول سایر سیمهای بین این دو پایه میشود . آیا مایل به تغیر طول سیم هستید ؟ ", "خطا", MessageBoxButtons.YesNo) == DialogResult.No) { txtLenght.Text = Length.ToString(); return(false); } else { return(true); } } } } return(true); }
public AcDrawJumper() { JumperBtranch = new Atend.Base.Design.DBranch(); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~// ///// <summary> ///// Save all data before start AutoPoleInstallation ///// </summary> ///// <returns></returns> //private bool PrepareData() //{ // Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; // OleDbConnection aConnection = new OleDbConnection(Atend.Control.ConnectionString.AccessCnString); // OleDbTransaction aTransaction; // try // { // aConnection.Open(); // aTransaction = aConnection.BeginTransaction(); // try // { // if (!selectedPole.AccessInsert(aTransaction, aConnection, true, true)) // { // throw new System.Exception("selectedPole.AccessInsert"); // } // if (SelectedBranch.ProductType == (int)Atend.Control.Enum.ProductType.Conductor) // { // if (!SelectedConsol.AccessInsert(aTransaction, aConnection, true, true)) // { // throw new System.Exception("SelectedConsol.AccessInsert"); // } // if (!SelectedConsolTension.AccessInsert(aTransaction, aConnection, true, true)) // { // throw new System.Exception("SelectedConsolTension.AccessInsert"); // } // } // else if (SelectedBranch.ProductType == (int)Atend.Control.Enum.ProductType.SelfKeeper) // { // if (!SelectedClamp.AccessInsert(aTransaction, aConnection, true, true)) // { // throw new System.Exception("SelectedClamp.AccessInsert"); // } // if (!SelectedClampTension.AccessInsert(aTransaction, aConnection, true, true)) // { // throw new System.Exception("SelectedClampTension.AccessInsert"); // } // } // } // catch (System.Exception ex2) // { // ed.WriteMessage("ERROR PrepareData: {0} \n", ex2.Message); // aTransaction.Rollback(); // aConnection.Close(); // return false; // } // } // catch (System.Exception ex1) // { // ed.WriteMessage("ERROR PrepareData: {0} \n", ex1.Message); // aConnection.Close(); // return false; // } // aTransaction.Commit(); // aConnection.Close(); // return true; //} public bool PoleInstallationWithoutForbiddenArea(Guid SelectedPoleDpackageCode) { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; bool Answer = true; List <ObjectIdCollection> _AllConsols = new List <ObjectIdCollection>(); ObjectIdCollection _AllClamps = new ObjectIdCollection(); double _SectionLength = 0; double _SpanLength = 0; int _SectionCount = SectionCalculation(out _SectionLength); int _SpanCount = SpanCalculation(_SectionLength, out _SpanLength); Atend.Base.Acad.AT_INFO CurrentBranchInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(BranchEntity.ObjectId); ObjectIdCollection t = new ObjectIdCollection(); try { Atend.Global.Acad.DrawEquips.AcDrawPole _AcDrawPole = null; Atend.Global.Acad.DrawEquips.AcDrawCirclePole _AcDrawCirclePole = null; Atend.Global.Acad.DrawEquips.AcDrawPolygonPole _AcDrawPolygonPole = null; if (_SpanLength != -1) { CalculateSectionPoints(branchEntity.StartPoint, branchEntity.EndPoint, _SectionCount); Atend.Base.Design.DPackage PolePack = Atend.Base.Design.DPackage.AccessSelectByNodeCode(SelectedPoleDpackageCode); //Start Pole consols or clamp if (SelectedBranch.ProductType == (int)Atend.Control.Enum.ProductType.Conductor) { t.Add(GetStartConsolOrClamp()); _AllConsols.Add(t); } else { _AllClamps.Add(GetStartConsolOrClamp()); } for (int SectionCounter = 0; SectionCounter < _SectionCount; SectionCounter++) { SpanPoints.Clear(); CalculateSpanPoints(SectionPoints[SectionCounter], SectionPoints[SectionCounter + 1], _SpanCount); for (int SpanCounter = 1; SpanCounter < _SpanCount; SpanCounter++) { Atend.Base.Design.DPoleInfo PoleInfo = new Atend.Base.Design.DPoleInfo(); PoleInfo.HalterCount = 0; PoleInfo.HalterType = 0; PoleInfo.Factor = 0; if (SelectedBranch.ProductType == (int)Atend.Control.Enum.ProductType.Conductor) { #region Counductor //ed.WriteMessage("~~~~~~~~{0}~~~~~~~~~~~~~~GO TO SHAPE~~~~~~~~~~~{1}~~~~~~~~~~~~~~\n", SelectedPole.Shape, SelectedPole.Type); if (SelectedPole.Shape == 0) { //ed.WriteMessage("~~~~~~~~~~~~~~~~~~~~~~TWO~~~~~~~~~~~~~~~~~~~~~~~~~\n"); _AcDrawCirclePole = new Atend.Global.Acad.DrawEquips.AcDrawCirclePole(); #region POLECircle _AcDrawCirclePole.UseAccess = true; _AcDrawCirclePole.ePole = SelectedPole; _AcDrawCirclePole.ProjectCode = PolePack.ProjectCode; _AcDrawCirclePole.Existance = Convert.ToByte(PolePack.IsExistance); _AcDrawCirclePole.dPoleInfo = PoleInfo; _AcDrawCirclePole.eConsols.Add(SelectedConsol); _AcDrawCirclePole.eConsolCount.Add(2); _AcDrawCirclePole.eConsolExistance.Add(Convert.ToByte(PolePack.IsExistance)); _AcDrawCirclePole.eConsolProjectCode.Add(PolePack.ProjectCode); _AcDrawCirclePole.eConsolUseAccess.Add(false); _AcDrawCirclePole.eHalterCount = 0; if (!_AcDrawCirclePole.DrawPoleCircle(SpanPoints[SpanCounter], GetStartPoleAngle() + 90, out t)) { throw new System.Exception("failor while drawing pole"); } _AllConsols.Add(t); #endregion } else if (SelectedPole.Shape == 1) { if (SelectedPole.Type == 2)//pertic { //ed.WriteMessage("~~~~~~~~~~~~~~~~~~~~~~THREE~~~~~~~~~~~~~~~~~~~~~~~~~\n"); _AcDrawPolygonPole = new Atend.Global.Acad.DrawEquips.AcDrawPolygonPole(); #region PolePolygon _AcDrawPolygonPole.UseAccess = true; _AcDrawPolygonPole.ePole = SelectedPole; _AcDrawPolygonPole.ProjectCode = PolePack.ProjectCode; _AcDrawPolygonPole.Existance = Convert.ToByte(PolePack.IsExistance); _AcDrawPolygonPole.dPoleInfo = PoleInfo; _AcDrawPolygonPole.eConsols.Add(SelectedConsol); _AcDrawPolygonPole.eConsolCount.Add(2); _AcDrawPolygonPole.eConsolExistance.Add(Convert.ToByte(PolePack.IsExistance)); _AcDrawPolygonPole.eConsolProjectCode.Add(PolePack.ProjectCode); _AcDrawPolygonPole.eConsolUseAccess.Add(false); _AcDrawPolygonPole.eHalterCount = 0; if (!_AcDrawPolygonPole.DrawPolePolygon(SpanPoints[SpanCounter], GetStartPoleAngle() + 90, out t)) { throw new System.Exception("failor while drawing pole"); } _AllConsols.Add(t); #endregion } else { //ed.WriteMessage("~~~~~~~~~~~~~~~~~~~~~~ONE~~~~~~~~~~~~~~~~~~~~~~~~~\n"); _AcDrawPole = new Atend.Global.Acad.DrawEquips.AcDrawPole(); #region Pole _AcDrawPole.UseAccess = true; _AcDrawPole.ePole = SelectedPole; _AcDrawPole.ProjectCode = PolePack.ProjectCode; _AcDrawPole.Existance = Convert.ToByte(PolePack.IsExistance); _AcDrawPole.dPoleInfo = PoleInfo; _AcDrawPole.eConsols.Add(SelectedConsol); _AcDrawPole.eConsolCount.Add(2); _AcDrawPole.eConsolExistance.Add(Convert.ToByte(PolePack.IsExistance)); _AcDrawPole.eConsolProjectCode.Add(PolePack.ProjectCode); _AcDrawPole.eConsolUseAccess.Add(false); _AcDrawPole.eHalterCount = 0; if (!_AcDrawPole.DrawPole(SpanPoints[SpanCounter], GetStartPoleAngle() + 90, out t)) { throw new System.Exception("failor while drawing pole"); } _AllConsols.Add(t); #endregion } } #endregion }//end of if (SelectedBranch.ProductType == (int)Atend.Control.Enum.ProductType.Conductor) else if (SelectedBranch.ProductType == (int)Atend.Control.Enum.ProductType.SelfKeeper) { #region Selfkeeper if (SelectedPole.Shape == 0) { //ed.WriteMessage("~~~~~~~~~~~~~~~~~~~~~~TWO~~~~~~~~~~~~~~~~~~~~~~~~~\n"); _AcDrawCirclePole = new Atend.Global.Acad.DrawEquips.AcDrawCirclePole(); #region POLECircle _AcDrawCirclePole.UseAccess = true; _AcDrawCirclePole.ePole = SelectedPole; _AcDrawCirclePole.ProjectCode = PolePack.ProjectCode; _AcDrawCirclePole.Existance = Convert.ToByte(PolePack.IsExistance); _AcDrawCirclePole.dPoleInfo = PoleInfo; _AcDrawCirclePole.eConsols = new List <Atend.Base.Equipment.EConsol>(); _AcDrawCirclePole.eConsolCount = new ArrayList(); _AcDrawCirclePole.eConsolExistance = new ArrayList(); _AcDrawCirclePole.eConsolProjectCode = new ArrayList(); _AcDrawCirclePole.eConsolUseAccess = new ArrayList(); _AcDrawCirclePole.eHalterCount = 0; if (!_AcDrawCirclePole.DrawPoleCircle(SpanPoints[SpanCounter], GetStartPoleAngle() + 90, out t)) { throw new System.Exception("failor while drawing pole"); } //_AllClamps.Add(t[0]); #endregion } else if (SelectedPole.Shape == 1) { if (SelectedPole.Type == 2)//pertic { //ed.WriteMessage("~~~~~~~~~~~~~~~~~~~~~~THREE~~~~~~~~~~~~~~~~~~~~~~~~~\n"); _AcDrawPolygonPole = new Atend.Global.Acad.DrawEquips.AcDrawPolygonPole(); #region PolePolygon _AcDrawPolygonPole.UseAccess = true; _AcDrawPolygonPole.ePole = SelectedPole; _AcDrawPolygonPole.ProjectCode = PolePack.ProjectCode; _AcDrawPolygonPole.Existance = Convert.ToByte(PolePack.IsExistance); _AcDrawPolygonPole.dPoleInfo = PoleInfo; _AcDrawPolygonPole.eConsols = new List <Atend.Base.Equipment.EConsol>(); _AcDrawPolygonPole.eConsolCount = new ArrayList(); _AcDrawPolygonPole.eConsolExistance = new ArrayList(); _AcDrawPolygonPole.eConsolProjectCode = new ArrayList(); _AcDrawPolygonPole.eConsolUseAccess = new ArrayList(); _AcDrawPolygonPole.eHalterCount = 0; if (!_AcDrawPolygonPole.DrawPolePolygon(SpanPoints[SpanCounter], GetStartPoleAngle() + 90, out t)) { throw new System.Exception("failor while drawing pole"); } //_AllClamps.Add(t[0]); #endregion } else { //ed.WriteMessage("~~~~~~~~~~~~~~~~~~~~~~ONE~~~~~~~~~~~~~~~~~~~~~~~~~\n"); _AcDrawPole = new Atend.Global.Acad.DrawEquips.AcDrawPole(); #region Pole _AcDrawPole.UseAccess = true; _AcDrawPole.ePole = SelectedPole; _AcDrawPole.ProjectCode = PolePack.ProjectCode; _AcDrawPole.Existance = Convert.ToByte(PolePack.IsExistance); _AcDrawPole.dPoleInfo = PoleInfo; _AcDrawPole.eConsols = new List <Atend.Base.Equipment.EConsol>(); _AcDrawPole.eConsolCount = new ArrayList(); _AcDrawPole.eConsolExistance = new ArrayList(); _AcDrawPole.eConsolProjectCode = new ArrayList(); _AcDrawPole.eConsolUseAccess = new ArrayList(); _AcDrawPole.eHalterCount = 0; if (!_AcDrawPole.DrawPole(SpanPoints[SpanCounter], GetStartPoleAngle() + 90, out t)) { throw new System.Exception("failor while drawing pole"); } //_AllClamps.Add(t[0]); #endregion } } #endregion Atend.Global.Acad.DrawEquips.AcDrawKalamp _AcDrawKalamp = new Atend.Global.Acad.DrawEquips.AcDrawKalamp(); _AcDrawKalamp.eClamp = SelectedClamp; _AcDrawKalamp.Existance = PolePack.IsExistance; _AcDrawKalamp.ProjectCode = PolePack.ProjectCode; _AcDrawKalamp.UseAccess = false; _AllClamps.Add(_AcDrawKalamp.DrawKalamp(Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(t[0])), t[0])); } //end of else if (SelectedBranch.ProductType == (int)Atend.Control.Enum.ProductType.SelfKeeper) } //end of span if (SectionCounter + 1 != _SectionCount) { //ed.WriteMessage("~~~~~~~~~~~~<<<SECTION>>>~~~~~~~~~~~~~\n"); if (_AcDrawPole != null) { //ed.WriteMessage("~~~~~~~~~~~~~~~~~~~~~~ONE~~~~~~~~~~~~~~~~~~~~~~~~~\n"); if (CurrentBranchInfo.NodeType != (int)Atend.Control.Enum.ProductType.SelfKeeper) { _AcDrawPole.eConsols = new List <Atend.Base.Equipment.EConsol>(); _AcDrawPole.eConsols.Add(SelectedConsolTension); _AcDrawPole.eConsols.Add(SelectedConsolTension); _AcDrawPole.eConsolCount = new ArrayList(); _AcDrawPole.eConsolCount.Add(2); _AcDrawPole.eConsolCount.Add(2); _AcDrawPole.eConsolExistance = new ArrayList(); _AcDrawPole.eConsolExistance.Add(Convert.ToByte(PolePack.IsExistance)); _AcDrawPole.eConsolExistance.Add(Convert.ToByte(PolePack.IsExistance)); _AcDrawPole.eConsolProjectCode = new ArrayList(); _AcDrawPole.eConsolProjectCode.Add(PolePack.ProjectCode); _AcDrawPole.eConsolProjectCode.Add(PolePack.ProjectCode); _AcDrawPole.eConsolUseAccess = new ArrayList(); _AcDrawPole.eConsolUseAccess.Add(false); _AcDrawPole.eConsolUseAccess.Add(false); } else { _AcDrawPole.eConsols = new List <Atend.Base.Equipment.EConsol>(); _AcDrawPole.eConsolCount = new ArrayList(); _AcDrawPole.eConsolExistance = new ArrayList(); _AcDrawPole.eConsolProjectCode = new ArrayList(); _AcDrawPole.eConsolUseAccess = new ArrayList(); } _AcDrawPole.eHalterCount = 0; if (!_AcDrawPole.DrawPole(SectionPoints[SectionCounter + 1], GetStartPoleAngle(), out t)) { throw new System.Exception("failor while drawing pole"); } } else if (_AcDrawCirclePole != null) { //ed.WriteMessage("~~~~~~~~~~~~~~~~~~~~~~TWO~~~~~~~~~~~~~~~~~~~~~~~~~\n"); if (CurrentBranchInfo.NodeType != (int)Atend.Control.Enum.ProductType.SelfKeeper) { _AcDrawCirclePole.eConsols = new List <Atend.Base.Equipment.EConsol>(); _AcDrawCirclePole.eConsols.Add(SelectedConsolTension); _AcDrawCirclePole.eConsols.Add(SelectedConsolTension); _AcDrawCirclePole.eConsolCount = new ArrayList(); _AcDrawCirclePole.eConsolCount.Add(2); _AcDrawCirclePole.eConsolCount.Add(2); _AcDrawCirclePole.eConsolExistance = new ArrayList(); _AcDrawCirclePole.eConsolExistance.Add(Convert.ToByte(PolePack.IsExistance)); _AcDrawCirclePole.eConsolExistance.Add(Convert.ToByte(PolePack.IsExistance)); _AcDrawCirclePole.eConsolProjectCode = new ArrayList(); _AcDrawCirclePole.eConsolProjectCode.Add(PolePack.ProjectCode); _AcDrawCirclePole.eConsolProjectCode.Add(PolePack.ProjectCode); _AcDrawCirclePole.eConsolUseAccess = new ArrayList(); _AcDrawCirclePole.eConsolUseAccess.Add(false); _AcDrawCirclePole.eConsolUseAccess.Add(false); } else { _AcDrawCirclePole.eConsols = new List <Atend.Base.Equipment.EConsol>(); _AcDrawCirclePole.eConsolCount = new ArrayList(); _AcDrawCirclePole.eConsolExistance = new ArrayList(); _AcDrawCirclePole.eConsolProjectCode = new ArrayList(); _AcDrawCirclePole.eConsolUseAccess = new ArrayList(); } _AcDrawCirclePole.eHalterCount = 0; if (!_AcDrawCirclePole.DrawPoleCircle(SectionPoints[SectionCounter + 1], GetStartPoleAngle(), out t)) { throw new System.Exception("failor while drawing pole"); } } else if (_AcDrawPolygonPole != null) { //ed.WriteMessage("~~~~~~~~~~~~~~~~~~~~~~THREE~~~~~~~~~~~~~~~~~~~~~~~~~\n"); if (CurrentBranchInfo.NodeType != (int)Atend.Control.Enum.ProductType.SelfKeeper) { _AcDrawPolygonPole.eConsols = new List <Atend.Base.Equipment.EConsol>(); _AcDrawPolygonPole.eConsols.Add(SelectedConsolTension); _AcDrawPolygonPole.eConsols.Add(SelectedConsolTension); _AcDrawPolygonPole.eConsolCount = new ArrayList(); _AcDrawPolygonPole.eConsolCount.Add(2); _AcDrawPolygonPole.eConsolCount.Add(2); _AcDrawPolygonPole.eConsolExistance = new ArrayList(); _AcDrawPolygonPole.eConsolExistance.Add(Convert.ToByte(PolePack.IsExistance)); _AcDrawPolygonPole.eConsolExistance.Add(Convert.ToByte(PolePack.IsExistance)); _AcDrawPolygonPole.eConsolProjectCode = new ArrayList(); _AcDrawPolygonPole.eConsolProjectCode.Add(PolePack.ProjectCode); _AcDrawPolygonPole.eConsolProjectCode.Add(PolePack.ProjectCode); _AcDrawPolygonPole.eConsolUseAccess = new ArrayList(); _AcDrawPolygonPole.eConsolUseAccess.Add(false); _AcDrawPolygonPole.eConsolUseAccess.Add(false); } else { _AcDrawPolygonPole.eConsols = new List <Atend.Base.Equipment.EConsol>(); _AcDrawPolygonPole.eConsolCount = new ArrayList(); _AcDrawPolygonPole.eConsolExistance = new ArrayList(); _AcDrawPolygonPole.eConsolProjectCode = new ArrayList(); _AcDrawPolygonPole.eConsolUseAccess = new ArrayList(); } ////ed.WriteMessage("### BBB ### \n"); _AcDrawPolygonPole.eHalterCount = 0; if (!_AcDrawPolygonPole.DrawPolePolygon(SectionPoints[SectionCounter + 1], GetStartPoleAngle(), out t)) { throw new System.Exception("failor while drawing pole"); } //ed.WriteMessage("### GGG ### \n"); } if (CurrentBranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.Conductor) { _AllConsols.Add(t); } else if (CurrentBranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.SelfKeeper) { Atend.Global.Acad.DrawEquips.AcDrawKalamp _AcDrawKalamp = new Atend.Global.Acad.DrawEquips.AcDrawKalamp(); _AcDrawKalamp.eClamp = SelectedClampTension; _AcDrawKalamp.Existance = PolePack.IsExistance; _AcDrawKalamp.ProjectCode = PolePack.ProjectCode; _AcDrawKalamp.UseAccess = false; _AllClamps.Add(_AcDrawKalamp.DrawKalamp(Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(t[0])), t[0])); } _AcDrawCirclePole = null; _AcDrawPole = null; _AcDrawPolygonPole = null; // ed.WriteMessage("~~~~~~~~~~~~<<<NOT SECTION>>>~~~~~~~~~~~~~\n"); }//change section } //End Pole consols if (CurrentBranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.Conductor) { t = new ObjectIdCollection(); t.Add(GetEndConsolOrClamp()); _AllConsols.Add(t); } else if (CurrentBranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.SelfKeeper) { //_AllClamps.Add(t[0]); _AllClamps.Add(GetEndConsolOrClamp()); } #region Do Branch Operation Here if (CurrentBranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.Conductor) { #region Conductor Operation //delete conductor if (Atend.Global.Acad.DrawEquips.AcDrawConductor.DeleteConductorData(branchEntity.ObjectId)) { Atend.Global.Acad.DrawEquips.AcDrawConductor.DeleteConductor(branchEntity.ObjectId); } //ed.WriteMessage("~~~~~~ start sim keshi ~~~~~~~~~\n"); ObjectId LastConsol = ObjectId.Null, StartConsol = ObjectId.Null; for (int ii = 0; ii < _AllConsols.Count - 1; ii++) { //ed.WriteMessage("~~~~~~~~~~~~~~~~~~~~~~~~\n"); ObjectIdCollection o1 = _AllConsols[ii]; //foreach (ObjectId oii in o1) //{ // ed.WriteMessage("oi:{0}\n", oii); //} if (o1.Count == 1) { StartConsol = o1[0]; } else { if (o1[1] == LastConsol) { StartConsol = o1[0]; } else { StartConsol = o1[1]; } } ObjectIdCollection o2 = _AllConsols[ii + 1]; LastConsol = o2[0]; //ed.WriteMessage("Start:{0} , End:{1} \n", StartConsol, LastConsol); Atend.Global.Acad.DrawEquips.AcDrawConductor _AcDrawConductor = new Atend.Global.Acad.DrawEquips.AcDrawConductor(); _AcDrawConductor.UseAccess = true; //ed.WriteMessage("111 \n"); _AcDrawConductor.eConductorTip = Atend.Base.Equipment.EConductorTip.AccessSelectByCode(CurrentBranchInfo.ProductCode); //ed.WriteMessage("112 \n"); ///////////_AcDrawConductor.eConductors.Add(Atend.Base.Equipment.EConductor.AccessSelectByCode(_AcDrawConductor.eConductorTip.NeutralProductCode)); //ed.WriteMessage("113 \n"); //////////_AcDrawConductor.eConductors.Add(Atend.Base.Equipment.EConductor.AccessSelectByCode(5)); //ed.WriteMessage("114 \n"); /////////_AcDrawConductor.eConductors.Add(Atend.Base.Equipment.EConductor.AccessSelectByCode(5)); //ed.WriteMessage("115 \n"); Atend.Base.Design.DBranch _DBranch = Atend.Base.Design.DBranch.AccessSelectByCode(new Guid(CurrentBranchInfo.NodeCode)); if (_DBranch.Code != Guid.Empty) { _AcDrawConductor.Existance = _DBranch.IsExist; //ed.WriteMessage("116 \n"); _AcDrawConductor.ProjectCode = _DBranch.ProjectCode; //ed.WriteMessage("i will go to draw sim \n"); } else { _AcDrawConductor.Existance = 0; //ed.WriteMessage("116 \n"); _AcDrawConductor.ProjectCode = 0; //ed.WriteMessage("i will go to draw sim \n"); } _AcDrawConductor.DrawConductor(Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(StartConsol)), Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(LastConsol)), StartConsol, LastConsol, _SpanLength); //ed.WriteMessage("Start:{0} , End:{1} \n", StartConsol, LastConsol); } //ed.WriteMessage("~~~~~~ end sim keshi ~~~~~~~~~\n"); #endregion } else if (CurrentBranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.SelfKeeper) { #region SelfKeeper Operation if (Atend.Global.Acad.DrawEquips.AcDrawSelfKeeper.DeleteSelfKeeperData(branchEntity.ObjectId)) { //ed.WriteMessage("delete data io{0}\n", branchEntity.ObjectId); if (Atend.Global.Acad.DrawEquips.AcDrawSelfKeeper.DeleteSelfKeeper(branchEntity.ObjectId, true)) { //ed.WriteMessage("delete graphic \n"); for (int ClampCounter = 0; ClampCounter < _AllClamps.Count - 1; ClampCounter++) { //ed.WriteMessage("draw self keeper \n"); //ed.WriteMessage("ANSWER={0} \n", oi); Atend.Global.Acad.DrawEquips.AcDrawSelfKeeper _AcDrawSelfKeeper = new Atend.Global.Acad.DrawEquips.AcDrawSelfKeeper(); _AcDrawSelfKeeper.UseAccess = true; _AcDrawSelfKeeper.eSelfKeeperTip = Atend.Base.Equipment.ESelfKeeperTip.AccessSelectByCode(SelectedBranch.ProductCode); _AcDrawSelfKeeper.Existance = SelectedBranch.IsExist; _AcDrawSelfKeeper.ProjectCode = SelectedBranch.ProjectCode; _AcDrawSelfKeeper.DrawSelfKeeper(Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(_AllClamps[ClampCounter])), Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(_AllClamps[ClampCounter + 1])), _AllClamps[ClampCounter], _AllClamps[ClampCounter + 1], _SpanLength); } } else { throw new System.Exception("while deleting self keeper"); } } else { throw new System.Exception("while deleting self keeper"); } #endregion } #endregion } else { ed.WriteMessage("طول اسپن قابل محاسبه نمی باشد" + "\n"); Answer = false; } } catch (System.Exception ex) { ed.WriteMessage("Error While Pole installation : {0} \n", ex.Message); Answer = false; } return(Answer); }
private void btnSelect_Click(object sender, EventArgs e) { this.Hide(); PromptEntityOptions peo = new PromptEntityOptions("\nSelect Entity:"); PromptEntityResult per = ed.GetEntity(peo); Atend.Base.Acad.AT_INFO atInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(per.ObjectId); //ed.WriteMessage("PoleGuid={0} ,ConsolGuid={1}\n", atInfo.ParentCode, atInfo.NodeCode); DataTable dtCondAndSelf = Atend.Global.Acad.UAcad.FillBranchList(); if ((atInfo.NodeType == Convert.ToInt32(Atend.Control.Enum.ProductType.Consol)) || (atInfo.NodeType == Convert.ToInt32(Atend.Control.Enum.ProductType.Kalamp)) || (atInfo.NodeType == Convert.ToInt32(Atend.Control.Enum.ProductType.HeaderCabel))) { CanDoCalculate = true; Nodeobj = Convert.ToInt32(per.ObjectId.ToString().Substring(1, per.ObjectId.ToString().Length - 2)); //ed.WriteMessage("NodeCode={0}\n",atInfo.NodeCode); Atend.Base.Design.DPackage dPAck = Atend.Base.Design.DPackage.AccessSelectByCode(new Guid(atInfo.NodeCode)); //ed.WriteMessage("dConsol.ProductCode={0}\n",dconsol.ProductCode); if (dPAck.Type == Convert.ToInt32(Atend.Control.Enum.ProductType.Consol)) { Atend.Base.Equipment.EConsol eConsol = Atend.Base.Equipment.EConsol.AccessSelectByCode(dPAck.ProductCode); //ed.WriteMessage("^^^^={0}\n",eConsol.Length); txtVolt.Text = eConsol.VoltageLevel.ToString(); txtVoltTev.Text = eConsol.VoltageLevel.ToString(); if (eConsol.VoltageLevel == 400) { txtMaxDropVolt.Text = "5"; txtMaxDropPower.Text = "3"; } else { txtMaxDropVolt.Text = "3"; txtMaxDropPower.Text = "3"; } } else if (dPAck.Type == Convert.ToInt32(Atend.Control.Enum.ProductType.Kalamp)) { //ed.WriteMessage("This Is Kalamp\n"); Atend.Base.Equipment.EClamp Clamp = Atend.Base.Equipment.EClamp.AccessSelectByCode(dPAck.ProductCode); txtVolt.Text = Clamp.VoltageLevel.ToString(); txtVoltTev.Text = Clamp.VoltageLevel.ToString(); if (Clamp.VoltageLevel == 400) { txtMaxDropVolt.Text = "5"; txtMaxDropPower.Text = "3"; } else { txtMaxDropVolt.Text = "3"; txtMaxDropPower.Text = "3"; } } else if (dPAck.Type == Convert.ToInt32(Atend.Control.Enum.ProductType.HeaderCabel)) { //ed.WriteMessage("This Is Kalamp\n"); Atend.Base.Equipment.EHeaderCabel HeaderCabel = Atend.Base.Equipment.EHeaderCabel.AccessSelectByCode(dPAck.ProductCode); txtVolt.Text = HeaderCabel.Voltage.ToString(); txtVoltTev.Text = HeaderCabel.Voltage.ToString(); if (HeaderCabel.Voltage == 400) { txtMaxDropVolt.Text = "5"; txtMaxDropPower.Text = "3"; } else { txtMaxDropVolt.Text = "3"; txtMaxDropPower.Text = "3"; } } //ed.WriteMessage("dtCondAndSelf.Rows.Count={0}\n",dtCondAndSelf.Rows.Count); DataRow[] drCond = dtCondAndSelf.Select(string.Format("Type={0}", (int)Atend.Control.Enum.ProductType.Conductor)); //System.Data.DataTable dtConductor = Atend.Global.Acad.UAcad.GetConsolConductors(new Guid(atInfo.ParentCode), new Guid(atInfo.NodeCode)); if (drCond.Length != 0) { Atend.Base.Design.DBranch branch = Atend.Base.Design.DBranch.AccessSelectByCode(new Guid(drCond[0]["BranchGuid"].ToString()));// SelectByCode(new Guid(dtConductor.Rows[0]["BranchGuid"].ToString())); //ed.WriteMessage("branch.productCode={0}\n",branch.ProductCode); Atend.Base.Equipment.EConductorTip condTip = Atend.Base.Equipment.EConductorTip.AccessSelectByCode(branch.ProductCode); cond = Atend.Base.Equipment.EConductor.AccessSelectByCode(condTip.PhaseProductCode); //ed.WriteMessage("Cond.TypeCode={0}\n",cond.TypeCode); cboMaterial.SelectedIndex = cond.TypeCode; //ed.WriteMessage("****\n"); } DataRow[] drSelf = dtCondAndSelf.Select(string.Format("Type={0}", (int)Atend.Control.Enum.ProductType.SelfKeeper)); if (drSelf.Length != 0) { //ed.WriteMessage("Self\n"); Atend.Base.Design.DBranch branchSelf = Atend.Base.Design.DBranch.AccessSelectByCode(new Guid(drSelf[0]["BranchGuid"].ToString())); Atend.Base.Equipment.ESelfKeeperTip SelfTip = Atend.Base.Equipment.ESelfKeeperTip.AccessSelectByCode(branchSelf.ProductCode); Atend.Base.Equipment.ESelfKeeper Self = Atend.Base.Equipment.ESelfKeeper.AccessSelectByCode(SelfTip.PhaseProductCode); CboMaterialCalamp.SelectedIndex = Self.MaterialConductorCode - 1; } txtX.Text = "0"; txtR.Text = "0"; txtLoadPercent.Text = "75"; //ed.WriteMessage("FinishSElect\n"); } else { MessageBox.Show("لطفت جهت شروع محاسبات یک گره را انتخاب کنید"); CanDoCalculate = false; } this.Show(); }
private void frmEditDrawGroundCable_Load(object sender, EventArgs e) { if (ForceToClose) { this.Close(); } BindDataToComboBoxIsExist(); BindMaterialToComboBox(); //BindDataTocboProjCode(); dtMerge = Atend.Base.Equipment.EGroundCabel.SelectAllAndMerge(); Atend.Base.Design.DBranch dBranch = Atend.Base.Design.DBranch.AccessSelectByCode(BranchCode); selectedProductCode = dBranch.ProductCode; System.Data.DataColumn dcTypeName = new System.Data.DataColumn("TypeName"); dtMerge.Columns.Add(dcTypeName); foreach (DataRow dr in dtMerge.Rows) { if (Convert.ToInt32(dr["Type"].ToString()) == 1) { dr["TypeName"] = "XLPE از جنس آلمینیوم با عایق خشک"; } if (Convert.ToInt32(dr["Type"].ToString()) == 2) { dr["TypeName"] = "XLPE از جنس مس با عایق خشک"; } if (Convert.ToInt32(dr["Type"].ToString()) == 3) { dr["TypeName"] = "PVC از جنس آلمینیوم با عایق خشک"; } if (Convert.ToInt32(dr["Type"].ToString()) == 4) { dr["TypeName"] = "از جنس مس با عایق خشک"; } } gvConductor.AutoGenerateColumns = false; gvConductor.DataSource = dtMerge; Atend.Global.Utility.UBinding.SetGridToCurrentSelectedEquip("CabelTipCode", new object[1] { selectedProductCode }, dtMerge, gvConductor, this); ChangeColor(); //BindDataToCounductorTip(); for (int i = 0; i < gvConductor.Rows.Count; i++) { if (Convert.ToInt32(gvConductor.Rows[i].Cells[1].Value.ToString()) == dBranch.ProductCode && Convert.ToBoolean(gvConductor.Rows[i].Cells[4].Value.ToString()) == false) { gvConductor.Rows[i].DefaultCellStyle.BackColor = Color.Yellow; } } cboIsExist.SelectedValue = Atend.Base.Base.BEquipStatus.SelectByACode(dBranch.IsExist).Code; cboProjCode.SelectedValue = dBranch.ProjectCode; txtLenght.Text = Math.Round(dBranch.Lenght, 2).ToString(); //Length = Convert.ToDouble(Math.Round(dBranch.Lenght, 2).ToString()); if (cboMaterial.Items.Count > 0) { cboMaterial.SelectedIndex = 0; } }