Exemplo n.º 1
0
 public ActionResult EditMapLines(MapLinesEditModel model)
 {
     if (ModelState.IsValid)
     {
         var result = MapLinesBLL.EditMapLines(model, base.CurrentUserID, base.CurrentStrucID);
         base.DoLog(OperationTypeEnum.Edit, result, "LinesName:" + model.LinesName);
         return(Json(result));
     }
     else
     {
         return(PartialView("_EditMapLines", model));
     }
 }
Exemplo n.º 2
0
        public static OperationResult EditMapLines(MapLinesEditModel model, int currentUserID, int currentStrucID)
        {
            int result = 0;

            #region 更新主表
            var            updateSql   = @"UPDATE dbo.MapLinesList
                      SET LinesName = @LinesName ,
                      StartTime = @StartTime ,
                      EndTime = @EndTime ,
                      UpdateTime = GetDate() ,
                      UpdateUserID = @UpdateUserID 
                     WHERE  ID = @ID ";
            SqlParameter[] updateParas = new SqlParameter[5];
            updateParas[0] = new SqlParameter()
            {
                ParameterName = "@LinesName",
                SqlDbType     = SqlDbType.NVarChar,
                Size          = 50,
                Value         = model.LinesName
            };
            if (string.IsNullOrEmpty(model.StartTime))
            {
                updateParas[1] = new SqlParameter()
                {
                    ParameterName = "@StartTime",
                    SqlDbType     = SqlDbType.DateTime,
                    Value         = DBNull.Value
                };
            }
            else
            {
                updateParas[1] = new SqlParameter()
                {
                    ParameterName = "@StartTime",
                    SqlDbType     = SqlDbType.DateTime,
                    Value         = model.StartTime
                };
            }
            if (string.IsNullOrEmpty(model.EndTime))
            {
                updateParas[2] = new SqlParameter()
                {
                    ParameterName = "@EndTime",
                    SqlDbType     = SqlDbType.DateTime,
                    Value         = DBNull.Value
                };
            }
            else
            {
                updateParas[2] = new SqlParameter()
                {
                    ParameterName = "@EndTime",
                    SqlDbType     = SqlDbType.DateTime,
                    Value         = model.EndTime
                };
            }
            updateParas[3] = new SqlParameter()
            {
                ParameterName = "@UpdateUserID",
                SqlDbType     = SqlDbType.Int,
                Value         = currentUserID
            };
            updateParas[4] = new SqlParameter()
            {
                ParameterName = "@ID",
                SqlDbType     = SqlDbType.BigInt,
                Value         = model.ID
            };
            int updateResult = MSSQLHelper.ExecuteNonQuery(CommandType.Text, updateSql, updateParas);
            #endregion


            #region  除
            var            delSql   = @"DELETE FROM dbo.MapLinesDetails WHERE LinesID=@LinesID";
            SqlParameter[] delParas = new SqlParameter[1];
            delParas[0] = new SqlParameter()
            {
                ParameterName = "@LinesID",
                SqlDbType     = SqlDbType.BigInt,
                Value         = model.ID
            };
            int delResult = MSSQLHelper.ExecuteNonQuery(CommandType.Text, delSql, delParas);
            #endregion


            #region 添加明细表
            int              orderID    = 0;//定位点序号
            int              len        = model.MapLinesDetails.Count;
            string[]         sqls       = new string[len];
            SqlParameter[][] linesParas = new SqlParameter[len][];
            int              num        = 0;
            for (int i = 0; i < len; i++)
            {
                string tempSql = string.Empty;
                tempSql            = @"INSERT  INTO dbo.MapLinesDetails( LinesID, OrderID, Latitude, Longitude, RoadWidth, IsCheckTime, MaxSecond, MinSecond, IsCheckSpeed, SpeedLimit, OverSpeedDuration ) VALUES  ( @LinesID,@OrderID,@Latitude,@Longitude,@RoadWidth,@IsCheckTime,@MaxSecond,@MinSecond,@IsCheckSpeed,@SpeedLimit,@OverSpeedDuration)";
                sqls[num]          = tempSql;
                linesParas[num]    = new SqlParameter[11];
                linesParas[num][0] = new SqlParameter()
                {
                    ParameterName = "@LinesID",
                    SqlDbType     = SqlDbType.BigInt,
                    Value         = model.ID
                };
                linesParas[num][1] = new SqlParameter()
                {
                    ParameterName = "@OrderID",
                    SqlDbType     = SqlDbType.TinyInt,
                    Value         = orderID
                };
                //纠偏
                double lat = double.Parse(model.MapLinesDetails[i].Latitude.ToString());
                double lng = double.Parse(model.MapLinesDetails[i].Longitude.ToString());
                //NetDecry.Fix(ref lng, ref lat, false);
                Rectify.Gcj02_To_Wgs84(ref lat, ref lng);
                linesParas[num][2] = new SqlParameter()
                {
                    ParameterName = "@Latitude",
                    SqlDbType     = SqlDbType.Float,
                    Value         = lat
                };
                linesParas[num][3] = new SqlParameter()
                {
                    ParameterName = "@Longitude",
                    SqlDbType     = SqlDbType.Float,
                    Value         = lng
                };
                if (model.MapLinesDetails[i].RoadWidth == null)
                {
                    linesParas[num][4] = new SqlParameter()
                    {
                        ParameterName = "@RoadWidth",
                        SqlDbType     = SqlDbType.Float,
                        Value         = DBNull.Value
                    };
                }
                else
                {
                    linesParas[num][4] = new SqlParameter()
                    {
                        ParameterName = "@RoadWidth",
                        SqlDbType     = SqlDbType.Float,
                        Value         = model.MapLinesDetails[i].RoadWidth
                    };
                }
                linesParas[num][5] = new SqlParameter()
                {
                    ParameterName = "@IsCheckTime",
                    SqlDbType     = SqlDbType.Bit,
                    Value         = false
                };
                if (model.MapLinesDetails[i].MaxSecond == null)
                {
                    linesParas[num][6] = new SqlParameter()
                    {
                        ParameterName = "@MaxSecond",
                        SqlDbType     = SqlDbType.Int,
                        Value         = DBNull.Value
                    };
                }
                else
                {
                    linesParas[num][6] = new SqlParameter()
                    {
                        ParameterName = "@MaxSecond",
                        SqlDbType     = SqlDbType.Int,
                        Value         = model.MapLinesDetails[i].MaxSecond
                    };
                }
                if (model.MapLinesDetails[i].MinSecond == null)
                {
                    linesParas[num][7] = new SqlParameter()
                    {
                        ParameterName = "@MinSecond",
                        SqlDbType     = SqlDbType.Float,
                        Value         = DBNull.Value
                    };
                }
                else
                {
                    linesParas[num][7] = new SqlParameter()
                    {
                        ParameterName = "@MinSecond",
                        SqlDbType     = SqlDbType.Float,
                        Value         = model.MapLinesDetails[i].MinSecond
                    };
                }
                linesParas[num][8] = new SqlParameter()
                {
                    ParameterName = "@IsCheckSpeed",
                    SqlDbType     = SqlDbType.Bit,
                    Value         = false
                };
                if (model.MapLinesDetails[i].SpeedLimit == null)
                {
                    linesParas[num][9] = new SqlParameter()
                    {
                        ParameterName = "@SpeedLimit",
                        SqlDbType     = SqlDbType.Float,
                        Value         = DBNull.Value
                    };
                }
                else
                {
                    linesParas[num][9] = new SqlParameter()
                    {
                        ParameterName = "@SpeedLimit",
                        SqlDbType     = SqlDbType.Float,
                        Value         = model.MapLinesDetails[i].SpeedLimit
                    };
                }
                if (model.MapLinesDetails[i].OverSpeedDuration == null)
                {
                    linesParas[num][10] = new SqlParameter()
                    {
                        ParameterName = "@OverSpeedDuration",
                        SqlDbType     = SqlDbType.Int,
                        Value         = DBNull.Value
                    };
                }
                else
                {
                    linesParas[num][10] = new SqlParameter()
                    {
                        ParameterName = "@OverSpeedDuration",
                        SqlDbType     = SqlDbType.Int,
                        Value         = model.MapLinesDetails[i].OverSpeedDuration
                    };
                }
                //判断行驶时间选中,限速、最高速度、超速持续时间控件不可用,数据未传递过来
                if (model.MapLinesDetails[i].IsCheckTime == true)
                {
                    linesParas[num][5] = new SqlParameter()
                    {
                        ParameterName = "@IsCheckTime",
                        SqlDbType     = SqlDbType.Bit,
                        Value         = true
                    };
                    linesParas[num][6] = new SqlParameter()
                    {
                        ParameterName = "@MaxSecond",
                        SqlDbType     = SqlDbType.Int,
                        Value         = model.MapLinesDetails[i].MaxSecond
                    };
                    linesParas[num][7] = new SqlParameter()
                    {
                        ParameterName = "@MinSecond",
                        SqlDbType     = SqlDbType.Float,
                        Value         = model.MapLinesDetails[i].MinSecond
                    };
                    linesParas[num][8] = new SqlParameter()
                    {
                        ParameterName = "@IsCheckSpeed",
                        SqlDbType     = SqlDbType.Bit,
                        Value         = false
                    };
                    linesParas[num][9] = new SqlParameter()
                    {
                        ParameterName = "@SpeedLimit",
                        SqlDbType     = SqlDbType.Float,
                        Value         = DBNull.Value
                    };
                    linesParas[num][10] = new SqlParameter()
                    {
                        ParameterName = "@OverSpeedDuration",
                        SqlDbType     = SqlDbType.Int,
                        Value         = DBNull.Value
                    };
                }
                //限速选中,判断行驶时间、路段行驶过长、路段行驶不足控件不可用,数据未传递过来
                if (model.MapLinesDetails[i].IsCheckSpeed == true)
                {
                    linesParas[num][5] = new SqlParameter()
                    {
                        ParameterName = "@IsCheckTime",
                        SqlDbType     = SqlDbType.Bit,
                        Value         = false
                    };
                    linesParas[num][6] = new SqlParameter()
                    {
                        ParameterName = "@MaxSecond",
                        SqlDbType     = SqlDbType.Int,
                        Value         = DBNull.Value
                    };
                    linesParas[num][7] = new SqlParameter()
                    {
                        ParameterName = "@MinSecond",
                        SqlDbType     = SqlDbType.Float,
                        Value         = DBNull.Value
                    };
                    linesParas[num][8] = new SqlParameter()
                    {
                        ParameterName = "@IsCheckSpeed",
                        SqlDbType     = SqlDbType.Bit,
                        Value         = true
                    };
                    linesParas[num][9] = new SqlParameter()
                    {
                        ParameterName = "@SpeedLimit",
                        SqlDbType     = SqlDbType.Float,
                        Value         = model.MapLinesDetails[i].SpeedLimit
                    };
                    linesParas[num][10] = new SqlParameter()
                    {
                        ParameterName = "@OverSpeedDuration",
                        SqlDbType     = SqlDbType.Int,
                        Value         = model.MapLinesDetails[i].OverSpeedDuration
                    };
                }
                num++;
                orderID++;
            }
            bool insertResult = MSSQLHelper.ExecuteTransaction(CommandType.Text, sqls, linesParas);
            if (updateResult > 0 && delResult != 0 && insertResult == true)
            {
                result = 1;
            }

            #endregion

            string msg = string.Empty;
            switch (result)
            {
            case 1:
                msg = PromptInformation.OperationSuccess;
                break;

            case 0:
                msg = PromptInformation.NotExists;
                break;

            case -1:
                msg = PromptInformation.DBError;
                break;
            }
            return(new OperationResult()
            {
                Success = result > 0,
                Message = msg
            });
        }
