private void Save(int RowIndex) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Atend.Base.Calculating.CDefaultRudSurface defRudSurface = Atend.Base.Calculating.CDefaultRudSurface.AccessSelectBySectionCode(new Guid(gvSection.Rows[RowIndex].Cells[0].Value.ToString())); DataRow[] drDefault = dtSectionNumber.Select(string.Format(" SectionCode='{0}'", gvSection.Rows[RowIndex].Cells[0].Value.ToString())); if (defRudSurface.Code != 0) { ed.WriteMessage("UTS={0}\n", drDefault[0]["UTS"].ToString()); defRudSurface.UTS = Convert.ToDouble(drDefault[0]["UTS"].ToString()); defRudSurface.NetCross = Convert.ToInt32(drDefault[0]["NetCrossCode"].ToString()); defRudSurface.SectionCode = new Guid(gvSection.Rows[RowIndex].Cells[0].Value.ToString()); //defMec.SE = se; defRudSurface.AccessUpdate(); } else { ed.WriteMessage("UTS={0}\n", drDefault[0]["UTS"].ToString()); defRudSurface.NetCross = Convert.ToInt32(drDefault[0]["NetCrossCode"].ToString()); defRudSurface.UTS = Convert.ToDouble(drDefault[0]["UTS"].ToString()); defRudSurface.SectionCode = new Guid(gvSection.Rows[RowIndex].Cells[0].Value.ToString()); defRudSurface.AccessInsert(); } System.Data.DataTable dtResultRudSurface = Atend.Base.Calculating.CRudSurface.AccessSelectBySectionCode(new Guid(gvSection.Rows[RowIndex].Cells[0].Value.ToString())); if (dtResultRudSurface.Rows.Count != 0) { Atend.Base.Calculating.CRudSurface.AccessDeleteBySectionCode(new Guid(gvSection.Rows[RowIndex].Cells[0].Value.ToString())); } foreach (DataRow dr in dtResult.Rows) { Atend.Base.Calculating.CRudSurface surface = new Atend.Base.Calculating.CRudSurface(); surface.DcIceHeavy = Convert.ToDouble(dr["DcIceHeavy"].ToString()); surface.DcMaxTemp = Convert.ToDouble(dr["DcMaxTemp"].ToString()); surface.DcMinTemp = Convert.ToDouble(dr["DcMinTemp"].ToString()); surface.DcNorm = Convert.ToDouble(dr["DcNorm"].ToString()); surface.DcPole = dr["DcPole"].ToString(); surface.DcwindIce = Convert.ToDouble(dr["DcWindIce"].ToString()); surface.DcWindSpeed = Convert.ToDouble(dr["DcWindSpeed"].ToString()); surface.SectionCode = new Guid(gvSection.Rows[RowIndex].Cells[0].Value.ToString()); if (!surface.AccessInsert()) { ed.WriteMessage("Failed surface INSERT\n"); } } }
private void BindDataToGridSection() { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; foreach (DataRow dr in dtSectionNumber.Rows) { ed.WriteMessage("SectionCode={0},SectionNumber={1}\n", new Guid(dr["SectionCode"].ToString()), dr["SectionNumber"].ToString()); Atend.Base.Calculating.CStartEnd startEnd = Atend.Base.Calculating.CStartEnd.AccessSelectBySectionCode(new Guid(dr["SectionCode"].ToString())); ed.WriteMessage("*****Start={0},End={1}\n", startEnd.StartPole, startEnd.EndPole); Atend.Base.Design.DPackage dPackStart = Atend.Base.Design.DPackage.AccessSelectByNodeCode(startEnd.StartPole); Atend.Base.Design.DPackage dPackEnd = Atend.Base.Design.DPackage.AccessSelectByNodeCode(startEnd.EndPole); dr["StartPole"] = dPackStart.Number; dr["EndPole"] = dPackEnd.Number; Atend.Base.Calculating.CSetDefaultMec cSetDefaultmec = Atend.Base.Calculating.CSetDefaultMec.AccessSelect(); System.Data.DataTable dtNetDefault = Atend.Base.Calculating.CNetWorkCross.AccessSelectAll(); Atend.Base.Calculating.CDefaultRudSurface defaultRudSurface = Atend.Base.Calculating.CDefaultRudSurface.AccessSelectBySectionCode(new Guid(dr["SectionCode"].ToString())); if (defaultRudSurface.Code != 0) { dr["UTS"] = defaultRudSurface.UTS; dr["NetCrossCode"] = defaultRudSurface.NetCross; } else { dr["UTS"] = cSetDefaultmec.Uts; dr["NetCrossCode"] = Convert.ToInt32(dtNetDefault.Rows[0]["Code"].ToString()); } } ed.WriteMessage(" EXIT BindDataToGridSection\n"); gvSection.AutoGenerateColumns = false; gvSection.DataSource = dtSectionNumber; }