public static bool UpdateLinePoints(int LineCode, List <JLinePoint> linePoints, bool isAutoOrderNo, int PathType = 0) { ClassLibrary.JDataBase db = new ClassLibrary.JDataBase(); try { int order = 1; db.beginTransaction("linePoints"); db.setQuery("Delete From AUTFleetLinePoints Where LineCode = " + LineCode + "And PathType = " + PathType); db.Query_Execute(); string sql = @"declare @points table([LineCode] [int], [Latitude] [decimal](18, 14), [Longitude] [decimal](18, 14), [OrderNo] [smallint], [PathType] [tinyint], [DistanceLastPoint] [float] NOT NULL DEFAULT ((0)))" + " \r\n"; foreach (JLinePoint point in linePoints) { sql += @"INSERT INTO @points(LineCode,Latitude,Longitude,OrderNo,PathType) VALUES (" + point.LineCode + ", " + point.Latitude + ", " + point.Longitude + ", " + (isAutoOrderNo == true ? order : point.OrderNo) + ", " + PathType + ") \r\n"; order++; } sql += @" update point2 set [DistanceLastPoint] = dbo.GetDistance2Points(point1.Longitude, point1.Latitude, point2.Longitude, point2.Latitude) from @points point2 inner join @points point1 on point1.OrderNo = point2.OrderNo - 1 insert into AUTFleetLinePoints select [LineCode], [Latitude], [Longitude], [OrderNo], [PathType], sum([DistanceLastPoint]) over (order by orderno) from @points"; db.setQuery(sql); if (db.Query_Execute() >= 0) { db.Commit(); return(true); } db.Rollback("linePoints"); return(false); } finally { db.Dispose(); } }
public static bool DeleteLinePoints(int LineCode, int PathType = 0) { ClassLibrary.JDataBase db = new ClassLibrary.JDataBase(); try { int order = 1; db.beginTransaction("linePointsDel"); db.setQuery("Delete From AUTFleetLinePoints Where LineCode = " + LineCode + " And PathType = " + PathType); if (db.Query_Execute() >= 0) { db.Commit(); return(true); } db.Rollback("linePointsDel"); return(false); } finally { db.Dispose(); } }
public bool Update() { //JPersonAddressTable addressTable = new JPersonAddressTable(); //addressTable.SetValueProperty(this); //return addressTable.Update(); ClassLibrary.JDataBase db = ClassLibrary.JGlobal.MainFrame.GetDBO(); try { db.setQuery(@"UPDATE AVLUserVarify SET email=@email , phonenumber = @phonenumber, phoneVarified = @phoneVarified, emailVarified = @emailVarified WHERE userID=@userID"); db.AddParams("@email", this.email); db.AddParams("@phonenumber", this.phonenumber); db.AddParams("@phoneVarified", this.phoneVarified); db.AddParams("@emailVarified", this.emailVarified); db.AddParams("@userID", this.userID); db.beginTransaction("UpdateAVLUserVarify"); if (db.Query_Execute() > -1) { if (db.Commit()) { return(true); } } db.Rollback("UpdateAVLUserVarify"); return(false); } catch (Exception ex) { ClassLibrary.JSystem.Except.AddException(ex); db.Rollback("UpdateAVLUserVarify"); return(false); } finally { db.Dispose(); } }