Ejemplo n.º 1
0
        public DataTable PostVehicleDriverQuery([FromBody] vehicledrivercls dcls)
        {
            string w_clause = "";

            if (dcls.drivername != "" && dcls.drivername != "undefined" && dcls.drivername != null)
            {
                w_clause = w_clause + " and DriverId in (select id from driverinfo where name like '%" + dcls.drivername + "%')";
            }

            if (dcls.devicemodel != "" && dcls.devicemodel != "undefined" && dcls.devicemodel != null)
            {
                w_clause = w_clause + " and DeviceModel like '%" + dcls.devicemodel + "%'";
            }

            if (dcls.deviceno != "" && dcls.deviceno != "undefined" && dcls.deviceno != null)
            {
                w_clause = w_clause + " and DeviceNo like '%" + dcls.deviceno + "%'";
            }

            if (dcls.IMSI != "" && dcls.IMSI != "undefined" && dcls.IMSI != null)
            {
                w_clause = w_clause + " and IMSI like '%" + dcls.IMSI + "%'";
            }

            if (dcls.IMEI != "" && dcls.IMEI != "undefined" && dcls.IMEI != null)
            {
                w_clause = w_clause + " and IMEI like '%" + dcls.IMEI + "%'";
            }

            if (dcls.vehicleplateno != "" && dcls.vehicleplateno != "undefined" && dcls.vehicleplateno != null)
            {
                w_clause = w_clause + " and vehicleplateno like '%" + dcls.vehicleplateno + "%'";
            }


            if (w_clause != "")
            {
                w_clause = " where " + w_clause.Substring(4);
            }

            SqlConnection cont = new SqlConnection();

            cont.ConnectionString = constr2;
            cont.Open();
            DataTable      dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter("select * from VehicleDriver " + w_clause, cont);

            da.Fill(dt);
            cont.Close();
            cont.Dispose();
            //  List <DriverInfo> = new List<DriverInfo>;

            return(dt);
        }
Ejemplo n.º 2
0
        public string PostDelVehicleDriver([FromBody] vehicledrivercls dcls)
        {
            SqlConnection cont = new SqlConnection();

            cont.ConnectionString = constr2;
            cont.Open();
            DataTable dt = new DataTable();
            //SqlDataAdapter da = new SqlDataAdapter("select * from driverinfo " + HttpUtility.HtmlDecode(w_clause), cont);
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = cont;
            cmd.CommandText = " delete vehicledriver  where deviceno='" + dcls.deviceno + "' and vehicleplateno='" + dcls.vehicleplateno + "'";
            cmd.ExecuteNonQuery();
            //da.Fill(dt);
            cont.Close();
            cont.Dispose();
            return("Deleted Successfully");
        }
Ejemplo n.º 3
0
 public string PostInsVehicleDriver([FromBody] vehicledrivercls dcls)
 {
     try
     {
         SqlConnection cont = new SqlConnection();
         cont.ConnectionString = constr2;
         cont.Open();
         // DataTable dt = new DataTable();
         //SqlDataAdapter da = new SqlDataAdapter("select * from driverinfo " + HttpUtility.HtmlDecode(w_clause), cont);
         SqlCommand cmd = new SqlCommand();
         cmd.Connection  = cont;
         cmd.CommandText = " insert into vehicledriver(deviceno,vehicleplateno,driverid,devicemodel,imsi,imei,userid) values('" + dcls.deviceno + "','" + dcls.vehicleplateno + "','" + dcls.driverId + "','" + dcls.devicemodel + "','" + dcls.IMSI + "','" + dcls.IMEI + "','" + dcls.userid + "')";
         int Records = cmd.ExecuteNonQuery();
         //da.Fill(dt);
         cont.Close();
         cont.Dispose();
         return(Records + " Saved Successfully");
     }
     catch (Exception e)
     {
         return("error" + e.Message);
     }
 }