private void frmDesignSaveServer_Load(object sender, EventArgs e) { if (ForceToClose) { this.Close(); } Atend.Base.Design.DDesignProfile CurrentDesignProfile = Atend.Base.Design.DDesignProfile.AccessSelect(); if (CurrentDesignProfile.DesignId != -1) { txtDesignName.Text = Atend.Control.Common.DesignName; txtDesignFullAddress.Text = Atend.Control.Common.DesignFullAddress; txtTitle.Text = CurrentDesignProfile.DesignName; Atend.Control.Common.DesignId = CurrentDesignProfile.DesignId; DataTable dt = Atend.Base.Design.DDesign.SelectAll(); gvDesign1.AutoGenerateColumns = false; gvDesign1.DataSource = dt; Atend.Global.Utility.UBinding.SetGridToCurrentSelectedEquip("Id", new object[1] { CurrentDesignProfile.DesignId }, dt, gvDesign1, this); AssignImageToGrid(); } else { //MessageBox.Show("design id was -1"); } }
//dsSagAndTension ds = new dsSagAndTension(); //public void SetDataset(dsSagAndTension Data) //{ // ds = Data; //} private void frmRemarkReport_Load(object sender, EventArgs e) { Atend.Report.dsSagAndTension dsloadbranch = new Atend.Report.dsSagAndTension(); Atend.Base.Design.DRemark remark = Atend.Base.Design.DRemark.AccessSelectByCode(1); if (remark.Code != -1) { DataRow drRemark = dsloadbranch.Tables["Remark"].NewRow(); drRemark["Name"] = remark.Name.ToString(); //MessageBox.Show(drRemark["Name"].ToString()); dsloadbranch.Tables["Remark"].Rows.Add(drRemark); Atend.Base.Design.DDesignProfile designProfile = Atend.Base.Design.DDesignProfile.AccessSelect(); DataRow drDesign = dsloadbranch.Tables["Title"].NewRow(); drDesign["ProjectName"] = designProfile.DesignName; drDesign["Designer"] = designProfile.Designer; drDesign["Area"] = designProfile.Zone; drDesign["Credit"] = designProfile.Validate; System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar(); string _date = string.Format("{0}/{1}/{2}", p.GetYear(designProfile.DesignDate).ToString(), p.GetMonth(designProfile.DesignDate).ToString(), p.GetDayOfMonth(designProfile.DesignDate).ToString()); drDesign["Date"] = _date; dsloadbranch.Tables["Title"].Rows.Add(drDesign); crRemark02 Remark = new crRemark02(); Remark.SetDataSource(dsloadbranch); crViewerRemark.ReportSource = Remark; } else { ed.WriteMessage("در Remark مقداری وجود ندارد\n"); } }
public Atend.Report.dsSagAndTension FillRemark() { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Atend.Report.dsSagAndTension dsloadbranch = new Atend.Report.dsSagAndTension(); Atend.Base.Design.DRemark remark = Atend.Base.Design.DRemark.AccessSelectByCode(1); if (remark.Code != -1) { DataRow drRemark = dsloadbranch.Tables["Remark"].NewRow(); drRemark["File"] = (byte[])remark.File; dsloadbranch.Tables["Remark"].Rows.Add(drRemark); //crRemark Remark = new crRemark(); //Remark.SetDataSource(dsloadbranch); //crViewerRemark.ReportSource = Remark; } else { ed.WriteMessage("در Remark مقداری وجود ندارد\n"); } DataRow dr1 = dsloadbranch.Tables["Title"].NewRow(); Atend.Base.Design.DDesignProfile designProfile = Atend.Base.Design.DDesignProfile.AccessSelect(); if (designProfile.Id != 0) { Atend.Base.Base.BRegion b12 = Atend.Base.Base.BRegion.SelectByCode(designProfile.Zone); dr1["Area"] = b12.SecondCode; System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar(); string _date = ChangeToShamsi(designProfile.DesignDate); dr1["Date"] = _date; //desProfile.DesignDate.ToString(); dr1["Designer"] = designProfile.Designer; dr1["ProjectName"] = designProfile.DesignName; //Atend.Control.Common.DesignName; dr1["Credit"] = designProfile.Validate; //dr1["SectionCount"] = arrSection.Count.ToString(); //dr1["PoleCount"] = CountPole.ToString(); if (System.IO.File.Exists(Atend.Control.ConnectionString.LogoPath)) { System.IO.FileStream FS = new System.IO.FileStream(Atend.Control.ConnectionString.LogoPath, System.IO.FileMode.Open); byte[] reader = new byte[FS.Length]; FS.Read(reader, 0, Convert.ToInt32(FS.Length)); dr1["Logo"] = reader; FS.Close(); } dr1["LogoName"] = Atend.Control.ConnectionString.LogoName; dsloadbranch.Tables["Title"].Rows.Add(dr1); } else { MessageBox.Show("لطفا ابتدا مشخصات طرح را تکمیل نمایید", "اخطار"); return(null); } return(dsloadbranch); }
private void frmDesignSaveServer_Load(object sender, EventArgs e) { if (ForceToClose) { this.Close(); } Atend.Base.Design.DDesignProfile CurrentDesignProfile = Atend.Base.Design.DDesignProfile.AccessSelect(); if (CurrentDesignProfile.DesignId != -1) { txtDesignName.Text = Atend.Control.Common.DesignName; txtDesignFullAddress.Text = Atend.Control.Common.DesignFullAddress; txtTitle.Text = CurrentDesignProfile.DesignName; Atend.Control.Common.DesignId = CurrentDesignProfile.DesignId; DataTable dt = Atend.Base.Design.DDesign.SelectAll(); gvDesign.AutoGenerateColumns = false; gvDesign.DataSource = dt; ///this.Text = Atend.Control.Common.DesignId.ToString(); } else { MessageBox.Show("design id was -1"); } }
public Atend.Report.dsSagAndTension FillCrossSection() { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; DataTable dtCross = Atend.Base.Calculating.CCrossSection.AccessSelectAll(); Atend.Report.dsSagAndTension dscrossSection = new Atend.Report.dsSagAndTension(); foreach (DataRow dr in dtCross.Rows) { DataRow drSection = dscrossSection.Tables["CrossSection"].NewRow(); //ed.WriteMessage("FROM={0}\n", dr["From"].ToString()); drSection["From"] = dr["From"].ToString(); drSection["To"] = dr["To"].ToString(); drSection["NameExist"] = dr["ExistCond"].ToString(); drSection["Lenght"] = dr["Lenght"].ToString(); drSection["NameComment"] = dr["CommentCond"].ToString(); drSection["CrossSection"] = dr["CrossSection"].ToString(); drSection["Current"] = dr["Current"].ToString(); drSection["Volt"] = dr["Volt"].ToString(); dscrossSection.Tables["CrossSection"].Rows.Add(drSection); } DataRow dr1 = dscrossSection.Tables["Title"].NewRow(); Atend.Base.Design.DDesignProfile designProfile = Atend.Base.Design.DDesignProfile.AccessSelect(); if (designProfile.Id != 0) { Atend.Base.Base.BRegion b12 = Atend.Base.Base.BRegion.SelectByCode(designProfile.Zone); dr1["Area"] = b12.SecondCode; System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar(); string _date = ChangeToShamsi(designProfile.DesignDate); dr1["Date"] = _date; //desProfile.DesignDate.ToString(); dr1["Designer"] = designProfile.Designer; dr1["ProjectName"] = designProfile.DesignName; //Atend.Control.Common.DesignName; dr1["Credit"] = designProfile.Validate; //dr1["SectionCount"] = arrSection.Count.ToString(); //dr1["PoleCount"] = CountPole.ToString(); if (System.IO.File.Exists(Atend.Control.ConnectionString.LogoPath)) { System.IO.FileStream FS = new System.IO.FileStream(Atend.Control.ConnectionString.LogoPath, System.IO.FileMode.Open); byte[] reader = new byte[FS.Length]; FS.Read(reader, 0, Convert.ToInt32(FS.Length)); dr1["Logo"] = reader; FS.Close(); } dr1["LogoName"] = Atend.Control.ConnectionString.LogoName; dscrossSection.Tables["Title"].Rows.Add(dr1); } else { MessageBox.Show("لطفا ابتدا مشخصات طرح را تکمیل نمایید", "اخطار"); return(null); } //Atend.Report.frmCrossSectionReport report = new frmCrossSectionReport(); //report.SetDataset(dscrossSection); //Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(report); return(dscrossSection); }
private void frmDesignProfile_Load(object sender, EventArgs e) { if (ForceToClose) { this.Close(); } BindDataToCboZone(); BindDataToCboSize(); if (cboZone.Items.Count > 0) { cboZone.SelectedIndex = 0; } if (cboSize.Items.Count > 0) { cboSize.SelectedIndex = 0; } string CurrentDate = ""; System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar(); CurrentDate = string.Format("{0}/{1:00}/{2:00}", p.GetYear(DateTime.Now), p.GetMonth(DateTime.Now), p.GetDayOfMonth(DateTime.Now)); txtDate.Text = CurrentDate; Atend.Base.Design.DDesignProfile DP = Atend.Base.Design.DDesignProfile.AccessSelect(); if (DP.Id != 0) { IsValid = true; Code = DP.Id; DesignId = DP.DesignId; txtDesignName.Text = DP.DesignName; txtDesignCode.Text = DP.DesignCode.ToString(); txtScale.Text = DP.Scale.ToString(); txtDate.Text = string.Format("{0}/{1:00}/{2:00}", p.GetYear(DP.DesignDate), p.GetMonth(DP.DesignDate), p.GetDayOfMonth(DP.DesignDate)); txtAddres.Text = DP.Address; //txtZone.Text = DP.Zone; if (DP.Zone == 0) { cboZone.SelectedIndex = 0; } else { cboZone.SelectedValue = DP.Zone; } txtValidate.Text = DP.Validate; txtEmployer.Text = DP.Employer; txtAdviser.Text = DP.Adviser; txtDesigner.Text = DP.Designer; txtController.Text = DP.Controller; txtSupporter.Text = DP.Supporter; txtApproval.Text = DP.Approval; txtPlanner.Text = DP.Planner; txtEdition.Text = DP.Edition; } else { txtDate.Text = CurrentDate; } }
public void Save() { Atend.Base.Design.DDesignProfile DP = new Atend.Base.Design.DDesignProfile(); DP.DesignId = DesignId; DP.DesignName = txtDesignName.Text; DP.DesignCode = Convert.ToString(txtDesignCode.Text); DP.Scale = Convert.ToSingle(txtScale.Text); System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar(); string a = txtDate.Text; string[] result = a.Split('/'); DP.DesignDate = p.ToDateTime(Convert.ToInt32(result[0]), Convert.ToInt32(result[1]), Convert.ToInt32(result[2]), 0, 0, 0, 0); DP.Address = txtAddres.Text; //DP.Zone = txtZone.Text; DP.Zone = Convert.ToInt32(cboZone.SelectedValue.ToString()); DP.Validate = txtValidate.Text; DP.Employer = txtEmployer.Text; DP.Adviser = txtAdviser.Text; DP.Designer = txtDesigner.Text; DP.Controller = txtController.Text; DP.Supporter = txtSupporter.Text; DP.Approval = txtApproval.Text; DP.Planner = txtPlanner.Text; DP.Id = Code; DP.Edition = txtEdition.Text; if (!IsValid) { if (DP.AccessInsert()) { MessageBox.Show("با موفقيت ثبت شد"); } else { MessageBox.Show("خطا در ثبت اطلاعات"); } } else { if (DP.AccessUpdate()) { MessageBox.Show("با موفقيت ويرايش شد"); } else { MessageBox.Show("خطا در ويرايش اطلاعات"); } } }
private void frmDrawFrame_Load(object sender, EventArgs e) { if (ForceToClose) { this.Close(); } dt_Products.Columns.Add(new System.Data.DataColumn("Type", System.Type.GetType("System.Int32"))); dt_Products.Columns.Add(new System.Data.DataColumn("ProductCode", System.Type.GetType("System.Int32"))); dt_Products.Columns.Add(new System.Data.DataColumn("SignText", System.Type.GetType("System.String"))); Atend.Base.Design.DDesignProfile SelectedDesign = Atend.Base.Design.DDesignProfile.AccessSelect(); if (SelectedDesign.DesignId != -1) { txtScale.Text = SelectedDesign.Scale.ToString(); } BindToCboPrintSize(); BindTogvSigns(); }
/// <summary> /// طرح پشتیبان /// </summary> private void PoshtibanDesign(OleDbConnection aConnection, OleDbTransaction aTransaction, SqlConnection sConnection, SqlTransaction sTransaction) { Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; DataTable dtWorkOrder = Atend.Base.Design.DPackage.AccessWorkOrders(aTransaction, aConnection); Atend.Base.Design.DDesignProfile _DDesignProfile = Atend.Base.Design.DDesignProfile.SelectByDesignID(sTransaction, sConnection, Atend.Control.Common.DesignId); Atend.Base.Design.DDesign _DDesign = Atend.Base.Design.DDesign.SelectByID(sTransaction, sConnection, Atend.Control.Common.DesignId); Atend.Base.Design.DDesignFile _DDesignFile = Atend.Base.Design.DDesignFile.SelectByDesignId(sTransaction, sConnection, Atend.Control.Common.DesignId); Atend.Base.Design.DDesignProfile currentDesignProfile = Atend.Base.Design.DDesignProfile.AccessSelect(aTransaction, aConnection); if (_DDesignProfile.Id != -1) { if (currentDesignProfile.DesignId != -1) { if (!currentDesignProfile.UpdateByDesignId(sTransaction, sConnection)) { throw new System.Exception("currentDesignProfile.Update 4"); } } else { throw new System.Exception("DDesignProfile access record was not found"); } } else { if (currentDesignProfile.DesignId != -1) { if (!currentDesignProfile.Insert(sTransaction, sConnection)) { throw new System.Exception("currentDesignProfile.Insert 5"); } } } #region design _DDesign.Region = Convert.ToByte(Atend.Base.Base.BRegion.SelectByCodeLoacal(currentDesignProfile.Zone).SecondCode); if (!_DDesign.Update(sTransaction, sConnection)) { throw new System.Exception("_DDesign.Update "); } #endregion #region DesignFile _DDesignFile.DesignId = Atend.Control.Common.DesignId; _DDesignFile.File = new byte[0]; #region ATNX file FileStream fs; fs = new FileStream(string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, Atend.Control.Common.DesignName.Replace(".DWG", ".ATNX")), FileMode.Open); BinaryReader br = new BinaryReader(fs); _DDesignFile.File = br.ReadBytes((Int32)br.BaseStream.Length); fs.Dispose(); #endregion #region PDF file if (txtBookAddress.Text != string.Empty) { fs = new FileStream(txtBookAddress.Text, FileMode.Open); br = new BinaryReader(fs); _DDesignFile.Book = br.ReadBytes((Int32)br.BaseStream.Length); fs.Dispose(); } else { _DDesignFile.Book = new byte[0]; } #endregion #region DWF file if (txtBookAddress.Text != string.Empty) { fs = new FileStream(txtDWFAddress.Text, FileMode.Open); br = new BinaryReader(fs); _DDesignFile.Image = br.ReadBytes((Int32)br.BaseStream.Length); fs.Dispose(); } else { _DDesignFile.Image = new byte[0]; } #endregion if (_DDesignFile.Id != -1) { if (!_DDesignFile.Update(sTransaction, sConnection)) { throw new System.Exception("NewDesignFile.Insert 5"); } } else { if (!_DDesignFile.Insert(sTransaction, sConnection)) { throw new System.Exception("CurrentDesignFile.Update 4"); } } #endregion #region StatusReport Atend.Global.Utility.UOtherOutPut Output = new Atend.Global.Utility.UOtherOutPut(); Atend.Report.dsSagAndTension ds = Output.FillStatusReport(); Atend.Base.Design.DStatusReport.DeleteByDesignId(currentDesignProfile.DesignId); for (int i = 0; i < ds.Tables["StatusReport"].Rows.Count; i++) { Atend.Base.Design.DStatusReport STR = new Atend.Base.Design.DStatusReport(); STR.DesignId = currentDesignProfile.DesignId; if (Atend.Control.NumericValidation.Int32Converter(ds.Tables["StatusReport"].Rows[i]["Code"].ToString())) { STR.ProductCode = Convert.ToInt32(ds.Tables["StatusReport"].Rows[i]["Code"].ToString()); } else { STR.ProductCode = 0; } DataTable ExTbl = Atend.Base.Base.BEquipStatus.SelectAllX(); STR.Existance = Convert.ToInt32(ExTbl.Select("Name = '" + ds.Tables["StatusReport"].Rows[i]["Exist"].ToString() + "'")[0]["ACode"].ToString()); int pc = Convert.ToInt32(ds.Tables["StatusReport"].Rows[i]["ProjectCode"]); //int pc = Atend.Base.Base.BProjectCode.AccessSelectByCode(Convert.ToInt32(Table.Rows[i]["ProjectCode"].ToString())).AdditionalCode; STR.ProjectCode = pc; ds.Tables["StatusReport"].Rows[i]["ProjectCode"] = pc; ds.Tables["StatusReport"].Rows[i]["Count"] = Math.Round(Convert.ToDouble(ds.Tables["StatusReport"].Rows[i]["Count"].ToString()), 2); STR.Count = Convert.ToDouble(ds.Tables["StatusReport"].Rows[i]["Count"].ToString()); if (!STR.Insert(sTransaction, sConnection)) { ed.WriteMessage("\nError In D_StatusReport Insertion\n"); } } #endregion #region WorkOrder if (Atend.Base.Design.DWorkOrder.Delete(Atend.Control.Common.DesignId, sTransaction, sConnection)) { foreach (DataRow drWorkOrder in dtWorkOrder.Rows) { Atend.Base.Design.DWorkOrder WO = new Atend.Base.Design.DWorkOrder(); WO.DesignID = Atend.Control.Common.DesignId;; WO.WorkOrder = Convert.ToInt32(drWorkOrder["WorkOrderCode"].ToString()); if (!WO.Insert(sTransaction, sConnection)) { throw new System.Exception("WorkOrder.Insert Failed 5"); } } } #endregion }
/// <summary> /// طرح جدید بدون پشتیبان /// </summary> private void NewDesignWithoutPoshtiban(OleDbConnection aConnection, OleDbTransaction aTransaction, SqlConnection sConnection, SqlTransaction sTransaction) { Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; //طرح کد نداره و در پشتیبان طرحی نداره پی یک طرح جدید تولید می کنیم ed.WriteMessage("@@@@ 1\n"); DataTable dtWorkOrder = Atend.Base.Design.DPackage.AccessWorkOrders(aTransaction, aConnection); Atend.Base.Design.DDesignProfile currentDesignProfile = Atend.Base.Design.DDesignProfile.AccessSelect(aTransaction, aConnection); Atend.Base.Design.DDesign currentDesign = new Atend.Base.Design.DDesign(); currentDesign.Title = currentDesignProfile.DesignName; currentDesign.ArchiveNo = currentDesignProfile.DesignCode; currentDesign.PRGCode = 0; ed.WriteMessage("@@@@ 2\n"); currentDesign.RequestType = 0; currentDesign.Region = Convert.ToByte(Atend.Base.Base.BRegion.SelectByCodeLoacal(currentDesignProfile.Zone).SecondCode); currentDesign.IsAtend = true; currentDesign.Address = currentDesignProfile.Address; ed.WriteMessage("@@@@ 3\n"); if (!currentDesign.Insert(sTransaction, sConnection)) { ed.WriteMessage("@@@@ 4\n"); throw new System.Exception("currentDesign.Insert 1"); } ed.WriteMessage("@@@@ 5\n"); foreach (DataRow drWorkOrder in dtWorkOrder.Rows) { Atend.Base.Design.DWorkOrder WO = new Atend.Base.Design.DWorkOrder(); WO.DesignID = currentDesign.Id; WO.WorkOrder = Convert.ToInt32(drWorkOrder["WorkOrderCode"].ToString()); if (!WO.Insert(sTransaction, sConnection)) { throw new System.Exception("WorkOrder.Insert Failed 1"); } } ed.WriteMessage("@@@@ 6\n"); currentDesignProfile.DesignId = currentDesign.Id; if (!currentDesignProfile.AccessUpdate(aTransaction, aConnection)) { throw new System.Exception("currentDesignProfile.AccessUpdate 1"); } ed.WriteMessage("@@@@ 7\n"); Atend.Base.Design.DDesignFile currentDesignFile = new Atend.Base.Design.DDesignFile(); currentDesignFile.DesignId = currentDesign.Id; currentDesignFile.File = new byte[0]; ed.WriteMessage("@@@@ 8\n"); #region ATNX file FileStream fs; fs = new FileStream(string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, Atend.Control.Common.DesignName.Replace(".DWG", ".ATNX")), FileMode.Open); BinaryReader br = new BinaryReader(fs); currentDesignFile.File = br.ReadBytes((Int32)br.BaseStream.Length); fs.Dispose(); #endregion ed.WriteMessage("@@@@ 9\n"); #region PDF file if (txtBookAddress.Text != string.Empty) { fs = new FileStream(txtBookAddress.Text, FileMode.Open); br = new BinaryReader(fs); currentDesignFile.Book = br.ReadBytes((Int32)br.BaseStream.Length); fs.Dispose(); } else { currentDesignFile.Book = new byte[0]; } #endregion ed.WriteMessage("@@@@ 10\n"); #region DWF file if (txtBookAddress.Text != string.Empty) { fs = new FileStream(txtDWFAddress.Text, FileMode.Open); br = new BinaryReader(fs); currentDesignFile.Image = br.ReadBytes((Int32)br.BaseStream.Length); fs.Dispose(); } else { currentDesignFile.Image = new byte[0]; } #endregion ed.WriteMessage("@@@@ 11\n"); if (!currentDesignFile.Insert(sTransaction, sConnection)) { throw new System.Exception("currentDesignFile.Insert 1"); } ed.WriteMessage("@@@@ 12\n"); if (!currentDesignProfile.Insert(sTransaction, sConnection)) { throw new System.Exception("currentDesignProfile.Insert 1"); } ed.WriteMessage("@@@@ 13\n"); #region StatusReport Atend.Global.Utility.UOtherOutPut Output = new Atend.Global.Utility.UOtherOutPut(); ed.WriteMessage("@@@@ 13.1\n"); Atend.Report.dsSagAndTension ds = Output.FillStatusReport(); ed.WriteMessage("@@@@ 13.2\n"); Atend.Base.Design.DStatusReport.DeleteByDesignId(currentDesignProfile.DesignId); ed.WriteMessage("@@@@ 14,{0}\n", ds.Tables["StatusReport"].Rows.Count); for (int i = 0; i < ds.Tables["StatusReport"].Rows.Count; i++) { Atend.Base.Design.DStatusReport STR = new Atend.Base.Design.DStatusReport(); STR.DesignId = currentDesignProfile.DesignId; if (Atend.Control.NumericValidation.Int32Converter(ds.Tables["StatusReport"].Rows[i]["Code"].ToString())) { STR.ProductCode = Convert.ToInt32(ds.Tables["StatusReport"].Rows[i]["Code"].ToString()); } else { STR.ProductCode = 0; } DataTable ExTbl = Atend.Base.Base.BEquipStatus.SelectAllX(); STR.Existance = Convert.ToInt32(ExTbl.Select("Name = '" + ds.Tables["StatusReport"].Rows[i]["Exist"].ToString() + "'")[0]["ACode"].ToString()); int pc = Convert.ToInt32(ds.Tables["StatusReport"].Rows[i]["ProjectCode"]); //int pc = Atend.Base.Base.BProjectCode.AccessSelectByCode(Convert.ToInt32(Table.Rows[i]["ProjectCode"].ToString())).AdditionalCode; STR.ProjectCode = pc; ds.Tables["StatusReport"].Rows[i]["ProjectCode"] = pc; ds.Tables["StatusReport"].Rows[i]["Count"] = Math.Round(Convert.ToDouble(ds.Tables["StatusReport"].Rows[i]["Count"].ToString()), 2); STR.Count = Convert.ToDouble(ds.Tables["StatusReport"].Rows[i]["Count"].ToString()); if (!STR.Insert(sTransaction, sConnection)) { ed.WriteMessage("\nError In D_StatusReport Insertion\n"); } ed.WriteMessage("@@@@ 15\n"); } #endregion }
public Atend.Report.dsSagAndTension FillLoadNode() { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage("\n -------------- Enter Fill Node------------------\n"); DataTable dtLoadNode = Atend.Base.Calculating.CDistributedLoadNode.AccessSelectAll(); Atend.Report.dsSagAndTension dsloadnode = new Atend.Report.dsSagAndTension(); ArrayList arrSection = new ArrayList(); foreach (DataRow dr in dtLoadNode.Rows) { DataRow drLoadNode = dsloadnode.Tables["Node"].NewRow(); drLoadNode["NodeName"] = dr["NodeName"].ToString(); drLoadNode["VoltAbs"] = dr["VoltAbs"].ToString(); drLoadNode["VoltArg"] = dr["VoltArg"].ToString(); drLoadNode["DropVolt"] = dr["DropVolt"].ToString(); drLoadNode["LoadPowerActive"] = dr["LoadPowerActive"].ToString(); drLoadNode["LoadPower"] = dr["LoadPower"].ToString(); drLoadNode["LoadCurrnetABS"] = dr["LoadCurrentAbs"].ToString(); drLoadNode["LoadCurrentArg"] = dr["LoadCurrentArg"].ToString(); dsloadnode.Tables["Node"].Rows.Add(drLoadNode); } DataRow dr1 = dsloadnode.Tables["Title"].NewRow(); Atend.Base.Design.DDesignProfile designProfile = Atend.Base.Design.DDesignProfile.AccessSelect(); //ed.WriteMessage("\n -----------{0}--------------\n", designProfile.Id); if (designProfile.Id != 0) { ed.WriteMessage("\n -------------- Enter Node Title------------------\n"); Atend.Base.Base.BRegion b12 = Atend.Base.Base.BRegion.SelectByCode(designProfile.Zone); dr1["Area"] = b12.SecondCode; System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar(); string _date = ChangeToShamsi(designProfile.DesignDate); dr1["Date"] = _date; //desProfile.DesignDate.ToString(); dr1["Designer"] = designProfile.Designer; dr1["ProjectName"] = designProfile.DesignName; //Atend.Control.Common.DesignName; //ed.WriteMessage("\n -----------{0}--------------\n", dr1["ProjectName"].ToString()); dr1["Credit"] = designProfile.Validate; //dr1["SectionCount"] = arrSection.Count.ToString(); //dr1["PoleCount"] = CountPole.ToString(); if (System.IO.File.Exists(Atend.Control.ConnectionString.LogoPath)) { System.IO.FileStream FS = new System.IO.FileStream(Atend.Control.ConnectionString.LogoPath, System.IO.FileMode.Open); byte[] reader = new byte[FS.Length]; FS.Read(reader, 0, Convert.ToInt32(FS.Length)); dr1["Logo"] = reader; FS.Close(); } dr1["LogoName"] = Atend.Control.ConnectionString.LogoName; dsloadnode.Tables["Title"].Rows.Add(dr1); } else { MessageBox.Show("لطفا ابتدا مشخصات طرح را تکمیل نمایید", "اخطار"); return(null); } //DataRow drDesign = dsloadnode.Tables["Title"].NewRow(); //drDesign["ProjectName"] = designProfile.DesignName; //drDesign["Designer"] = designProfile.Designer; //drDesign["Area"] = designProfile.Zone; //drDesign["Date"] = designProfile.DesignDate.ToString(); //dsloadnode.Tables["Title"].Rows.Add(drDesign); //Atend.Report.frmNodeReport nodeReport = new frmNodeReport(); //nodeReport.SetDataset(dsloadnode); //Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(nodeReport); return(dsloadnode); }
public Atend.Report.dsSagAndTension FillTrans() { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; DataTable dtTransCurrent = Atend.Base.Calculating.CTransCurrent.AccessSelectAll(); Atend.Report.dsSagAndTension dsTransCurrent = new Atend.Report.dsSagAndTension(); foreach (DataRow dr in dtTransCurrent.Rows) { DataRow drCurrent = dsTransCurrent.Tables["LoadCurrent"].NewRow(); drCurrent["I"] = dr["I"].ToString(); drCurrent["PF"] = dr["PF"].ToString(); drCurrent["Count"] = dr["BranchCount"].ToString(); drCurrent["CF"] = dr["CF"].ToString(); dsTransCurrent.Tables["LoadCurrent"].Rows.Add(drCurrent); } //ed.WriteMessage("PASS LoadCurrent\n"); DataTable dtLoadPower = Atend.Base.Calculating.CTransPower.AccessSelectAll(); foreach (DataRow dr in dtLoadPower.Rows) { DataRow drPower = dsTransCurrent.Tables["LoadPower"].NewRow(); drPower["P"] = dr["P"].ToString(); drPower["PF"] = dr["PF"].ToString(); drPower["Count"] = dr["BranchCount"].ToString(); drPower["CF"] = dr["CF"].ToString(); dsTransCurrent.Tables["LoadPower"].Rows.Add(drPower); } //ed.WriteMessage("PASS LOADPOWER\n"); DataTable dtLoadBranch = Atend.Base.Calculating.CTransBranch.AccessSelectAll(); foreach (DataRow dr in dtLoadBranch.Rows) { DataRow drBranch = dsTransCurrent.Tables["LoadBranch"].NewRow(); drBranch["I"] = dr["I"].ToString(); drBranch["PF"] = dr["PF"].ToString(); drBranch["BranchCount"] = dr["BranchCount"].ToString(); drBranch["PhuseCount"] = dr["PhaseCount"].ToString(); drBranch["CF"] = dr["CF"].ToString(); dsTransCurrent.Tables["LoadBranch"].Rows.Add(drBranch); } //ed.WriteMessage("PASS BranchName\n"); DataTable dtInput = Atend.Base.Calculating.CTransformer.AccessSelectAll(); //ed.WriteMessage("PassSelectROWS.Count={0}\n", dtInput.Rows.Count); foreach (DataRow dr in dtInput.Rows) { DataRow drInput = dsTransCurrent.Tables["InputInfoTranse"].NewRow(); //ed.WriteMessage("Build Row\n"); drInput["Height"] = dr["Height"].ToString(); //ed.WriteMessage("H\n"); drInput["Load"] = dr["Load"].ToString(); //ed.WriteMessage("L\n"); drInput["Result"] = dr["Result"].ToString(); //ed.WriteMessage("R\n"); drInput["PowerLoss"] = "0"; //ed.WriteMessage("P\n"); dsTransCurrent.Tables["InputInfoTranse"].Rows.Add(drInput); } //ed.WriteMessage("Pass INPUTINFO TrANS\n"); DataRow dr1 = dsTransCurrent.Tables["Title"].NewRow(); Atend.Base.Design.DDesignProfile designProfile = Atend.Base.Design.DDesignProfile.AccessSelect(); if (designProfile.Id != 0) { Atend.Base.Base.BRegion b12 = Atend.Base.Base.BRegion.SelectByCode(designProfile.Zone); dr1["Area"] = b12.SecondCode; System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar(); string _date = ChangeToShamsi(designProfile.DesignDate); dr1["Date"] = _date; //desProfile.DesignDate.ToString(); dr1["Designer"] = designProfile.Designer; dr1["ProjectName"] = designProfile.DesignName; //Atend.Control.Common.DesignName; dr1["Credit"] = designProfile.Validate; //dr1["SectionCount"] = arrSection.Count.ToString(); //dr1["PoleCount"] = CountPole.ToString(); if (System.IO.File.Exists(Atend.Control.ConnectionString.LogoPath)) { System.IO.FileStream FS = new System.IO.FileStream(Atend.Control.ConnectionString.LogoPath, System.IO.FileMode.Open); byte[] reader = new byte[FS.Length]; FS.Read(reader, 0, Convert.ToInt32(FS.Length)); dr1["Logo"] = reader; FS.Close(); } dr1["LogoName"] = Atend.Control.ConnectionString.LogoName; dsTransCurrent.Tables["Title"].Rows.Add(dr1); } else { MessageBox.Show("لطفا ابتدا مشخصات طرح را تکمیل نمایید", "اخطار"); return(null); } ed.WriteMessage("GO TO Page\n"); //Atend.Report.frmTranseInfoReport report = new frmTranseInfoReport(); //report.SetDataset(dsTransCurrent); //Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(report); return(dsTransCurrent); }
public Atend.Report.dsSagAndTension FillStatusReport() { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Atend.Report.dsSagAndTension ds = new Atend.Report.dsSagAndTension(); ed.WriteMessage("#### 0\n"); Atend.Global.Utility.UReport Report = new Atend.Global.Utility.UReport(); ed.WriteMessage("#### 0.1\n"); System.Data.DataTable Table = Report.CreateExcelStatus(); //ed.WriteMessage("ST Report2 - table Row Count = " + Table.Rows.Count.ToString() + "\n"); ed.WriteMessage("#### 1\n"); DataRow dr1 = ds.Tables["Title"].NewRow(); Atend.Base.Design.DDesignProfile desProfile = Atend.Base.Design.DDesignProfile.AccessSelect(); ed.WriteMessage("#### 2\n"); if (desProfile.Id != 0) { Atend.Base.Base.BRegion b12 = Atend.Base.Base.BRegion.SelectByCode(desProfile.Zone); dr1["Area"] = b12.SecondCode; System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar(); string _date = ChangeToShamsi(desProfile.DesignDate); dr1["Date"] = _date; //desProfile.DesignDate.ToString(); dr1["Designer"] = desProfile.Designer; //ed.WriteMessage(); dr1["ProjectName"] = desProfile.DesignName; //Atend.Control.Common.DesignName; dr1["Credit"] = desProfile.Validate; //dr1["SectionCount"] = arrSection.Count.ToString(); //dr1["PoleCount"] = CountPole.ToString(); ed.WriteMessage(string.Format(@" >> {0}\SupportFiles\default.JPG ", Atend.Control.Common.fullPath) + "\n"); ed.WriteMessage(string.Format(@" >> {0} ", Atend.Control.ConnectionString.LogoPath) + "\n"); if (System.IO.File.Exists(Atend.Control.ConnectionString.LogoPath)) { System.IO.FileStream FS = new System.IO.FileStream(Atend.Control.ConnectionString.LogoPath, System.IO.FileMode.Open); byte[] reader = new byte[FS.Length]; FS.Read(reader, 0, Convert.ToInt32(FS.Length)); dr1["Logo"] = reader; FS.Close(); } //else //{ // //MessageBox.Show(string.Format(@"{0}\SupportFiles\default.JPG", Atend.Control.Common.fullPath)); // //ed.WriteMessage("2 \n"); // if (System.IO.File.Exists(string.Format(@"{0}\SupportFiles\default.JPG", Atend.Control.Common.fullPath))) // { // System.IO.FileStream FS = new System.IO.FileStream(string.Format(@"{0}\SupportFiles\default.JPG", Atend.Control.Common.fullPath), System.IO.FileMode.Open); // byte[] reader11 = new byte[FS.Length]; // FS.Read(reader11, 0, Convert.ToInt32(FS.Length)); // dr1["Logo"] = reader11; // FS.Close(); // } // else // { // ed.WriteMessage("file was not exist in this path : " + string.Format(@"{0}\SupportFiles\default.JPG", Atend.Control.Common.fullPath) + "\n"); // } //} dr1["LogoName"] = Atend.Control.ConnectionString.LogoName; ds.Tables["Title"].Rows.Add(dr1); } else { // MessageBox.Show("لطفا ابتدا مشخصات طرح را تکمیل نمایید", "اخطار"); ed.WriteMessage("#### 3\n"); return(null); } //____________________________________________________ Dictionary <string, string> Dic = new Dictionary <string, string>(); Dic.Add("Code", "كد كالا"); Dic.Add("Name", "نام كالا"); Dic.Add("Count", "تعداد"); Dic.Add("Exist", "نوع صورت وضعیت"); Dic.Add("ProjectCode", "کد دستور کار تجهیز"); Dic.Add("Unit", "واحد كالا"); Dic.Add("Price", "قیمت واحد"); Dic.Add("ExecutePrice", "قیمت اجرا"); Dic.Add("WagePrice", "قیمت دستمزد"); Dic.Add("ProjectName1", "شرح دستور کار"); ed.WriteMessage("#### 4\n"); Atend.Base.Design.DDesignProfile DP = Atend.Base.Design.DDesignProfile.AccessSelect(); ed.WriteMessage("#### 5\n"); System.Data.DataTable UnitTable = Atend.Base.Base.BUnit.SelectAll(); ed.WriteMessage("#### 6\n"); try { ed.WriteMessage("#### 7 , {0}\n", Table.Rows.Count); for (int i = 0; i < Table.Rows.Count; i++) { if (Atend.Control.NumericValidation.Int32Converter(Table.Rows[i]["Unit"].ToString())) { DataRow[] drs = UnitTable.Select(string.Format("Code={0}", Convert.ToInt32(Table.Rows[i]["Unit"]))); if (drs.Length > 0) { Table.Rows[i]["Unit"] = drs[0]["Name"]; } } Table.Rows[i]["Exist"] = Atend.Base.Base.BEquipStatus.SelectByACode(Convert.ToInt32(Table.Rows[i]["Exist"])).Name; } } catch (System.Exception ex2) { ed.WriteMessage(string.Format("Error : {0} \n", ex2.Message)); }// ed.WriteMessage("#### 8\n"); //ds.StatusReport = Table; int Sum = 0; //DataColumn DC = new DataColumn("Sum", typeof(int)); //Table.Columns.Add(DC); ed.WriteMessage("#### 9\n"); foreach (DataRow dr in Table.Rows) { //ed.WriteMessage("\n Name StRep = {0}", dr["Name"].ToString()); DataRow drStatusReport = ds.Tables["StatusReport"].NewRow(); drStatusReport["Code"] = dr["Code"].ToString(); drStatusReport["Name"] = dr["Name"].ToString().PadRight(dr["Name"].ToString().Length); drStatusReport["Count"] = dr["Count"].ToString(); drStatusReport["Unit"] = dr["Unit"].ToString(); drStatusReport["Price"] = dr["Price"].ToString(); drStatusReport["ExecutePrice"] = dr["ExecutePrice"].ToString(); drStatusReport["WagePrice"] = dr["WagePrice"].ToString(); drStatusReport["Exist"] = dr["Exist"].ToString(); drStatusReport["ProjectCode"] = dr["ProjectCode"].ToString(); drStatusReport["ProjectName1"] = dr["ProjectName1"].ToString(); // ed.WriteMessage(" >>>>> Total:{0} \nPrice:{1} \nExecutePrice:{2} \nWagePrice:{3} \nCount: {4}\n", //drStatusReport["Total"], //(dr["Price"]), //(dr["ExecutePrice"]), //(dr["WagePrice"]), //(dr["Count"].ToString())); drStatusReport["Total"] = (Convert.ToDouble(dr["Price"]) + Convert.ToDouble(dr["ExecutePrice"]) + Convert.ToDouble(dr["WagePrice"])) * Convert.ToDouble(dr["Count"].ToString()); //ed.WriteMessage(" <<<< Total:{0} \nPrice:{1} \nExecutePrice:{2} \nWagePrice:{3} \nCount: {4}\n", // drStatusReport["Total"], // (dr["Price"]), // (dr["ExecutePrice"]), // (dr["WagePrice"]), // (dr["Count"].ToString())); drStatusReport["AreaCoeff"] = 1; Sum += (Convert.ToInt32(drStatusReport["Total"].ToString())); ds.Tables["StatusReport"].Rows.Add(drStatusReport); } for (int i = 0; i < ds.Tables["StatusReport"].Rows.Count; i++) { ds.Tables["StatusReport"].Rows[i]["Sum"] = Sum; } return(ds); }
private void btnOk_Click(object sender, EventArgs e) { Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; if (Validation()) { Atend.Base.Design.NodeTransaction _NodeTransaction = new Atend.Base.Design.NodeTransaction(); SqlConnection sConnection = null; SqlTransaction sTransaction = null; OleDbTransaction aTransaction = null; OleDbConnection aConnection = null; try { if (_NodeTransaction.CreateTransactionAndConnection(out sTransaction, out sConnection, out aTransaction, out aConnection, false)) { Atend.Control.Common.DesignId = Atend.Base.Design.DDesignProfile.AccessSelect(aTransaction, aConnection).DesignId; if (Atend.Control.Common.DesignId == 0) { if (MessageBox.Show("آیا طرح در پشتیبان تعریف شده است", "ذخیره سازی طرح", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { //طرح کد نداره ولی در پشتیبان است پس به پشتیبان اختصاص می دهیم ed.WriteMessage("~~~ No design Id and is Poshtiban file ~~~\n"); if (gvDesign.SelectedRows.Count > 0) { if (chkIsComplement.Checked) { //Is Postiban and is complement ed.WriteMessage("~~~ is complement ~~~\n"); Atend.Base.Design.DDesign currentDessign = Atend.Base.Design.DDesign.SelectByID(sTransaction, sConnection, Convert.ToInt32(gvDesign.SelectedRows[0].Cells["Id"].Value)); if (currentDessign.Id != -1) { DataTable Designs = Atend.Base.Design.DDesign.SelectByCode(sTransaction, sConnection, currentDessign.Code); if (Designs.Rows.Count > 0) { DataView dv = new DataView(Designs); dv.Sort = "RequestType"; Atend.Base.Design.DDesign NewDesign = Atend.Base.Design.DDesign.SelectByID(sTransaction, sConnection, Convert.ToInt32(dv.Table.Rows[0]["Id"].ToString())); if (NewDesign.Id != -1) { NewDesign.RequestType++; if (!NewDesign.Insert(sTransaction, sConnection)) { throw new System.Exception("NewDesign.Insert 2"); } Atend.Base.Design.DDesignProfile currentProfile = Atend.Base.Design.DDesignProfile.AccessSelect(aTransaction, aConnection); if (currentProfile.DesignId != -1) { currentProfile.DesignId = NewDesign.Id; if (!currentProfile.AccessUpdate(aTransaction, aConnection)) { throw new System.Exception("currentProfile.AccessUpdate 2"); } Atend.Base.Design.DDesignFile NewDesignFile = new Atend.Base.Design.DDesignFile(); NewDesignFile.DesignId = NewDesign.Id; NewDesignFile.File = null; FileStream fs; fs = new FileStream(string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, Atend.Control.Common.DesignName.Replace(".DWG", ".ATNX")), FileMode.Open); BinaryReader br = new BinaryReader(fs); NewDesignFile.File = br.ReadBytes((Int32)br.BaseStream.Length); fs.Dispose(); if (!NewDesignFile.Insert(sTransaction, sConnection)) { throw new System.Exception("NewDesignFile.Insert 2"); } if (!currentProfile.Insert(sTransaction, sConnection)) { throw new System.Exception("currentProfile.Insert 2"); } MessageBox.Show("Well done 2"); } } } }//////// } else { //Is Poshtiban and is not complement ed.WriteMessage("~~~ is not complement ~~~\n"); Atend.Base.Design.DDesignFile CurrentDesignFile = Atend.Base.Design.DDesignFile.SelectByDesignId(sTransaction, sConnection, Convert.ToInt32(gvDesign.SelectedRows[0].Cells["Id"].Value)); if (CurrentDesignFile.Id != -1) { ed.WriteMessage("~~~ have file ~~~\n"); Atend.Base.Design.DDesignProfile currentDesignProfile = Atend.Base.Design.DDesignProfile.AccessSelect(aTransaction, aConnection); if (currentDesignProfile.DesignId != -1) { currentDesignProfile.DesignId = Convert.ToInt32(gvDesign.SelectedRows[0].Cells["Id"].Value); if (!currentDesignProfile.AccessUpdate(aTransaction, aConnection)) { throw new System.Exception("currentDesignProfile.AccessUpdate 6"); } CurrentDesignFile.File = null; FileStream fs; fs = new FileStream(string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, Atend.Control.Common.DesignName.Replace(".DWG", ".ATNX")), FileMode.Open); BinaryReader br = new BinaryReader(fs); CurrentDesignFile.File = br.ReadBytes((Int32)br.BaseStream.Length); fs.Dispose(); if (!CurrentDesignFile.Update(sTransaction, sConnection)) { throw new System.Exception("CurrentDesignFile.Update 6"); } if (!currentDesignProfile.UpdateByDesignId(sTransaction, sConnection)) { throw new System.Exception("currentDesignProfile.Update 6"); } MessageBox.Show("well done 6"); } } else { ed.WriteMessage("~~~ does not have file ~~~\n"); Atend.Base.Design.DDesignProfile currentDesignProfile = Atend.Base.Design.DDesignProfile.AccessSelect(aTransaction, aConnection); if (currentDesignProfile.DesignId != -1) { currentDesignProfile.DesignId = Convert.ToInt32(gvDesign.SelectedRows[0].Cells["Id"].Value); if (!currentDesignProfile.AccessUpdate(aTransaction, aConnection)) { throw new System.Exception("currentDesignProfile.AccessUpdate 5"); } Atend.Base.Design.DDesignFile NewDesignFile = new Atend.Base.Design.DDesignFile(); NewDesignFile.DesignId = Convert.ToInt32(gvDesign.SelectedRows[0].Cells["Id"].Value); NewDesignFile.File = null; FileStream fs; fs = new FileStream(string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, Atend.Control.Common.DesignName.Replace(".DWG", ".ATNX")), FileMode.Open); BinaryReader br = new BinaryReader(fs); NewDesignFile.File = br.ReadBytes((Int32)br.BaseStream.Length); fs.Dispose(); if (!NewDesignFile.Insert(sTransaction, sConnection)) { throw new System.Exception("NewDesignFile.Insert 5"); } if (!currentDesignProfile.Insert(sTransaction, sConnection)) { throw new System.Exception("currentDesignProfile.Insert 5"); } MessageBox.Show("well done 5"); } } } } } else ///////////////////////////////////////////////////////////////////////////////// { //طرح کد نداره و در پشتیبان طرحی نداره پی یک طرح جدید تولید می کنیم ed.WriteMessage("~~~ No design Id and is atend file ~~~\n"); Atend.Base.Design.DDesignProfile currentDesignProfile = Atend.Base.Design.DDesignProfile.AccessSelect(aTransaction, aConnection); Atend.Base.Design.DDesign currentDesign = new Atend.Base.Design.DDesign(); currentDesign.Code = 0; currentDesign.Title = currentDesignProfile.DesignName; currentDesign.ArchiveNo = currentDesignProfile.DesignCode; currentDesign.PRGCode = 0; currentDesign.RequestType = 0; currentDesign.AdditionalCode = 0; if (!currentDesign.Insert(sTransaction, sConnection)) { throw new System.Exception("currentDesign.Insert 1"); } currentDesignProfile.DesignId = currentDesign.Id; if (!currentDesignProfile.AccessUpdate(aTransaction, aConnection)) { throw new System.Exception("currentDesignProfile.AccessUpdate 1"); } Atend.Base.Design.DDesignFile currentDesignFile = new Atend.Base.Design.DDesignFile(); currentDesignFile.DesignId = currentDesign.Id; currentDesignFile.File = null; FileStream fs; fs = new FileStream(string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, Atend.Control.Common.DesignName.Replace(".DWG", ".ATNX")), FileMode.Open); BinaryReader br = new BinaryReader(fs); currentDesignFile.File = br.ReadBytes((Int32)br.BaseStream.Length); fs.Dispose(); if (!currentDesignFile.Insert(sTransaction, sConnection)) { throw new System.Exception("currentDesignFile.Insert 1"); } if (!currentDesignProfile.Insert(sTransaction, sConnection)) { throw new System.Exception("currentDesignProfile.Insert 1"); } MessageBox.Show("Well Done 1"); } } else////////////////////////////////////// ALL DESIGN HAVE DESIGN ID /////////////////////////////////////// { //means Design has DesignId MessageBox.Show(Atend.Control.Common.DesignId.ToString()); if (chkIsComplement.Checked) { //means design is complement Atend.Base.Design.DDesign currentDessign = Atend.Base.Design.DDesign.SelectByID(sTransaction, sConnection, Atend.Control.Common.DesignId); if (currentDessign.Id != -1) { DataTable Designs = Atend.Base.Design.DDesign.SelectByCode(sTransaction, sConnection, currentDessign.Code); if (Designs.Rows.Count > 0) { DataView dv = new DataView(Designs); dv.Sort = "RequestType"; Atend.Base.Design.DDesign NewDesign = Atend.Base.Design.DDesign.SelectByID(sTransaction, sConnection, Convert.ToInt32(dv.Table.Rows[0]["Id"].ToString())); if (NewDesign.Id != -1) { NewDesign.RequestType++; if (!NewDesign.Insert(sTransaction, sConnection)) { throw new System.Exception("NewDesign.Insert 3"); } Atend.Base.Design.DDesignProfile currentProfile = Atend.Base.Design.DDesignProfile.AccessSelect(aTransaction, aConnection); if (currentProfile.DesignId != -1) { currentProfile.DesignId = NewDesign.Id; if (!currentProfile.AccessUpdate(aTransaction, aConnection)) { throw new System.Exception("currentProfile.AccessUpdate 3"); } Atend.Base.Design.DDesignFile NewDesignFile = new Atend.Base.Design.DDesignFile(); NewDesignFile.DesignId = NewDesign.Id; NewDesignFile.File = null; FileStream fs; fs = new FileStream(string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, Atend.Control.Common.DesignName.Replace(".DWG", ".ATNX")), FileMode.Open); BinaryReader br = new BinaryReader(fs); NewDesignFile.File = br.ReadBytes((Int32)br.BaseStream.Length); fs.Dispose(); if (!NewDesignFile.Insert(sTransaction, sConnection)) { throw new System.Exception("NewDesignFile.Insert 3"); } if (!currentProfile.Insert(sTransaction, sConnection)) { throw new System.Exception("currentProfile.Insert 3"); } MessageBox.Show("Well done 3"); } } } }//////// } else { //means design is not complement Atend.Base.Design.DDesignFile CurrentDesignFile = Atend.Base.Design.DDesignFile.SelectByDesignId(sTransaction, sConnection, Atend.Control.Common.DesignId); if (CurrentDesignFile.Id != -1) { ed.WriteMessage("~~~ have file ~~~\n"); Atend.Base.Design.DDesignProfile currentDesignProfile = Atend.Base.Design.DDesignProfile.AccessSelect(aTransaction, aConnection); if (currentDesignProfile.DesignId != -1) { CurrentDesignFile.File = null; FileStream fs; fs = new FileStream(string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, Atend.Control.Common.DesignName.Replace(".DWG", ".ATNX")), FileMode.Open); BinaryReader br = new BinaryReader(fs); CurrentDesignFile.File = br.ReadBytes((Int32)br.BaseStream.Length); fs.Dispose(); if (!CurrentDesignFile.Update(sTransaction, sConnection)) { throw new System.Exception("CurrentDesignFile.Update 4"); } if (!currentDesignProfile.UpdateByDesignId(sTransaction, sConnection)) { throw new System.Exception("currentDesignProfile.Update 4"); } MessageBox.Show("well done 4"); } else { throw new System.Exception("DDesignProfile access record was not found"); } } else { ed.WriteMessage("~~~ does not have file ~~~\n"); Atend.Base.Design.DDesignProfile currentDesignProfile = Atend.Base.Design.DDesignProfile.AccessSelect(aTransaction, aConnection); if (currentDesignProfile.DesignId != -1) { Atend.Base.Design.DDesignFile NewDesignFile = new Atend.Base.Design.DDesignFile(); NewDesignFile.DesignId = Atend.Control.Common.DesignId; NewDesignFile.File = null; FileStream fs; fs = new FileStream(string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, Atend.Control.Common.DesignName.Replace(".DWG", ".ATNX")), FileMode.Open); BinaryReader br = new BinaryReader(fs); NewDesignFile.File = br.ReadBytes((Int32)br.BaseStream.Length); fs.Dispose(); if (!NewDesignFile.Insert(sTransaction, sConnection)) { throw new System.Exception("NewDesignFile.Insert 5"); } if (!currentDesignProfile.Insert(sTransaction, sConnection)) { throw new System.Exception("currentDesignProfile.Insert 5"); } MessageBox.Show("well done 4-2"); } } } } } aTransaction.Commit(); sTransaction.Commit(); aConnection.Close(); sConnection.Close(); } catch { aTransaction.Rollback(); sTransaction.Rollback(); aConnection.Close(); sConnection.Close(); ed.WriteMessage("ERROR WHILE SAVE FILE ON SERVER"); //AllowToClose = false; } DataTable dt = Atend.Base.Design.DDesign.SelectAll(); gvDesign.AutoGenerateColumns = false; gvDesign.DataSource = dt; } else { AllowToClose = false; } }
public Atend.Report.dsSagAndTension FillRudSurface() { ArrayList arrSection = new ArrayList(); bool chk = true; DataTable dtrudSurface = Atend.Base.Calculating.CRudSurface.AccessSelect(); Atend.Report.dsSagAndTension dsSagTensionReport = new Atend.Report.dsSagAndTension(); int CountPole = 0; for (int i = 0; i < arrSection.Count; i++) { DataTable dtpoleSec = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(arrSection[i].ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.Pole)); CountPole += dtpoleSec.Rows.Count; DataTable dtpoleSec1 = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(arrSection[i].ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.PoleTip)); CountPole += dtpoleSec1.Rows.Count; } DataRow dr1 = dsSagTensionReport.Tables["Title"].NewRow(); Atend.Base.Design.DDesignProfile desProfile = Atend.Base.Design.DDesignProfile.AccessSelect(); if (desProfile.Id != 0) { Atend.Base.Base.BRegion b12 = Atend.Base.Base.BRegion.SelectByCode(desProfile.Zone); dr1["Area"] = b12.SecondCode; System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar(); string _date = ChangeToShamsi(desProfile.DesignDate); dr1["Date"] = _date; //desProfile.DesignDate.ToString(); dr1["Designer"] = desProfile.Designer; dr1["ProjectName"] = desProfile.DesignName; //Atend.Control.Common.DesignName; dr1["SectionCount"] = arrSection.Count.ToString(); dr1["Credit"] = desProfile.Validate; dr1["PoleCount"] = CountPole.ToString(); if (System.IO.File.Exists(Atend.Control.ConnectionString.LogoPath)) { System.IO.FileStream FS = new System.IO.FileStream(Atend.Control.ConnectionString.LogoPath, System.IO.FileMode.Open); byte[] reader = new byte[FS.Length]; FS.Read(reader, 0, Convert.ToInt32(FS.Length)); dr1["Logo"] = reader; FS.Close(); } dr1["LogoName"] = Atend.Control.ConnectionString.LogoName; dsSagTensionReport.Tables["Title"].Rows.Add(dr1); } else { // MessageBox.Show("لطفا ابتدا مشخصات طرح را تکمیل نمایید", "اخطار"); return(null); } foreach (DataRow dr in dtrudSurface.Rows) { DataRow drForcePole = dsSagTensionReport.Tables["RudSurface"].NewRow(); //Atend.Base.Calculating.CStartEnd startEnd = Atend.Base.Calculating.CStartEnd.AccessSelectBySectionCode(new Guid(dr["SectionCode"].ToString())); //Atend.Base.Design.DPackage dPackStart = Atend.Base.Design.DPackage.AccessSelectByNodeCode(startEnd.StartPole); //Atend.Base.Design.DPackage dPackEnd = Atend.Base.Design.DPackage.AccessSelectByNodeCode(startEnd.EndPole); drForcePole["SectionNumber"] = dr["Number"].ToString(); drForcePole["PoleNumber"] = dr["DcPole"].ToString(); drForcePole["Normal"] = dr["DcNorm"].ToString(); drForcePole["Ice"] = dr["DcIceHeavy"].ToString(); drForcePole["Wind"] = dr["DcWindSpeed"].ToString(); drForcePole["MaxTemp"] = dr["DcMaxTemp"].ToString(); drForcePole["MinTemp"] = dr["DcMinTemp"].ToString(); drForcePole["IceWind"] = dr["DcWindIce"].ToString(); dsSagTensionReport.Tables["RudSurface"].Rows.Add(drForcePole); chk = true; for (int i = 0; i < arrSection.Count; i++) { if (new Guid(arrSection[0].ToString()) == new Guid(dr["SectionCode"].ToString())) { chk = false; } } if (chk) { arrSection.Add(dr["SectionCode"].ToString()); } } //MessageBox.Show(dsSagTensionReport.Tables["RudSurface"].Rows.Count.ToString()); //Atend.Report.frmRudSurfaceReport frm = new frmRudSurfaceReport(); //frm.SetDataset(dsSagTensionReport); //Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(frm); return(dsSagTensionReport); }
public Atend.Report.dsSagAndTension FillSagAndTension(bool IsUTS) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; //System.Windows.Forms.MessageBox.Show("salam"); ed.WriteMessage("-2\n"); ArrayList arrSection = new ArrayList(); ed.WriteMessage("-1\n"); bool chk = true; ed.WriteMessage("0\n"); DataTable dtSagtension = Atend.Base.Calculating.CSagAndTension.AccessSelectByIsUTS(IsUTS); ed.WriteMessage("1\n"); Atend.Report.dsSagAndTension dsSagTensionReport = new Atend.Report.dsSagAndTension(); ed.WriteMessage("2\n"); int CountPole = 0; ed.WriteMessage("3\n"); for (int i = 0; i < arrSection.Count; i++) { DataTable dtpoleSec = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(arrSection[i].ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.Pole)); CountPole += dtpoleSec.Rows.Count; DataTable dtpoleSec1 = Atend.Base.Design.DPoleSection.AccessSelectBySectionCodeProductType(new Guid(arrSection[i].ToString()), Convert.ToInt32(Atend.Control.Enum.ProductType.PoleTip)); CountPole += dtpoleSec1.Rows.Count; } ed.WriteMessage("4\n"); DataRow dr1 = dsSagTensionReport.Tables["Title"].NewRow(); ed.WriteMessage("5\n"); Atend.Base.Design.DDesignProfile desProfile = Atend.Base.Design.DDesignProfile.AccessSelect(); ed.WriteMessage("6\n"); if (desProfile.Id != 0) { Atend.Base.Base.BRegion b12 = Atend.Base.Base.BRegion.SelectByCode(desProfile.Zone); dr1["Area"] = b12.SecondCode; System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar(); string _date = ChangeToShamsi(desProfile.DesignDate); dr1["Date"] = _date; //desProfile.DesignDate.ToString(); dr1["Designer"] = desProfile.Designer; dr1["ProjectName"] = desProfile.DesignName; //Atend.Control.Common.DesignName; dr1["SectionCount"] = arrSection.Count.ToString(); dr1["PoleCount"] = CountPole.ToString(); dr1["Credit"] = desProfile.Validate; if (System.IO.File.Exists(Atend.Control.ConnectionString.LogoPath)) { System.IO.FileStream FS = new System.IO.FileStream(Atend.Control.ConnectionString.LogoPath, System.IO.FileMode.Open); byte[] reader = new byte[FS.Length]; FS.Read(reader, 0, Convert.ToInt32(FS.Length)); dr1["Logo"] = reader; FS.Close(); } dr1["LogoName"] = Atend.Control.ConnectionString.LogoName; dsSagTensionReport.Tables["Title"].Rows.Add(dr1); } else { MessageBox.Show("لطفا ابتدا مشخصات طرح را تکمیل نمایید", "اخطار"); return(null); } ed.WriteMessage("7\n"); foreach (DataRow dr in dtSagtension.Rows) { ed.WriteMessage("FillSagTension\n"); DataRow drSagTension = dsSagTensionReport.Tables["SagAndTension"].NewRow(); Atend.Base.Calculating.CStartEnd startEnd = Atend.Base.Calculating.CStartEnd.AccessSelectBySectionCode(new Guid(dr["SectionCode"].ToString())); Atend.Base.Design.DPackage dPackStart = Atend.Base.Design.DPackage.AccessSelectByNodeCode(startEnd.StartPole); Atend.Base.Design.DPackage dPackEnd = Atend.Base.Design.DPackage.AccessSelectByNodeCode(startEnd.EndPole); Atend.Base.Calculating.CDefaultMec DefMec = Atend.Base.Calculating.CDefaultMec.AccessSelectBySectionCode(new Guid(dr["SectionCode"].ToString()), IsUTS); drSagTension["SectionCode"] = dr["Number"].ToString(); drSagTension["StartPole"] = dPackStart.Number; drSagTension["EndPole"] = dPackEnd.Number; drSagTension["NormH"] = dr["NormH"].ToString(); drSagTension["NormF"] = dr["NormF"].ToString(); drSagTension["WindAndIceH"] = dr["WindAndIceH"].ToString(); drSagTension["WindAndIceF"] = dr["WindAndIceF"].ToString(); drSagTension["MinTempH"] = dr["MinTempH"].ToString(); drSagTension["MinTempF"] = dr["MinTempF"].ToString(); drSagTension["MaxTempH"] = dr["MaxTempH"].ToString(); drSagTension["MaxTempF"] = dr["MaxTempF"].ToString(); drSagTension["WindH"] = dr["WindH"].ToString(); drSagTension["WindF"] = dr["WindF"].ToString(); drSagTension["IceH"] = dr["IceH"].ToString(); drSagTension["IceF"] = dr["IceF"].ToString(); drSagTension["CondName"] = dr["ConductorName"].ToString(); drSagTension["Span"] = DefMec.SE; dsSagTensionReport.Tables["SagAndTension"].Rows.Add(drSagTension); chk = true; for (int i = 0; i < arrSection.Count; i++) { if (new Guid(arrSection[0].ToString()) == new Guid(dr["SectionCode"].ToString())) { chk = false; } } if (chk) { arrSection.Add(dr["SectionCode"].ToString()); } } ed.WriteMessage("8\n"); return(dsSagTensionReport); }