Exemplo n.º 3
0
        public static SelectResult <MapLinesEditModel> GetMapLinesByID(int id)
        {
            List <SqlParameter> paras = new List <SqlParameter>()
            {
                new SqlParameter()
                {
                    ParameterName = "@ID",
                    SqlDbType     = SqlDbType.BigInt,
                },
            };

            paras[0].Value = id;
            string sql = @"SELECT ID ,LinesType ,LinesName ,StartTime ,EndTime ,Remark
      FROM dbo.MapLinesList
      WHERE Status=0 AND ID=@ID";

            List <MapLinesEditModel> list = ConvertToList <MapLinesEditModel> .Convert(MSSQLHelper.ExecuteDataTable(CommandType.Text, sql, paras.ToArray()));

            MapLinesEditModel data = null;
            string            msg  = string.Empty;

            if (list == null)
            {
                msg = PromptInformation.DBError;
            }
            else if (list.Count == 0)
            {
                msg = PromptInformation.NotExists;
            }
            else
            {
                List <SqlParameter> detailParas = new List <SqlParameter>()
                {
                    new SqlParameter()
                    {
                        ParameterName = "@ID",
                        SqlDbType     = SqlDbType.BigInt,
                    },
                };
                detailParas[0].Value = id;
                string detailSql = @"SELECT OrderID ,Latitude ,Longitude ,RoadWidth ,IsCheckTime,
MaxSecond,MinSecond,IsCheckSpeed,SpeedLimit,OverSpeedDuration ,IsSouthLatitude,IsWestLongitude
FROM dbo.MapLinesDetails
WHERE LinesID=@ID";

                List <MapLinesDetailsEditModel> detailList = ConvertToList <MapLinesDetailsEditModel> .Convert(MSSQLHelper.ExecuteDataTable(CommandType.Text, detailSql, detailParas.ToArray()));

                if (detailList != null && detailList.Count != 0)
                {
                    string points = string.Empty;
                    for (int i = 0; i < detailList.Count; i++)
                    {
                        //纠偏
                        double lng = double.Parse(detailList[i].Longitude.ToString());
                        double lat = double.Parse(detailList[i].Latitude.ToString());
                        //NetDecry.Fix(ref lng, ref lat, true);
                        Rectify.Wgs84_To_Gcj02(ref lat, ref lng);
                        detailList[i].Longitude = (float)lng;
                        detailList[i].Latitude  = (float)lat;

                        points = points + lng.ToString() + ",";
                        points = points + lat.ToString() + ",";
                    }
                    list[0].MapLinesPoints  = points;
                    list[0].MapLinesDetails = detailList;
                }
                data = list[0];
            }
            return(new SelectResult <MapLinesEditModel>()
            {
                DataResult = data,
                Message = msg
            });
        }